Skip to content

Commit

Permalink
Ensure jar URL path is properly decoded into a file system path.
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbywalters authored and asimarslan committed Jun 12, 2013
1 parent ec280ab commit 75c876e
Showing 1 changed file with 9 additions and 3 deletions.
Expand Up @@ -19,6 +19,7 @@
package org.batoo.jpa.parser.impl.acl;

import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.Enumeration;
import java.util.Set;
Expand Down Expand Up @@ -65,8 +66,8 @@ private JarAnnotatedClassLocator() {
super();
}

private Set<Class<?>> findClasses(PersistenceUnitInfo persistenceUnitInfo, URL url, final Set<Class<?>> classes) throws IOException {
final JarFile jarFile = new JarFile(url.getFile());
private Set<Class<?>> findClasses(PersistenceUnitInfo persistenceUnitInfo, URL url, final Set<Class<?>> classes) throws IOException, URISyntaxException {
final JarFile jarFile = new JarFile(url.toURI().getPath());

final Enumeration<JarEntry> entries = jarFile.entries();
while (entries.hasMoreElements()) {
Expand All @@ -90,6 +91,8 @@ private Set<Class<?>> findClasses(PersistenceUnitInfo persistenceUnitInfo, URL u

jarFile.close();

jarFile.close();

return classes;
}

Expand All @@ -106,8 +109,11 @@ public Set<Class<?>> locateClasses(PersistenceUnitInfo persistenceUnitInfo, URL

return this.findClasses(persistenceUnitInfo, url, classes);
}
catch (final URISyntaxException e) {
throw new PersistenceException("Unable to read JAR url: " + url, e);
}
catch (final IOException e) {
throw new PersistenceException("Unable to read JAR url: " + url);
throw new PersistenceException("Unable to read JAR url: " + url, e);
}
finally {
JarAnnotatedClassLocator.LOG.info("Found persistent classes {0}", classes.toString());
Expand Down

0 comments on commit 75c876e

Please sign in to comment.