Skip to content

Commit

Permalink
Avoid crashing due to FileSystemNotFound while behind a Spring boot e…
Browse files Browse the repository at this point in the history
…mbedded JAR
  • Loading branch information
ctabin committed Oct 13, 2023
1 parent 6cf5bfe commit ea87e73
Showing 1 changed file with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@
import com.sun.enterprise.deployment.deploy.shared.Util;
import com.sun.enterprise.util.OS;
import java.io.File;
import java.io.FileFilter;
import java.io.IOException;
import java.io.InputStream;
import java.io.FileInputStream;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.file.FileSystemNotFoundException;
import java.nio.file.Paths;
import java.util.logging.Level;
import java.util.logging.Logger;
Expand Down Expand Up @@ -272,8 +272,18 @@ private static synchronized String getModulesClasspath(ServiceLocator habitat) {
tmpString.append("file:").append(uri.toString().substring("jardir:".length()));
tmpString.append(File.pathSeparator);
} else {
tmpString.append(Paths.get(uri).toString());
tmpString.append(File.pathSeparator);
try {
// While using payara-embedded-all behind Spring boot, the other dependencies are
// embedded in a JAR-in-JAR and hence start with "jar:" which results in a FileSystemNotFoundException.
// Since those URLs cannot be used in the classpath, they are simply ignored.
tmpString.append(Paths.get(uri).toString());
tmpString.append(File.pathSeparator);
} catch(FileSystemNotFoundException fsNotFound) {
LogRecord logRecord = new LogRecord(Level.WARNING, "URI has been excluded from classpath: {0}");
logRecord.setParameters(new Object[]{uri});
logRecord.setThrown(fsNotFound);
deplLogger.log(logRecord);
}
}
}
}
Expand Down

0 comments on commit ea87e73

Please sign in to comment.