From 698e5384d9b32aca091417b16977703a6b3d20e2 Mon Sep 17 00:00:00 2001
From: gprat <guylaine.prat@c-s.fr>
Date: Wed, 1 Jul 2020 12:13:07 +0200
Subject: [PATCH] Improved use of try with resources statement.

---
 src/main/java/org/orekit/rugged/errors/RuggedMessages.java | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/src/main/java/org/orekit/rugged/errors/RuggedMessages.java b/src/main/java/org/orekit/rugged/errors/RuggedMessages.java
index 740e92f3..98accfea 100644
--- a/src/main/java/org/orekit/rugged/errors/RuggedMessages.java
+++ b/src/main/java/org/orekit/rugged/errors/RuggedMessages.java
@@ -21,6 +21,7 @@ import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.net.URL;
 import java.net.URLConnection;
+import java.nio.charset.StandardCharsets;
 import java.util.Locale;
 import java.util.MissingResourceException;
 import java.util.PropertyResourceBundle;
@@ -164,11 +165,9 @@ public enum RuggedMessages implements Localizable {
                 stream = loader.getResourceAsStream(resourceName);
             }
             if (stream != null) {
-                try {
+                try (InputStreamReader inputStreamReader = new InputStreamReader(stream, StandardCharsets.UTF_8)) {
                     // Only this line is changed to make it to read properties files as UTF-8.
-                    bundle = new PropertyResourceBundle(new InputStreamReader(stream, "UTF-8"));
-                } finally {
-                    stream.close();
+                    bundle = new PropertyResourceBundle(inputStreamReader);
                 }
             }
             return bundle;
-- 
GitLab