Skip to content

Commit dee49a3

Browse files
committed
release resources - Fortify
1 parent 5321c47 commit dee49a3

File tree

7 files changed

+25
-14
lines changed

7 files changed

+25
-14
lines changed

visualvm/appui/src/org/graalvm/visualvm/modules/appui/AboutAction.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ private String getBuildNumber() {
9898
try {
9999
InputStream manifestStream = getClass().getResourceAsStream("/META-INF/MANIFEST.MF"); // NOI18N
100100
buildNumber = new Manifest(manifestStream).getMainAttributes().getValue("OpenIDE-Module-Implementation-Version"); // NOI18N
101+
manifestStream.close();
101102
} catch (IOException ex) {}
102103
}
103104

visualvm/libs.profiler/lib.profiler/src/org/graalvm/visualvm/lib/jfluid/heap/AbstractLongMap.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ abstract class Entry {
100100
}
101101
file.setLength(fileSize);
102102
setDumpBuffer(file);
103+
file.close();
103104
cacheDirectory = cacheDir;
104105
}
105106

@@ -216,6 +217,7 @@ void writeToStream(DataOutputStream out) throws IOException {
216217
fileSize = keys * ENTRY_SIZE;
217218
RandomAccessFile file = new RandomAccessFile(tempFile, "rw"); // NOI18N
218219
setDumpBuffer(file);
220+
file.close();
219221
cacheDirectory = cacheDir;
220222
}
221223

@@ -514,6 +516,7 @@ public void force(File bufferFile) throws IOException{
514516
channel.write(buf);
515517
offset_start = (int)(offset_end - (i+1)*BUFFER_SIZE);
516518
}
519+
channel.close();
517520
dumpBuffer = null;
518521
bufferFile.delete();
519522
newBufferFile.renameTo(bufferFile);
@@ -535,6 +538,7 @@ private static MappedByteBuffer[] createBuffers(RandomAccessFile file, long leng
535538
dumpBuffer[i] = channel.map(MemoryMappedData.MAP_MODE, position, size);
536539
}
537540
channel.close();
541+
file.close();
538542
return dumpBuffer;
539543
}
540544
}

visualvm/libs.profiler/lib.profiler/src/org/graalvm/visualvm/lib/jfluid/heap/LongBuffer.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ LongBuffer revertBuffer() throws IOException {
201201
raf.seek(offset);
202202
reverted.writeLong(raf.readLong());
203203
}
204+
raf.close();
204205
}
205206
reverted.startReading();
206207
return reverted;

visualvm/libs.profiler/lib.profiler/src/org/graalvm/visualvm/lib/jfluid/utils/FileOrZipEntry.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,10 @@ public long getLength() throws IOException {
140140
return (new File(dirOrJar, fileName)).length();
141141
} else {
142142
ZipFile zip = new ZipFile(dirOrJar);
143+
long size = zip.getEntry(fileName).getSize();
143144

144-
return zip.getEntry(fileName).getSize();
145+
zip.close();
146+
return size;
145147
}
146148
}
147149

visualvm/libs.profiler/lib.profiler/src/org/graalvm/visualvm/lib/jfluid/utils/MiscUtils.java

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -157,24 +157,24 @@ public static void getAllClassesInJar(String jarName, boolean removeClassExt, Co
157157

158158
try {
159159
zip = new ZipFile(jarName);
160-
} catch (Exception ex) {
161-
System.err.println("Warning: could not open archive " + jarName); // NOI18N
162-
163-
return;
164-
}
160+
for (Enumeration entries = zip.entries(); entries.hasMoreElements();) {
161+
ZipEntry entry = (ZipEntry) entries.nextElement();
162+
String className = entry.getName();
165163

166-
for (Enumeration entries = zip.entries(); entries.hasMoreElements();) {
167-
ZipEntry entry = (ZipEntry) entries.nextElement();
168-
String className = entry.getName();
164+
if (className.endsWith(".class")) { // NOI18N
169165

170-
if (className.endsWith(".class")) { // NOI18N
166+
if (removeClassExt) {
167+
className = className.substring(0, className.length() - 6);
168+
}
171169

172-
if (removeClassExt) {
173-
className = className.substring(0, className.length() - 6);
170+
res.add(className.intern());
174171
}
175-
176-
res.add(className.intern());
177172
}
173+
zip.close();
174+
} catch (Exception ex) {
175+
System.err.println("Warning: could not open archive " + jarName); // NOI18N
176+
177+
return;
178178
}
179179
}
180180

@@ -402,6 +402,7 @@ private static void getClassPathFromManifest(String jarPath,List pathList) throw
402402
}
403403
}
404404
}
405+
jarFile.close();
405406
}
406407
}
407408

visualvm/profiling/src/org/graalvm/visualvm/profiling/presets/ProfilerPresets.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,7 @@ private static String getMainClass(Application application) {
286286
String mainClassName = jf.getManifest().getMainAttributes().getValue(Attributes.Name.MAIN_CLASS);
287287
assert mainClassName!=null;
288288
mainClass = mainClassName.replace('\\', '/').replace('/', '.'); // NOI18N
289+
jf.close();
289290
} catch (IOException ex) {
290291
// LOGGER.log(Level.INFO, "getMainClass", ex); // NOI18N
291292
}

visualvm/tools/src/org/graalvm/visualvm/tools/jvmstat/JvmJvmstatModel.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ public String getMainClass() {
258258
JarFile jf = new JarFile(jarFile);
259259
mainClassName = jf.getManifest().getMainAttributes().getValue(Attributes.Name.MAIN_CLASS);
260260
assert mainClassName!=null;
261+
jf.close();
261262
} catch (IOException ex) {
262263
LOGGER.throwing(JvmJvmstatModel.class.getName(), "getMainClass", ex); // NOI18N
263264
}

0 commit comments

Comments
 (0)