You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by "Erik-Berndt Scheper (JIRA)" <ji...@apache.org> on 2008/06/10 12:24:44 UTC

[jira] Created: (IVY-831) NPE in AbstractResolver.exists() if a resource cannot be found

NPE in AbstractResolver.exists() if a resource cannot be found
--------------------------------------------------------------

                 Key: IVY-831
                 URL: https://issues.apache.org/jira/browse/IVY-831
             Project: Ivy
          Issue Type: Bug
          Components: Core
    Affects Versions: 2.0-RC1
            Reporter: Erik-Berndt Scheper
             Fix For: 2.0-RC1


A NullPointerException occurs inAbstractResolver.exists(AbstractResolver.java:196) if a host cannot be found

Reproducible with "ant coverage-report" behind a firewall with proxy install disabled.
Resulting stack trace:

{noformat}
java.lang.NullPointerException
at org.apache.ivy.plugins.resolver.AbstractResolver.exists(AbstractResolver.java:196)
at org.apache.ivy.plugins.parser.m2.PomModuleDescriptorParser.addSourcesAndJavadocArtifactsIfPresent(PomModuleDescriptorParser.java:267)
at org.apache.ivy.plugins.parser.m2.PomModuleDescriptorParser.parseDescriptor(PomModuleDescriptorParser.java:246)
at org.apache.ivy.plugins.parser.m2.PomModuleDescriptorParser.parseDescriptor(PomModuleDescriptorParser.java:104)
at org.apache.ivy.plugins.parser.m2.PomModuleDescriptorParserTest.testSimple(PomModuleDescriptorParserTest.java:89)
{noformat}

Offending code:
{noformat}
    /**
     * Default implementation actually download the artifact Subclasses should overwrite this to
     * avoid the download
     */
    public boolean exists(Artifact artifact) {
        DownloadReport dr = download(new Artifact[] {artifact}, new DownloadOptions());
        ArtifactDownloadReport adr = dr.getArtifactReport(artifact);
        return adr.getDownloadStatus() != DownloadStatus.FAILED;
    }
{noformat}

If the DownloadReport instance is null, a NPE occurs


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (IVY-831) NPE in AbstractResolver.exists() if a resource cannot be found

Posted by "Xavier Hanin (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/IVY-831?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12603832#action_12603832 ] 

Xavier Hanin commented on IVY-831:
----------------------------------

I've just checked in what should fix the NPE. But I've checked the code, and I haven't found any implementation of download which can return null. Therefore I've added javadoc to the download method to clarify its contract specifying it must never return null. Hence the prevention against the NPE in AbstractResolver shouldn't be required, but I let it in case a bad implementation of DependencyResolver (according to the contract I've just defined) is used.

Could you confirm you don't have the NPE anymore, and tell me if you get an IllegalStateException, and if such, with which resolver implementation?

> NPE in AbstractResolver.exists() if a resource cannot be found
> --------------------------------------------------------------
>
>                 Key: IVY-831
>                 URL: https://issues.apache.org/jira/browse/IVY-831
>             Project: Ivy
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 2.0-RC1
>            Reporter: Erik-Berndt Scheper
>            Assignee: Xavier Hanin
>             Fix For: 2.0-RC1
>
>
> A NullPointerException occurs inAbstractResolver.exists(AbstractResolver.java:196) if a host cannot be found
> Reproducible with "ant coverage-report" behind a firewall with proxy install disabled.
> Resulting stack trace:
> {noformat}
> java.lang.NullPointerException
> at org.apache.ivy.plugins.resolver.AbstractResolver.exists(AbstractResolver.java:196)
> at org.apache.ivy.plugins.parser.m2.PomModuleDescriptorParser.addSourcesAndJavadocArtifactsIfPresent(PomModuleDescriptorParser.java:267)
> at org.apache.ivy.plugins.parser.m2.PomModuleDescriptorParser.parseDescriptor(PomModuleDescriptorParser.java:246)
> at org.apache.ivy.plugins.parser.m2.PomModuleDescriptorParser.parseDescriptor(PomModuleDescriptorParser.java:104)
> at org.apache.ivy.plugins.parser.m2.PomModuleDescriptorParserTest.testSimple(PomModuleDescriptorParserTest.java:89)
> {noformat}
> Offending code:
> {noformat}
>     /**
>      * Default implementation actually download the artifact Subclasses should overwrite this to
>      * avoid the download
>      */
>     public boolean exists(Artifact artifact) {
>         DownloadReport dr = download(new Artifact[] {artifact}, new DownloadOptions());
>         ArtifactDownloadReport adr = dr.getArtifactReport(artifact);
>         return adr.getDownloadStatus() != DownloadStatus.FAILED;
>     }
> {noformat}
> If the DownloadReport instance is null, a NPE occurs

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (IVY-831) NPE in AbstractResolver.exists() if a resource cannot be found

Posted by "Xavier Hanin (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/IVY-831?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Xavier Hanin resolved IVY-831.
------------------------------

    Resolution: Fixed

Indeed, I didn't check test code... Now the MockResolver fulfills the contract, and the Exception is clearer (quoting the resolver class name). Hence I mark this issue as resolved, feel free to reopen if you still have similar problems

> NPE in AbstractResolver.exists() if a resource cannot be found
> --------------------------------------------------------------
>
>                 Key: IVY-831
>                 URL: https://issues.apache.org/jira/browse/IVY-831
>             Project: Ivy
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 2.0-RC1
>            Reporter: Erik-Berndt Scheper
>            Assignee: Xavier Hanin
>             Fix For: 2.0-RC1
>
>
> A NullPointerException occurs inAbstractResolver.exists(AbstractResolver.java:196) if a host cannot be found
> Reproducible with "ant coverage-report" behind a firewall with proxy install disabled.
> Resulting stack trace:
> {noformat}
> java.lang.NullPointerException
> at org.apache.ivy.plugins.resolver.AbstractResolver.exists(AbstractResolver.java:196)
> at org.apache.ivy.plugins.parser.m2.PomModuleDescriptorParser.addSourcesAndJavadocArtifactsIfPresent(PomModuleDescriptorParser.java:267)
> at org.apache.ivy.plugins.parser.m2.PomModuleDescriptorParser.parseDescriptor(PomModuleDescriptorParser.java:246)
> at org.apache.ivy.plugins.parser.m2.PomModuleDescriptorParser.parseDescriptor(PomModuleDescriptorParser.java:104)
> at org.apache.ivy.plugins.parser.m2.PomModuleDescriptorParserTest.testSimple(PomModuleDescriptorParserTest.java:89)
> {noformat}
> Offending code:
> {noformat}
>     /**
>      * Default implementation actually download the artifact Subclasses should overwrite this to
>      * avoid the download
>      */
>     public boolean exists(Artifact artifact) {
>         DownloadReport dr = download(new Artifact[] {artifact}, new DownloadOptions());
>         ArtifactDownloadReport adr = dr.getArtifactReport(artifact);
>         return adr.getDownloadStatus() != DownloadStatus.FAILED;
>     }
> {noformat}
> If the DownloadReport instance is null, a NPE occurs

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (IVY-831) NPE in AbstractResolver.exists() if a resource cannot be found

Posted by "Erik-Berndt Scheper (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/IVY-831?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12603867#action_12603867 ] 

Erik-Berndt Scheper commented on IVY-831:
-----------------------------------------

Positive. 

If I run "ant coverage-report" when building ivy, I get 26 errors in org.apache.ivy.plugins.parser.m2.PomModuleDescriptorParserTest (all except testAccept), with the following output:

{noformat}
null download report returned by null when trying to download org.apache#test;1.0!test.jar(source)

java.lang.IllegalStateException: null download report returned by null when trying to download org.apache#test;1.0!test.jar(source)
at org.apache.ivy.plugins.resolver.AbstractResolver.exists(AbstractResolver.java:201)
at org.apache.ivy.plugins.parser.m2.PomModuleDescriptorParser.addSourcesAndJavadocArtifactsIfPresent(PomModuleDescriptorParser.java:267)
at org.apache.ivy.plugins.parser.m2.PomModuleDescriptorParser.parseDescriptor(PomModuleDescriptorParser.java:246)
at org.apache.ivy.plugins.parser.m2.PomModuleDescriptorParser.parseDescriptor(PomModuleDescriptorParser.java:104)
at org.apache.ivy.plugins.parser.m2.PomModuleDescriptorParserTest.testSimple(PomModuleDescriptorParserTest.java:89)
{noformat}


Maybe the root cause is in this unit test. It uses the following resolver:
{code:title=PomModuleDescriptorParserTest.java|borderStyle=solid}
    private IvySettings settings = new IvySettings();
    
    private class MockedDependencyResolver extends MockResolver {        
        public ResolvedModuleRevision getDependency(DependencyDescriptor dd, ResolveData data) 
                throws ParseException {
            //TODO make it a real mock and check that dd and data are the one that are expected
            DefaultModuleDescriptor moduleDesc = DefaultModuleDescriptor.newDefaultInstance(
                                                                    dd.getDependencyRevisionId());
            ResolvedModuleRevision r = new ResolvedModuleRevision(this,this,moduleDesc,null);
            return r;
        }
    }
{code}

> NPE in AbstractResolver.exists() if a resource cannot be found
> --------------------------------------------------------------
>
>                 Key: IVY-831
>                 URL: https://issues.apache.org/jira/browse/IVY-831
>             Project: Ivy
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 2.0-RC1
>            Reporter: Erik-Berndt Scheper
>            Assignee: Xavier Hanin
>             Fix For: 2.0-RC1
>
>
> A NullPointerException occurs inAbstractResolver.exists(AbstractResolver.java:196) if a host cannot be found
> Reproducible with "ant coverage-report" behind a firewall with proxy install disabled.
> Resulting stack trace:
> {noformat}
> java.lang.NullPointerException
> at org.apache.ivy.plugins.resolver.AbstractResolver.exists(AbstractResolver.java:196)
> at org.apache.ivy.plugins.parser.m2.PomModuleDescriptorParser.addSourcesAndJavadocArtifactsIfPresent(PomModuleDescriptorParser.java:267)
> at org.apache.ivy.plugins.parser.m2.PomModuleDescriptorParser.parseDescriptor(PomModuleDescriptorParser.java:246)
> at org.apache.ivy.plugins.parser.m2.PomModuleDescriptorParser.parseDescriptor(PomModuleDescriptorParser.java:104)
> at org.apache.ivy.plugins.parser.m2.PomModuleDescriptorParserTest.testSimple(PomModuleDescriptorParserTest.java:89)
> {noformat}
> Offending code:
> {noformat}
>     /**
>      * Default implementation actually download the artifact Subclasses should overwrite this to
>      * avoid the download
>      */
>     public boolean exists(Artifact artifact) {
>         DownloadReport dr = download(new Artifact[] {artifact}, new DownloadOptions());
>         ArtifactDownloadReport adr = dr.getArtifactReport(artifact);
>         return adr.getDownloadStatus() != DownloadStatus.FAILED;
>     }
> {noformat}
> If the DownloadReport instance is null, a NPE occurs

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Issue Comment Edited: (IVY-831) NPE in AbstractResolver.exists() if a resource cannot be found

Posted by "Erik-Berndt Scheper (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/IVY-831?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12604429#action_12604429 ] 

fbascheper edited comment on IVY-831 at 6/12/08 12:17 AM:
-------------------------------------------------------------------

Notwithstanding my previous comment: this issue is fully resolved; created IVY-837 for the new issue.

      was (Author: fbascheper):
    Notwithstanding my previous comment: this issue is fully resolved..
  
> NPE in AbstractResolver.exists() if a resource cannot be found
> --------------------------------------------------------------
>
>                 Key: IVY-831
>                 URL: https://issues.apache.org/jira/browse/IVY-831
>             Project: Ivy
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 2.0-RC1
>            Reporter: Erik-Berndt Scheper
>            Assignee: Xavier Hanin
>             Fix For: 2.0-RC1
>
>
> A NullPointerException occurs inAbstractResolver.exists(AbstractResolver.java:196) if a host cannot be found
> Reproducible with "ant coverage-report" behind a firewall with proxy install disabled.
> Resulting stack trace:
> {noformat}
> java.lang.NullPointerException
> at org.apache.ivy.plugins.resolver.AbstractResolver.exists(AbstractResolver.java:196)
> at org.apache.ivy.plugins.parser.m2.PomModuleDescriptorParser.addSourcesAndJavadocArtifactsIfPresent(PomModuleDescriptorParser.java:267)
> at org.apache.ivy.plugins.parser.m2.PomModuleDescriptorParser.parseDescriptor(PomModuleDescriptorParser.java:246)
> at org.apache.ivy.plugins.parser.m2.PomModuleDescriptorParser.parseDescriptor(PomModuleDescriptorParser.java:104)
> at org.apache.ivy.plugins.parser.m2.PomModuleDescriptorParserTest.testSimple(PomModuleDescriptorParserTest.java:89)
> {noformat}
> Offending code:
> {noformat}
>     /**
>      * Default implementation actually download the artifact Subclasses should overwrite this to
>      * avoid the download
>      */
>     public boolean exists(Artifact artifact) {
>         DownloadReport dr = download(new Artifact[] {artifact}, new DownloadOptions());
>         ArtifactDownloadReport adr = dr.getArtifactReport(artifact);
>         return adr.getDownloadStatus() != DownloadStatus.FAILED;
>     }
> {noformat}
> If the DownloadReport instance is null, a NPE occurs

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (IVY-831) NPE in AbstractResolver.exists() if a resource cannot be found

Posted by "Erik-Berndt Scheper (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/IVY-831?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12604429#action_12604429 ] 

Erik-Berndt Scheper commented on IVY-831:
-----------------------------------------

Notwithstanding my previous comment: this issue is fully resolved..

> NPE in AbstractResolver.exists() if a resource cannot be found
> --------------------------------------------------------------
>
>                 Key: IVY-831
>                 URL: https://issues.apache.org/jira/browse/IVY-831
>             Project: Ivy
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 2.0-RC1
>            Reporter: Erik-Berndt Scheper
>            Assignee: Xavier Hanin
>             Fix For: 2.0-RC1
>
>
> A NullPointerException occurs inAbstractResolver.exists(AbstractResolver.java:196) if a host cannot be found
> Reproducible with "ant coverage-report" behind a firewall with proxy install disabled.
> Resulting stack trace:
> {noformat}
> java.lang.NullPointerException
> at org.apache.ivy.plugins.resolver.AbstractResolver.exists(AbstractResolver.java:196)
> at org.apache.ivy.plugins.parser.m2.PomModuleDescriptorParser.addSourcesAndJavadocArtifactsIfPresent(PomModuleDescriptorParser.java:267)
> at org.apache.ivy.plugins.parser.m2.PomModuleDescriptorParser.parseDescriptor(PomModuleDescriptorParser.java:246)
> at org.apache.ivy.plugins.parser.m2.PomModuleDescriptorParser.parseDescriptor(PomModuleDescriptorParser.java:104)
> at org.apache.ivy.plugins.parser.m2.PomModuleDescriptorParserTest.testSimple(PomModuleDescriptorParserTest.java:89)
> {noformat}
> Offending code:
> {noformat}
>     /**
>      * Default implementation actually download the artifact Subclasses should overwrite this to
>      * avoid the download
>      */
>     public boolean exists(Artifact artifact) {
>         DownloadReport dr = download(new Artifact[] {artifact}, new DownloadOptions());
>         ArtifactDownloadReport adr = dr.getArtifactReport(artifact);
>         return adr.getDownloadStatus() != DownloadStatus.FAILED;
>     }
> {noformat}
> If the DownloadReport instance is null, a NPE occurs

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (IVY-831) NPE in AbstractResolver.exists() if a resource cannot be found

Posted by "Erik-Berndt Scheper (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/IVY-831?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12604427#action_12604427 ] 

Erik-Berndt Scheper commented on IVY-831:
-----------------------------------------

This works fine now: the NPE's and IllegalStateExceptions have disappeared. 

Unfortunately, I still get an (unrelated) test failure when running "ant coverage-report" to build ivy from trunk:
{noformat}
[xml parsing: test-write.xml:23:86: cvc-complex-type.3.2.2: Attribute 'classifier' is not allowed to appear in element 'artifact'. in file:/D:/java-apps/ivy/build/test/test-write.xml , xml parsing: test-write.xml:24:87: cvc-complex-type.3.2.2: Attribute 'classifier' is not allowed to appear in element 'artifact'. in file:/D:/java-apps/ivy/build/test/test-write.xml ]
{noformat}

This is caused by the same bug that causes IVY-833: the ivy.xsd has not been updated to include the new "classifier" attrtibute of an artifact.

> NPE in AbstractResolver.exists() if a resource cannot be found
> --------------------------------------------------------------
>
>                 Key: IVY-831
>                 URL: https://issues.apache.org/jira/browse/IVY-831
>             Project: Ivy
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 2.0-RC1
>            Reporter: Erik-Berndt Scheper
>            Assignee: Xavier Hanin
>             Fix For: 2.0-RC1
>
>
> A NullPointerException occurs inAbstractResolver.exists(AbstractResolver.java:196) if a host cannot be found
> Reproducible with "ant coverage-report" behind a firewall with proxy install disabled.
> Resulting stack trace:
> {noformat}
> java.lang.NullPointerException
> at org.apache.ivy.plugins.resolver.AbstractResolver.exists(AbstractResolver.java:196)
> at org.apache.ivy.plugins.parser.m2.PomModuleDescriptorParser.addSourcesAndJavadocArtifactsIfPresent(PomModuleDescriptorParser.java:267)
> at org.apache.ivy.plugins.parser.m2.PomModuleDescriptorParser.parseDescriptor(PomModuleDescriptorParser.java:246)
> at org.apache.ivy.plugins.parser.m2.PomModuleDescriptorParser.parseDescriptor(PomModuleDescriptorParser.java:104)
> at org.apache.ivy.plugins.parser.m2.PomModuleDescriptorParserTest.testSimple(PomModuleDescriptorParserTest.java:89)
> {noformat}
> Offending code:
> {noformat}
>     /**
>      * Default implementation actually download the artifact Subclasses should overwrite this to
>      * avoid the download
>      */
>     public boolean exists(Artifact artifact) {
>         DownloadReport dr = download(new Artifact[] {artifact}, new DownloadOptions());
>         ArtifactDownloadReport adr = dr.getArtifactReport(artifact);
>         return adr.getDownloadStatus() != DownloadStatus.FAILED;
>     }
> {noformat}
> If the DownloadReport instance is null, a NPE occurs

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Assigned: (IVY-831) NPE in AbstractResolver.exists() if a resource cannot be found

Posted by "Xavier Hanin (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/IVY-831?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Xavier Hanin reassigned IVY-831:
--------------------------------

    Assignee: Xavier Hanin

> NPE in AbstractResolver.exists() if a resource cannot be found
> --------------------------------------------------------------
>
>                 Key: IVY-831
>                 URL: https://issues.apache.org/jira/browse/IVY-831
>             Project: Ivy
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 2.0-RC1
>            Reporter: Erik-Berndt Scheper
>            Assignee: Xavier Hanin
>             Fix For: 2.0-RC1
>
>
> A NullPointerException occurs inAbstractResolver.exists(AbstractResolver.java:196) if a host cannot be found
> Reproducible with "ant coverage-report" behind a firewall with proxy install disabled.
> Resulting stack trace:
> {noformat}
> java.lang.NullPointerException
> at org.apache.ivy.plugins.resolver.AbstractResolver.exists(AbstractResolver.java:196)
> at org.apache.ivy.plugins.parser.m2.PomModuleDescriptorParser.addSourcesAndJavadocArtifactsIfPresent(PomModuleDescriptorParser.java:267)
> at org.apache.ivy.plugins.parser.m2.PomModuleDescriptorParser.parseDescriptor(PomModuleDescriptorParser.java:246)
> at org.apache.ivy.plugins.parser.m2.PomModuleDescriptorParser.parseDescriptor(PomModuleDescriptorParser.java:104)
> at org.apache.ivy.plugins.parser.m2.PomModuleDescriptorParserTest.testSimple(PomModuleDescriptorParserTest.java:89)
> {noformat}
> Offending code:
> {noformat}
>     /**
>      * Default implementation actually download the artifact Subclasses should overwrite this to
>      * avoid the download
>      */
>     public boolean exists(Artifact artifact) {
>         DownloadReport dr = download(new Artifact[] {artifact}, new DownloadOptions());
>         ArtifactDownloadReport adr = dr.getArtifactReport(artifact);
>         return adr.getDownloadStatus() != DownloadStatus.FAILED;
>     }
> {noformat}
> If the DownloadReport instance is null, a NPE occurs

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.