Fix memory leaks by closing streams

This commit is contained in:
Kam committed 2025-07-23 05:43:50 -04:00
1 parent 39e51bc8c2
commit 540508a2be
18 files changed
+96 -60

No files matched your search

@@ -122,10 +122,14 @@ public class ImageDownloadAlt extends SimpleTexture {
BufferedImage bufferedimage;
if (ImageDownloadAlt.this.cacheFile != null) {
FileUtils.copyInputStreamToFile(connection.getInputStream(), ImageDownloadAlt.this.cacheFile);
try (InputStream in = connection.getInputStream()) {
FileUtils.copyInputStreamToFile(in, ImageDownloadAlt.this.cacheFile);
}
bufferedimage = ImageIO.read(ImageDownloadAlt.this.cacheFile);
} else {
bufferedimage = ImageIO.read(connection.getInputStream());
try (InputStream in = connection.getInputStream()) {
bufferedimage = ImageIO.read(in);
}
}
if (ImageDownloadAlt.this.imageBuffer != null) {