Fix some compile warnings

This commit is contained in:
Phillip Webb
2014-01-26 22:54:04 -08:00
parent 5a47360cb5
commit c1f8fd2bac
5 changed files with 32 additions and 25 deletions

View File

@@ -121,6 +121,8 @@ public class PropertiesLauncher extends Launcher {
private static final Pattern WORD_SEPARATOR = Pattern.compile("\\W+");
private static final URL[] EMPTY_URLS = {};
private final File home;
private List<String> paths = new ArrayList<String>(DEFAULT_PATHS);
@@ -493,28 +495,32 @@ public class PropertiesLauncher extends Launcher {
private void addParentClassLoaderEntries(List<Archive> lib) throws IOException,
URISyntaxException {
ClassLoader parentClassLoader = getClass().getClassLoader();
if (parentClassLoader instanceof URLClassLoader) {
URLClassLoader urlClassLoader = (URLClassLoader) parentClassLoader;
for (URL url : urlClassLoader.getURLs()) {
if (url.toString().endsWith(".jar") || url.toString().endsWith(".zip")) {
lib.add(0, new JarFileArchive(new File(url.toURI())));
}
else if (url.toString().endsWith("/*")) {
String name = url.getFile();
File dir = new File(name.substring(0, name.length() - 1));
if (dir.exists()) {
lib.add(0,
new ExplodedArchive(new File(name.substring(0,
name.length() - 1)), false));
}
}
else {
lib.add(0, new ExplodedArchive(new File(url.getFile())));
for (URL url : getURLs(parentClassLoader)) {
if (url.toString().endsWith(".jar") || url.toString().endsWith(".zip")) {
lib.add(0, new JarFileArchive(new File(url.toURI())));
}
else if (url.toString().endsWith("/*")) {
String name = url.getFile();
File dir = new File(name.substring(0, name.length() - 1));
if (dir.exists()) {
lib.add(0,
new ExplodedArchive(new File(name.substring(0,
name.length() - 1)), false));
}
}
else {
lib.add(0, new ExplodedArchive(new File(url.getFile())));
}
}
}
private URL[] getURLs(ClassLoader classLoader) {
if (classLoader instanceof URLClassLoader) {
return ((URLClassLoader) classLoader).getURLs();
}
return EMPTY_URLS;
}
private String cleanupPath(String path) {
path = path.trim();
if (path.toLowerCase().endsWith(".jar") || path.toLowerCase().endsWith(".zip")) {

View File

@@ -126,6 +126,7 @@ public class ExplodedArchiveTests {
}
@Test
@SuppressWarnings("resource")
public void getFilteredArchive() throws Exception {
Archive filteredArchive = this.archive
.getFilteredArchive(new Archive.EntryRenameFilter() {

View File

@@ -281,6 +281,7 @@ public class RandomAccessJarFileTests {
}
@Test
@SuppressWarnings("resource")
public void verifySignedJar() throws Exception {
String classpath = System.getProperty("java.class.path");
String[] entries = classpath.split(System.getProperty("path.separator"));