diff --git a/src/main/java/com/laytonsmith/core/functions/FileHandling.java b/src/main/java/com/laytonsmith/core/functions/FileHandling.java index 0a1bf12a6..965f2a4cc 100644 --- a/src/main/java/com/laytonsmith/core/functions/FileHandling.java +++ b/src/main/java/com/laytonsmith/core/functions/FileHandling.java @@ -453,7 +453,9 @@ public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntime } } InputStream stream = new GZIPInputStream(new FileInputStream(location)); - return CByteArray.wrap(StreamUtils.GetBytes(stream), t); + byte[] fileBytes = StreamUtils.GetBytes(stream); + stream.close(); + return CByteArray.wrap(fileBytes, t); } catch (IOException ex) { Static.getLogger().log(Level.SEVERE, "Could not read in file while attempting to find " + location.getAbsolutePath() + "\nFile " + (location.exists() ? "exists" : "does not exist")); @@ -514,7 +516,9 @@ public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntime throw new CRESecurityException("You do not have permission to access the file '" + location + "'", t); } InputStream stream = new BufferedInputStream(new FileInputStream(location)); - return CByteArray.wrap(StreamUtils.GetBytes(stream), t); + byte[] fileBytes = StreamUtils.GetBytes(stream); + stream.close(); + return CByteArray.wrap(fileBytes, t); } catch (IOException ex) { Static.getLogger().log(Level.SEVERE, "Could not read in file while attempting to find " + location.getAbsolutePath() + "\nFile " + (location.exists() ? "exists" : "does not exist"));