Skip to content

Commit 34103e6

Browse files
committed
use try-with-resources
1 parent 0bffc14 commit 34103e6

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

visualvm/libs.profiler/profiler/src/org/graalvm/visualvm/lib/profiler/ResultsManager.java

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1339,25 +1339,18 @@ private Lookup.Provider findProjectForSnapshot(FileObject selectedFile) {
13391339

13401340
private LoadedSnapshot loadSnapshotFromFileObject(FileObject selectedFile)
13411341
throws IOException {
1342-
DataInputStream dis = null;
1343-
1344-
try {
1342+
try (
13451343
InputStream is = selectedFile.getInputStream();
13461344
BufferedInputStream bis = new BufferedInputStream(is);
1347-
dis = new DataInputStream(bis);
1348-
1345+
DataInputStream dis = new DataInputStream(bis);
1346+
) {
13491347
LoadedSnapshot ls = LoadedSnapshot.loadSnapshot(dis);
13501348

13511349
if (ls != null) {
13521350
ls.setFile(FileUtil.toFile(selectedFile));
13531351
ls.setProject(findProjectForSnapshot(selectedFile));
13541352
}
1355-
13561353
return ls;
1357-
} finally {
1358-
if (dis != null) {
1359-
dis.close();
1360-
}
13611354
}
13621355
}
13631356

0 commit comments

Comments
 (0)