Skip to content

Commit

Permalink
Merge pull request #166 from slonopotamus/dispose-exceptions
Browse files Browse the repository at this point in the history
Stop swallowing exceptions that happen in `TestEnvironment#dispose()`
  • Loading branch information
oleg-nenashev authored Oct 8, 2019
2 parents ea28426 + a07387a commit 07275e8
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions src/main/java/org/jvnet/hudson/test/JenkinsRule.java
Original file line number Diff line number Diff line change
Expand Up @@ -509,21 +509,19 @@ public void after() throws Exception {

try {
env.dispose();
} catch (Exception x) {
x.printStackTrace();
}

// Hudson creates ClassLoaders for plugins that hold on to file descriptors of its jar files,
// but because there's no explicit dispose method on ClassLoader, they won't get GC-ed until
// at some later point, leading to possible file descriptor overflow. So encourage GC now.
// see http://bugs.sun.com/view_bug.do?bug_id=4950148
// TODO use URLClassLoader.close() in Java 7
System.gc();

// restore defaultUseCache
if(Functions.isWindows()) {
URLConnection aConnection = new File(".").toURI().toURL().openConnection();
aConnection.setDefaultUseCaches(origDefaultUseCache);
} finally {
// Hudson creates ClassLoaders for plugins that hold on to file descriptors of its jar files,
// but because there's no explicit dispose method on ClassLoader, they won't get GC-ed until
// at some later point, leading to possible file descriptor overflow. So encourage GC now.
// see http://bugs.sun.com/view_bug.do?bug_id=4950148
// TODO use URLClassLoader.close() in Java 7
System.gc();

// restore defaultUseCache
if(Functions.isWindows()) {
URLConnection aConnection = new File(".").toURI().toURL().openConnection();
aConnection.setDefaultUseCaches(origDefaultUseCache);
}
}
}
}
Expand Down

0 comments on commit 07275e8

Please sign in to comment.