You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2024/06/01 18:51:53 UTC
(commons-jexl) 02/08: Use try-with-resources
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-jexl.git
commit d6eb5876ac0a138c8b14f8fa0a4304443d5d4469
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sat Jun 1 14:29:13 2024 -0400
Use try-with-resources
---
.../java/org/apache/commons/jexl3/ComposePermissionsTest.java | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/src/test/java/org/apache/commons/jexl3/ComposePermissionsTest.java b/src/test/java/org/apache/commons/jexl3/ComposePermissionsTest.java
index 7b50e636..d3ff5e7c 100644
--- a/src/test/java/org/apache/commons/jexl3/ComposePermissionsTest.java
+++ b/src/test/java/org/apache/commons/jexl3/ComposePermissionsTest.java
@@ -45,8 +45,11 @@ public class ComposePermissionsTest extends JexlTestCase {
final String check = "http://example.com/content.jpg";
final File jsonFile = new File(SAMPLE_JSON);
final Gson gson = new Gson();
- final Object json = gson.fromJson(new FileReader(jsonFile), Object.class);
- assertNotNull(json);
+ final Object json;
+ try (final FileReader reader = new FileReader(jsonFile)) {
+ json = gson.fromJson(reader, Object.class);
+ assertNotNull(json);
+ }
// will succeed because java.util.Map is allowed and gson LinkedTreeMap is one
final JexlEngine j0 = createEngine(false, p);
@@ -69,7 +72,7 @@ public class ComposePermissionsTest extends JexlTestCase {
// will not fail since gson objects
j1 = createEngine(false, JexlPermissions.RESTRICTED);
final JexlScript s3 = j1.createScript("json.pageInfo.pagePic", "json");
- final Object r1 = s3.execute(null, json);
+ s3.execute(null, json);
assertEquals(check, r0);
}