Fix file lock issues with the skin cache

This commit is contained in:
Matthew Messinger 2018-08-24 21:38:29 -04:00
parent d20199fffb
commit 72324feaf3

View file

@ -193,7 +193,8 @@ public class ThreadDownloadImageETag extends SimpleTexture {
Files.createDirectories(cacheFile.getParent());
Files.copy(resp.getInputStream(), cacheFile);
BufferedImage bufferedimage = ImageIO.read(Files.newInputStream(cacheFile));
try (InputStream in = Files.newInputStream(cacheFile)) {
BufferedImage bufferedimage = ImageIO.read(in);
// maybe write the etag to disk
Header eTag = resp.getResponse().getFirstHeader(HttpHeaders.ETAG);
@ -206,6 +207,7 @@ public class ThreadDownloadImageETag extends SimpleTexture {
}
setBufferedImage(bufferedimage);
}
}
} catch (Exception exception) {
LOGGER.error("Couldn\'t download http texture", exception);
}