1010import com .hubspot .jinjava .JinjavaConfig ;
1111import com .hubspot .jinjava .el .JinjavaELContext ;
1212import com .hubspot .jinjava .interpret .JinjavaInterpreter ;
13+ import java .util .ArrayList ;
1314import java .util .List ;
1415import javax .el .ELContext ;
1516import javax .el .MethodNotFoundException ;
@@ -189,25 +190,21 @@ public void itDoesNotAllowAccessingPropertiesOfInterpreter() {
189190
190191 @ Test
191192 public void itDoesNotGettingFromObjectMapper () {
192- try (
193- AutoCloseableSupplier .AutoCloseableImpl <JinjavaInterpreter > c = JinjavaInterpreter
194- .closeablePushCurrent (interpreter )
195- .get ()
196- ) {
193+ JinjavaInterpreter .pushCurrent (interpreter );
194+ try {
197195 assertThat (
198196 jinjavaBeanELResolver .getValue (elContext , new ObjectMapper (), "dateFormat" )
199197 )
200198 .isNull ();
199+ } finally {
200+ JinjavaInterpreter .popCurrent ();
201201 }
202202 }
203203
204204 @ Test
205205 public void itDoesNotAllowInvokingFromObjectMapper () throws NoSuchMethodException {
206- try (
207- AutoCloseableSupplier .AutoCloseableImpl <JinjavaInterpreter > c = JinjavaInterpreter
208- .closeablePushCurrent (interpreter )
209- .get ()
210- ) {
206+ JinjavaInterpreter .pushCurrent (interpreter );
207+ try {
211208 ObjectMapper objectMapper = new ObjectMapper ();
212209 assertThatThrownBy (() ->
213210 jinjavaBeanELResolver .invoke (
@@ -219,17 +216,17 @@ public void itDoesNotAllowInvokingFromObjectMapper() throws NoSuchMethodExceptio
219216 )
220217 )
221218 .isInstanceOf (MethodNotFoundException .class );
219+ } finally {
220+ JinjavaInterpreter .popCurrent ();
222221 }
223222 }
224223
225224 @ Test
226225 public void itDoesNotAllowInvokingFromMethod () throws NoSuchMethodException {
227- try (
228- AutoCloseableSupplier .AutoCloseableImpl <JinjavaInterpreter > c = JinjavaInterpreter
229- .closeablePushCurrent (interpreter )
230- .get ()
231- ) {
232- List <String > list = List .of ("foo" );
226+ JinjavaInterpreter .pushCurrent (interpreter );
227+ try {
228+ List <String > list = new ArrayList <>();
229+ list .add ("foo" );
233230 assertThatThrownBy (() ->
234231 jinjavaBeanELResolver .invoke (
235232 elContext ,
@@ -240,6 +237,8 @@ public void itDoesNotAllowInvokingFromMethod() throws NoSuchMethodException {
240237 )
241238 )
242239 .isInstanceOf (MethodNotFoundException .class );
240+ } finally {
241+ JinjavaInterpreter .popCurrent ();
243242 }
244243 }
245244}
0 commit comments