[FIXED JENKINS-9349] let GZipInputStream release its native memory

eagerly.
This commit is contained in:
Kohsuke Kawaguchi committed 2011-11-03 16:23:05 -07:00
1 parent 92709ae16d
commit 313fb5940f
3 files changed
+16 -5

No files matched your search

@@ -121,10 +121,14 @@ public class AnnotatedLargeText<T> extends LargeText {
ObjectInputStream ois = new ObjectInputStreamEx(new GZIPInputStream(
new CipherInputStream(new ByteArrayInputStream(Base64.decode(base64.toCharArray())),sym)),
Jenkins.getInstance().pluginManager.uberClassLoader);
long timestamp = ois.readLong();
if (TimeUnit2.HOURS.toMillis(1) > abs(System.currentTimeMillis()-timestamp))
// don't deserialize something too old to prevent a replay attack
return (ConsoleAnnotator)ois.readObject();
try {
long timestamp = ois.readLong();
if (TimeUnit2.HOURS.toMillis(1) > abs(System.currentTimeMillis()-timestamp))
// don't deserialize something too old to prevent a replay attack
return (ConsoleAnnotator)ois.readObject();
} finally {
ois.close();
}
}
} catch (GeneralSecurityException e) {
throw new IOException2(e);
@@ -222,7 +222,11 @@ public abstract class ConsoleNote<T> implements Serializable, Describable<Consol
ObjectInputStream ois = new ObjectInputStreamEx(
new GZIPInputStream(new ByteArrayInputStream(buf)), Jenkins.getInstance().pluginManager.uberClassLoader);
return (ConsoleNote) ois.readObject();
try {
return (ConsoleNote) ois.readObject();
} finally {
ois.close();
}
} catch (Error e) {
// for example, bogus 'sz' can result in OutOfMemoryError.
// package that up as IOException so that the caller won't fatally die.