Skip to content

Commit 3cc8794

Browse files
committed
Bug: warning "Resource leak: 'reader' is never closed" in PathUtil.java
1 parent bf8dd1f commit 3cc8794

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

sources/net.sf.j2s.ui/src/net/sf/j2s/ui/classpath/PathUtil.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
import java.util.List;
1212
import java.util.Properties;
1313

14+
import net.sf.j2s.core.compiler.FileUtil;
15+
1416
public class PathUtil {
1517
public static final String J2S_RESOURCES_LIST = "j2s.resources.list";
1618
public static final String J2S_ABANDOMED_RESOURCES_LIST = "j2s.abandoned.resources.list";
@@ -147,8 +149,9 @@ public static String joinArray(String[] list, String seperator) {
147149
public static Properties loadJZ(File file) {
148150
Properties props = new Properties();
149151
if (file.exists()) {
152+
FileReader reader = null;
150153
try {
151-
FileReader reader = new FileReader(file);
154+
reader = new FileReader(file);
152155
char[] buf = new char[1024];
153156
StringBuffer buffer = new StringBuffer();
154157
int read = 0;
@@ -184,6 +187,8 @@ public static Properties loadJZ(File file) {
184187
e1.printStackTrace();
185188
} catch (IOException e1) {
186189
e1.printStackTrace();
190+
} finally {
191+
FileUtil.close(reader);
187192
}
188193
}
189194
return props;

0 commit comments

Comments
 (0)