You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Michael Osipov (Jira)" <ji...@apache.org> on 2020/04/19 22:44:00 UTC

[jira] [Commented] (MRESOLVER-94) NullPointerException if no Package is defined for the current class

    [ https://issues.apache.org/jira/browse/MRESOLVER-94?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17087237#comment-17087237 ] 

Michael Osipov commented on MRESOLVER-94:
-----------------------------------------

So this requires changes in Maven Core. There are four spots using {{#getPackage()}}.

> NullPointerException if no Package is defined for the current class
> -------------------------------------------------------------------
>
>                 Key: MRESOLVER-94
>                 URL: https://issues.apache.org/jira/browse/MRESOLVER-94
>             Project: Maven Resolver
>          Issue Type: Bug
>          Components: resolver
>    Affects Versions: 1.4.1
>         Environment: Windows 10, Java 8, custom classloading
>            Reporter: Bence Sipka
>            Priority: Minor
>
> When the maven-resolver and related classes are used with a {{ClassLoader}} that doesn't define a java.lang.Package object for the loaded classes, the library throws a {{NullPointerException}}.
> Scenario: I'm using the maven-resolver classes to resolver artifacts from various repositories. I package the app, and deploy it to a custom environment where the {{ClassLoader}} for the app doesn't define a {{Package}} for the loaded classes. In these cases, when the maven-resolver library calls {{this.getClass().getPackage().getImplementationVersion()}} then a {{NullPointerException}} will occurr.
>  The following classes are affected:
>  {{DefaultSuperPomProvider.getSuperModel():81}}
>  {{DefaultReportingConverter.<init>:56}}
> Code around the locations:
> {code:java}
> String modelId = "org.apache.maven:maven-model-builder:"
>     + this.getClass().getPackage().getImplementationVersion() + ":super-pom";
> InputSource inputSource = new InputSource();
> inputSource.setModelId( modelId );
> {code}
> This exception makes the library unportable to different environments.
> Workaround:
> Implement a custom variant of the above classes that circumvent these parts of the code.
> Possible solution:
> Null checks, and hard coding the version number.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)