Skip to content

Commit 2a25bde

Browse files
committed
Closing a few BufferedReaders and InputStreams
1 parent f7cd672 commit 2a25bde

3 files changed

Lines changed: 20 additions & 3 deletions

File tree

app/src/processing/app/Recent.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ protected void load() throws IOException {
8484
}
8585
}
8686
}
87+
reader.close();
8788
}
8889
updateMenu(mainMenu);
8990
updateMenu(toolbarMenu);

core/src/processing/core/PApplet.java

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4910,6 +4910,7 @@ protected PImage loadImageIO(String filename) {
49104910
// with the old method.
49114911
outgoing.checkAlpha();
49124912

4913+
stream.close();
49134914
// return the image
49144915
return outgoing;
49154916

@@ -5120,7 +5121,7 @@ header[17] image descriptor (packed bits)
51205121
}
51215122
}
51225123
}
5123-
5124+
is.close();
51245125
return outgoing;
51255126
}
51265127

@@ -6300,7 +6301,13 @@ static public byte[] loadBytes(InputStream input) {
63006301
*/
63016302
static public byte[] loadBytes(File file) {
63026303
InputStream is = createInput(file);
6303-
return loadBytes(is);
6304+
byte[] byteArr = loadBytes(is);
6305+
try {
6306+
is.close();
6307+
} catch (IOException e) {
6308+
e.printStackTrace();
6309+
}
6310+
return byteArr;
63046311
}
63056312

63066313
/**
@@ -6366,7 +6373,15 @@ static public String[] loadStrings(File file) {
63666373
*/
63676374
public String[] loadStrings(String filename) {
63686375
InputStream is = createInput(filename);
6369-
if (is != null) return loadStrings(is);
6376+
if (is != null) {
6377+
String[] strArr = loadStrings(is);
6378+
try {
6379+
is.close();
6380+
} catch (IOException e) {
6381+
e.printStackTrace();
6382+
}
6383+
return strArr;
6384+
}
63706385

63716386
System.err.println("The file \"" + filename + "\" " +
63726387
"is missing or inaccessible, make sure " +

core/src/processing/core/PShapeOBJ.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ static protected void parseOBJ(PApplet parent, String path,
232232
BufferedReader mreader = parent.createReader(fn);
233233
if (mreader != null) {
234234
parseMTL(parent, path, mreader, materials, mtlTable);
235+
mreader.close();
235236
}
236237
}
237238
} else if (parts[0].equals("g")) {

0 commit comments

Comments
 (0)