Skip to content

Commit

Permalink
AnnotationClassLoader multithread support (#2168)
Browse files Browse the repository at this point in the history
  • Loading branch information
jyluo authored and wmdietl committed Sep 25, 2018
1 parent 2efca73 commit be73e17
Showing 1 changed file with 21 additions and 7 deletions.
Expand Up @@ -473,18 +473,32 @@ private void loadBundledAnnotationClasses() {
// resource URL for the qual directory will have the protocol
// "jar". This means the whole checker is loaded as a jar file.

JarFile jarFile = null;
// open up that jar file and extract annotation class names
JarURLConnection connection;
// create a connection to the jar file
try {
JarURLConnection connection = (JarURLConnection) resourceURL.openConnection();
jarFile = connection.getJarFile();
connection = (JarURLConnection) resourceURL.openConnection();

// disable caching / connection sharing of the low level URLConnection to the Jar
// file
connection.setDefaultUseCaches(false);
connection.setUseCaches(false);

// connect to the Jar file
connection.connect();
} catch (IOException e) {
throw new BugInCF(
"AnnotationClassLoader: cannot open the Jar file " + resourceURL.getFile());
"AnnotationClassLoader: cannot open a connection to the Jar file "
+ resourceURL.getFile());
}

// get class names inside the jar file within the particular package
annotationNames = getBundledAnnotationNamesFromJar(jarFile);
// open up that jar file and extract annotation class names
try (JarFile jarFile = connection.getJarFile()) {
// get class names inside the jar file within the particular package
annotationNames = getBundledAnnotationNamesFromJar(jarFile);
} catch (IOException e) {
throw new BugInCF(
"AnnotationClassLoader: cannot open the Jar file " + resourceURL.getFile());
}

} else if (resourceURL.getProtocol().contentEquals("file")) {
// if the checker class file is found within the file system itself
Expand Down

0 comments on commit be73e17

Please sign in to comment.