jMonkeyEngine-Contributions / Lemur

Lemur is a jMonkeyEngine-based UI toolkit.
http://jmonkeyengine-contributions.github.io/Lemur/
BSD 3-Clause "New" or "Revised" License
116 stars 33 forks source link

StyleLoader#loadStyle(URL) doesn't close the stream. #121

Open zt2mUTDm opened 8 months ago

zt2mUTDm commented 8 months ago

The method loadStyle(URL) in com.simsilica.lemur.style.StyleLoader doesn't close the InputStream.

I would change it in this way:

@@ -158,8 +158,8 @@                                                                                                                                                                                                                                                                                                               
     }                                                                                                                                                                                                                                                                                                                            

     public void loadStyle( URL u ) {
-        try {
-            loadStyle(u.toString(), new InputStreamReader(u.openStream()));
+        try( Reader in = new InputStreamReader(u.openStream()) ) {
+            loadStyle(u.toString(), in);
         } catch( IOException e ) {
             throw new RuntimeException("Error opening stream for:" + u, e);
         }