Skip to content

Commit 98d1d63

Browse files
committed
Cannot use AutoCloseableSupplier in 2.7.x
1 parent 8687498 commit 98d1d63

1 file changed

Lines changed: 15 additions & 16 deletions

File tree

src/test/java/com/hubspot/jinjava/el/ext/JinjavaBeanELResolverTest.java

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import com.hubspot.jinjava.JinjavaConfig;
1111
import com.hubspot.jinjava.el.JinjavaELContext;
1212
import com.hubspot.jinjava.interpret.JinjavaInterpreter;
13+
import java.util.ArrayList;
1314
import java.util.List;
1415
import javax.el.ELContext;
1516
import 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

Comments
 (0)