Skip to content

Cannot read metadata from jar that is exactly 1 directory from path root #19

@IzzelAliz

Description

@IzzelAliz

Launch with argument like -DlegacyClassPath=/path/to.jar would throw NPE and fail because artifactMaybe would be / so that artifactMaybe.getFileName() return null.

java.lang.NullPointerException: Cannot invoke "java.nio.file.Path.toString()" because the return value of "java.nio.file.Path.getFileName()" is null
	at cpw.mods.securejarhandler@0.9.54/cpw.mods.jarhandling.JarMetadata.fromFileName(JarMetadata.java:60)
	at cpw.mods.securejarhandler@0.9.54/cpw.mods.jarhandling.JarMetadata.from(JarMetadata.java:44)
	at cpw.mods.securejarhandler@0.9.54/cpw.mods.jarhandling.SecureJar.lambda$from$1(SecureJar.java:42)
	at cpw.mods.securejarhandler@0.9.54/cpw.mods.jarhandling.SecureJar$$Lambda$97/0x00000000f4842b00.apply(Unknown Source)
	at cpw.mods.securejarhandler@0.9.54/cpw.mods.jarhandling.impl.Jar.<init>(Jar.java:133)
	at cpw.mods.securejarhandler@0.9.54/cpw.mods.jarhandling.SecureJar.from(SecureJar.java:58)
	at cpw.mods.securejarhandler@0.9.54/cpw.mods.jarhandling.SecureJar.from(SecureJar.java:50)
	at cpw.mods.securejarhandler@0.9.54/cpw.mods.jarhandling.SecureJar.from(SecureJar.java:42)
	at cpw.mods.bootstraplauncher@0.1.17/cpw.mods.bootstraplauncher.BootstrapLauncher.main(BootstrapLauncher.java:60)

static SimpleJarMetadata fromFileName(final Path path, final Set<String> pkgs, final List<SecureJar.Provider> providers) {
// detect Maven-like paths
Path versionMaybe = path.getParent();
if (versionMaybe != null)
{
Path artifactMaybe = versionMaybe.getParent();
if (artifactMaybe != null && path.getFileName().toString().startsWith(artifactMaybe.getFileName().toString() + "-" + versionMaybe.getFileName().toString()))
{
var name = artifactMaybe.getFileName().toString();

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions