Skip to content

Starter jars not excluded from repackaged jars using spring-boot-maven-plugin. #24594

@edwardsre

Description

@edwardsre

JarTypeFilter is not handling dependency jars with missing manifest files. This results in all starter jars being included in the repackaged jar.

A NullPointerException is thrown from JarTypeFilter.filter on this line:

    String jarType = jarFile.getManifest().getMainAttributes().getValue("Spring-Boot-Jar-Type");

When this occurs, the NPE is caught in FilterArtifacts.filter which skips the results of the executing filter, resulting in the starter jars being retained in the repackaged jar file.

If the manifest file is missing, the jar should still be included by this filter (returning false). Either of these fix the issue...

	return Optional.ofNullable(jarFile.getManifest())
			.map(Manifest::getMainAttributes)
			.map(attributes -> attributes.getValue("Spring-Boot-Jar-Type"))
			.map(EXCLUDED_JAR_TYPES::contains)
			.orElse(Boolean.FALSE);

or

	final Manifest manifest = jarFile.getManifest();
	if (manifest != null) {
		String jarType = manifest.getMainAttributes().getValue("Spring-Boot-Jar-Type");
		return jarType != null && EXCLUDED_JAR_TYPES.contains(jarType);
	}
	return false;

This jar was the culprit in our project. net.sourceforge.streamsupport:streamsupport:1.2.1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: supersededAn issue that has been superseded by anothertype: bugA general bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions