Skip to content

Commit

Permalink
[FIXED JENKINS-9349] let GZipInputStream release its native memory
Browse files Browse the repository at this point in the history
eagerly.
(cherry picked from commit 313fb59)

Conflicts:

	changelog.html
  • Loading branch information
kohsuke authored and vjuranek committed Dec 14, 2011
1 parent 3bf2e4f commit 7aab7eb
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
14 changes: 14 additions & 0 deletions changelog.html
Expand Up @@ -54,10 +54,24 @@

<!-- Record your changes in the trunk here. -->
<div id="trunk" style="display:none"><!--=TRUNK-BEGIN=-->
<ul class=image>
<<<<<<< HEAD
=======
<li class=>
</ul>
</div><!--=TRUNK-END=-->

<!-- these changes are controlled by the release process. DO NOT MODIFY -->
<div id="rc" style="display:none;"><!--=BEGIN=-->
<h3><a name=v1.438>What's new in 1.438</a> <!--=DATE=--></h3>
<ul class=image>
<li class=bug>
Fixed random OutOfMemoryError with console annotations
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-9349">issue 9349</a>)
<li class=bug>
Fixed the OutOfMemoryError in trying to download/install JDK
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-10689">issue 10689</a>)
<li class=bug>
If running as a daemon, don't daemonize one more time during restart.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-11742">issue 11742</a>)
</ul>
Expand Down
12 changes: 8 additions & 4 deletions core/src/main/java/hudson/console/AnnotatedLargeText.java
Expand Up @@ -121,10 +121,14 @@ private ConsoleAnnotator createAnnotator(StaplerRequest req) throws IOException
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);
Expand Down
6 changes: 5 additions & 1 deletion core/src/main/java/hudson/console/ConsoleNote.java
Expand Up @@ -222,7 +222,11 @@ public static ConsoleNote readFrom(DataInputStream in) throws IOException, Class

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.
Expand Down

0 comments on commit 7aab7eb

Please sign in to comment.