ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrea Bernardo Ciddio (JIRA)" <j...@apache.org>
Subject [jira] Created: (IVY-659) NPE in namespace transformation during the ivy:findrevision and ivy:resolve task execution
Date Fri, 07 Dec 2007 01:05:43 GMT
NPE in namespace transformation during the ivy:findrevision and ivy:resolve task execution
------------------------------------------------------------------------------------------

                 Key: IVY-659
                 URL: https://issues.apache.org/jira/browse/IVY-659
             Project: Ivy
          Issue Type: Bug
          Components: Core
    Affects Versions: 2.0.0-alpha-2, 2.0.0-alpha-1, 2.0.0-beta-1, 2.0
            Reporter: Andrea Bernardo Ciddio
            Priority: Critical


While executing this ant code

{code:xml} 
[...]
	<target name="build">
		<ivy:findrevision organisation="apache" module="ant" revision="latest.integration" property="test"/>
		<echo message="Latest revision: ${test}" />
	</target>
[...]
{code}

using this ivy settings file:

{code:xml}
<ivysettings>
	<settings defaultResolver="m2" defaultConflictManager="all" />
	<resolvers>
		<ibiblio name="m2" m2compatible="true"
				namespace="test-ns" root="${public.root}" pattern="${public.pattern}" />
	</resolvers>
	<namespaces>
		<namespace name="test-ns">
				<rule>
					<fromsystem>
						<src org=".*" module="([^-]+)[-]*.*"/>
						<dest org="org.$o0.$m1" module="$m0" />
					</fromsystem>
					<tosystem>
						<src org="org\.([^.]+)\..*" module=".+" />
						<dest org="$o1" module="$m0" />
					</tosystem>
				</rule>
			</namespace>
	</namespaces>
</ivysettings>
{code}

a NullPointerException is raised:
{code}
java.lang.NullPointerException
        at org.apache.ivy.plugins.namespace.MRIDTransformationRule$MridRuleMatcher.match(MRIDTransformationRule.java:38)
        at org.apache.ivy.plugins.namespace.MRIDTransformationRule.transform(MRIDTransformationRule.java:133)
        at org.apache.ivy.plugins.namespace.Namespace$2.transform(Namespace.java:65)
        at org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor.transformInstance(DefaultDependencyDescriptor.java:82)
        at org.apache.ivy.plugins.namespace.NameSpaceHelper.transform(NameSpaceHelper.java:42)
        at org.apache.ivy.plugins.resolver.AbstractResolver.toSystem(AbstractResolver.java:266)
        at org.apache.ivy.plugins.resolver.BasicResolver.parse(BasicResolver.java:426)
        at org.apache.ivy.plugins.resolver.BasicResolver.getDependency(BasicResolver.java:265)
        at org.apache.ivy.plugins.resolver.IBiblioResolver.getDependency(IBiblioResolver.java:206)
        at org.apache.ivy.core.resolve.ResolveEngine.findModule(ResolveEngine.java:945)
        at org.apache.ivy.Ivy.findModule(Ivy.java:642)
        at org.apache.ivy.ant.IvyFindRevision.doExecute(IvyFindRevision.java:98)
        at org.apache.ivy.ant.IvyTask.execute(IvyTask.java:275)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
        at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105)
        at org.apache.tools.ant.Task.perform(Task.java:348)
        at org.apache.tools.ant.Target.execute(Target.java:357)
        at org.apache.tools.ant.Target.performTasks(Target.java:385)
        at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329)
        at org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:38)
        at org.apache.tools.ant.Project.executeTargets(Project.java:1181)
        at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:416)
        at org.apache.tools.ant.taskdefs.CallTarget.execute(CallTarget.java:105)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
        at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105)
        at org.apache.tools.ant.Task.perform(Task.java:348)
        at org.apache.tools.ant.Target.execute(Target.java:357)
        at org.apache.tools.ant.Target.performTasks(Target.java:385)
        at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329)
        at org.apache.tools.ant.Project.executeTarget(Project.java:1298)
        at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
        at org.apache.tools.ant.Project.executeTargets(Project.java:1181)
        at org.apache.tools.ant.Main.runBuild(Main.java:698)
        at org.apache.tools.ant.Main.startAnt(Main.java:199)
        at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
        at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)
{code}

The same thing happens when calling ivy:resolve.
It has something to do with the way the ResolveEngine creates the DependencyDescriptor:

{code}
[...]
try {
   return r.getDependency(new DefaultDependencyDescriptor(id, true), new ResolveData(this,
                    options, new ConfigurationResolveReport(this, md, "default", null, options)));
} catch (ParseException e) {
            throw new RuntimeException("problem while parsing repository module descriptor
for "
                    + id + ": " + e, e);
}
[...]
{code}

that does not set the parent revision id of the descriptor (leaving it null). After some digging
into the code I wrote a simple patch that fixes this issue:

{code}
Index: org/apache/ivy/plugins/namespace/Namespace.java
===================================================================
--- org/apache/ivy/plugins/namespace/Namespace.java     (revision 601926)
+++ org/apache/ivy/plugins/namespace/Namespace.java     (working copy)
@@ -37,6 +37,8 @@
 
     private NamespaceTransformer fromSystemTransformer = new NamespaceTransformer() {
         public ModuleRevisionId transform(ModuleRevisionId mrid) {
+               if (mrid == null)
+                       return null;
             for (Iterator iter = rules.iterator(); iter.hasNext();) {
                 NamespaceRule rule = (NamespaceRule) iter.next();
                 ModuleRevisionId nmrid = rule.getFromSystem().transform(mrid);
@@ -56,6 +58,8 @@
 
     private NamespaceTransformer toSystemTransformer = new NamespaceTransformer() {
         public ModuleRevisionId transform(ModuleRevisionId mrid) {
+               if (mrid == null)
+                       return null;
             for (Iterator iter = rules.iterator(); iter.hasNext();) {
                 NamespaceRule rule = (NamespaceRule) iter.next();
                 ModuleRevisionId nmrid = rule.getToSystem().transform(mrid);

{code}

Hope that's useful.

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


Mime
View raw message