mirror of
https://github.com/ysoftdevs/DependencyCheck.git
synced 2026-01-17 09:06:55 +01:00
Patch for bootclasspath loading
This commit is contained in:
@@ -24,6 +24,7 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.UUID;
|
||||
import org.apache.commons.lang3.SystemUtils;
|
||||
|
||||
@@ -148,4 +149,13 @@ public final class FileUtils {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the {@link InputStream} for this resource
|
||||
* @param resource path
|
||||
* @return
|
||||
*/
|
||||
public static InputStream getResourceAsStream(String resource) {
|
||||
return FileUtils.class.getClassLoader()!=null?FileUtils.class.getClassLoader().getResourceAsStream(resource):ClassLoader.getSystemResourceAsStream(resource);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
import java.security.ProtectionDomain;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Properties;
|
||||
|
||||
@@ -440,7 +441,7 @@ public final class Settings {
|
||||
*/
|
||||
private Settings(String propertiesFilePath) {
|
||||
props = new Properties();
|
||||
try (InputStream in = this.getClass().getClassLoader().getResourceAsStream(propertiesFilePath)) {
|
||||
try (InputStream in = FileUtils.getResourceAsStream(propertiesFilePath)) {
|
||||
props.load(in);
|
||||
} catch (NullPointerException ex) {
|
||||
LOGGER.error("Did not find settings file '{}'.", propertiesFilePath);
|
||||
@@ -733,8 +734,12 @@ public final class Settings {
|
||||
* @return a File object
|
||||
*/
|
||||
private static File getJarPath() {
|
||||
final String jarPath = Settings.class.getProtectionDomain().getCodeSource().getLocation().getPath();
|
||||
String decodedPath = ".";
|
||||
String jarPath = "";
|
||||
ProtectionDomain domain = Settings.class.getProtectionDomain();
|
||||
if(domain!=null&& domain.getCodeSource()!=null && domain.getCodeSource().getLocation()!=null) {
|
||||
jarPath = Settings.class.getProtectionDomain().getCodeSource().getLocation().getPath();
|
||||
}
|
||||
try {
|
||||
decodedPath = URLDecoder.decode(jarPath, "UTF-8");
|
||||
} catch (UnsupportedEncodingException ex) {
|
||||
|
||||
Reference in New Issue
Block a user