You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "elharo (via GitHub)" <gi...@apache.org> on 2026/08/02 11:18:19 UTC

[I] configureLocator() runs outside the guarded try and can throw raw NPE [maven-remote-resources-plugin]

elharo opened a new issue, #275:
URL: https://github.com/apache/maven-remote-resources-plugin/issues/275

   ## Summary
   `execute()` calls `configureLocator()` before the `try` block that contains the validation and resource processing, so any runtime exception it throws is not wrapped and escapes untyped.
   
   `src/main/java/org/apache/maven/plugin/resources/remote/AbstractProcessRemoteResourcesMojo.java:429-433`
   
   ```java
   configureLocator();
   ClassLoader origLoader = Thread.currentThread().getContextClassLoader();
   try {
       validate();
       ...
   ```
   
   `configureLocator()` at `:482-507` dereferences `project.getFile().getParentFile()`:
   
   ```java
   locator.addSearchPath(FileResourceLoader.ID, project.getFile().getParentFile().getAbsolutePath());
   ```
   
   If the current project has no associated POM file (`project.getFile()` null — possible for models built without a file, super POMs, or stubs), this throws a raw `NullPointerException` instead of a `MojoExecutionException`. The rest of `execute()` deliberately wraps work in the `try`/`finally` (which also restores the thread context classloader) precisely to contain such failures.
   
   ## Suggested fix
   Move `configureLocator()` inside the guarded `try`, and/or null-guard `project.getFile()` in `configureLocator()` with a clear error message.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] configureLocator() runs outside the guarded try and can throw raw NPE [maven-remote-resources-plugin]

Posted by "AzazelSensei (via GitHub)" <gi...@apache.org>.
AzazelSensei commented on issue #275:
URL: https://github.com/apache/maven-remote-resources-plugin/issues/275#issuecomment-5392891051

   Opened https://github.com/apache/maven-remote-resources-plugin/pull/299 — configureLocator now runs inside the execute try/finally and fails with MojoExecutionException when the project has no POM file.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] configureLocator() runs outside the guarded try and can throw raw NPE [maven-remote-resources-plugin]

Posted by "slachiewicz (via GitHub)" <gi...@apache.org>.
slachiewicz closed issue #275: configureLocator() runs outside the guarded try and can throw raw NPE
URL: https://github.com/apache/maven-remote-resources-plugin/issues/275


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org