wujimin commented on a change in pull request #2103:
URL: 
https://github.com/apache/servicecomb-java-chassis/pull/2103#discussion_r536487595



##########
File path: 
service-registry/registry-local/src/main/java/org/apache/servicecomb/localregistry/LocalRegistryStore.java
##########
@@ -111,37 +111,38 @@ public MicroserviceInstance getSelfMicroserviceInstance() 
{
   private List<RegistryBean> loadYamlBeans() {
     List<RegistryBean> beans = new ArrayList<>();
 
-    InputStream is = null;
-
     try {
       ClassLoader loader = JvmUtils.findClassLoader();
       Enumeration<URL> urls = loader.getResources(REGISTRY_FILE_NAME);
+
       while (urls.hasMoreElements()) {
         URL url = urls.nextElement();
-        is = url.openStream();
-        if (is != null) {
-          beans.addAll(initFromData(is));
+
+        InputStream is = null;
+        try {
+          is = url.openStream();
+          if (is != null) {
+            beans.addAll(initFromData(is));
+          }
+        } finally {
+          if (is != null) {
+            try {
+              is.close();
+            } catch (IOException e) {
+              // nothing to do
+            }
+          }

Review comment:
       ```java
     try (InputStream is = url.openStream()) {
       if (is != null) {
         beans.addAll(initFromData(is));
       }
     }
   ```




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to