Skip to content

Commit

Permalink
Estimate ideal class loader caching: reuse the class loader of all cl…
Browse files Browse the repository at this point in the history
…asses
  • Loading branch information
luontola committed Feb 10, 2013
1 parent 3051283 commit b9e3015
Showing 1 changed file with 3 additions and 29 deletions.
32 changes: 3 additions & 29 deletions jumi-core/src/main/java/fi/jumi/core/suite/SuiteFactory.java
Expand Up @@ -17,7 +17,7 @@
import fi.jumi.core.util.*;

import javax.annotation.concurrent.NotThreadSafe;
import java.io.*;
import java.io.PrintStream;
import java.net.*;
import java.nio.file.*;
import java.util.*;
Expand Down Expand Up @@ -49,29 +49,10 @@ public SuiteFactory(DaemonConfiguration daemonConfiguration, OutputCapturer outp
}

public void configure(SuiteConfiguration suite) {
List<URI> dependencies = new ArrayList<>();
List<URI> application = new ArrayList<>();
for (URI uri : suite.getClassPath()) {
String path = uri.getPath();
if (path.contains("dimdwarf") ||
path.contains("jdave") ||
path.contains("mockito") ||
path.contains("jmock")) {
application.add(uri);
} else {
dependencies.add(uri);
}
}

if (cachedClassLoader == null) {
cachedClassLoader = createClassLoader(dependencies);
}
try {
testClassLoader = new URLClassLoader(asUrls(application), cachedClassLoader);
} catch (MalformedURLException e) {
throw new RuntimeException(e);
cachedClassLoader = createClassLoader(suite.getClassPath());
}

testClassLoader = cachedClassLoader;
testFileFinder = createTestFileFinder(suite);
driverFinder = DriverFinderFactory.createDriverFinder(testClassLoader, logOutput);
runIdSequence = new RunIdSequence();
Expand Down Expand Up @@ -133,13 +114,6 @@ public void close() {
if (testThreadPool != null) {
testThreadPool.shutdownNow();
}
if (testClassLoader != null) {
try {
testClassLoader.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}

private static URLClassLoader createClassLoader(List<URI> classpath) {
Expand Down

0 comments on commit b9e3015

Please sign in to comment.