Skip to content

fix: throw NullPointerException when getManifest is called without Session and classpath is enabled - #378

Open
elharo wants to merge 1 commit into
apache:masterfrom
elharo:fix-364-npe-getmanifest
Open

fix: throw NullPointerException when getManifest is called without Session and classpath is enabled#378
elharo wants to merge 1 commit into
apache:masterfrom
elharo:fix-364-npe-getmanifest

Conversation

@elharo

@elharo elharo commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Fixes #364.

The two-parameter getManifest(Project, ManifestConfiguration) passes null for Session. When addClasspath or addExtensions is enabled, doGetManifest dereferences the null session, causing a NullPointerException.

Add a null check that throws an informative NullPointerException telling callers to use the three-parameter overload with a non-null Session.


DependencyResolverResult result;
if (config.isAddClasspath() || config.isAddExtensions()) {
if (session == null) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a NullPointerException

@elharo elharo changed the title Throw IllegalArgumentException when getManifest is called without Session and classpath is enabled Throw NullPointerException when getManifest is called without Session and classpath is enabled Jul 4, 2026
@elharo
elharo force-pushed the fix-364-npe-getmanifest branch from 333d1fe to 18df55e Compare July 4, 2026 12:53
@elharo elharo changed the title Throw NullPointerException when getManifest is called without Session and classpath is enabled fix: prevent NPE in ManifestConfiguration.getClasspathPrefix() when prefix is null Jul 4, 2026
@elharo
elharo force-pushed the fix-364-npe-getmanifest branch 2 times, most recently from 8339516 to dcee117 Compare July 4, 2026 12:57
@elharo elharo changed the title fix: prevent NPE in ManifestConfiguration.getClasspathPrefix() when prefix is null fix: throw NullPointerException when getManifest is called without Session and classpath is enabled Jul 4, 2026
@elharo
elharo force-pushed the fix-364-npe-getmanifest branch from dcee117 to 85bbed1 Compare July 4, 2026 13:06
…ssion and classpath is enabled

The two-parameter getManifest(Project, ManifestConfiguration) passes null
for Session. When addClasspath is enabled, doGetManifest dereferences the
null session, causing a NullPointerException.

Add a null check that throws an informative NullPointerException telling
callers to use the three-parameter overload with a non-null Session.

Fixes apache#364
@elharo
elharo force-pushed the fix-364-npe-getmanifest branch from 85bbed1 to f6a3f34 Compare July 4, 2026 13:14
@elharo
elharo requested a review from gnodet July 4, 2026 13:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NPE in getManifest(Project, ManifestConfiguration) when addClasspath is enabled

1 participant