Author: xavier
Date: Thu Mar 8 03:14:01 2007
New Revision: 516010
URL: http://svn.apache.org/viewvc?view=rev&rev=516010
Log:
FIX: NPE when no organisation or no name is provided in module element of
ivyconf (IVY-422)
Added:
incubator/ivy/core/trunk/test/java/org/apache/ivy/core/settings/ivyconf-no-name-in-module.xml
incubator/ivy/core/trunk/test/java/org/apache/ivy/core/settings/ivyconf-no-org-in-module.xml
Modified:
incubator/ivy/core/trunk/CHANGES.txt
incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ModuleId.java
incubator/ivy/core/trunk/src/java/org/apache/ivy/core/settings/XmlSettingsParser.java
incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/matcher/ModuleIdMatcher.java
incubator/ivy/core/trunk/test/java/org/apache/ivy/core/settings/XmlSettingsParserTest.java
Modified: incubator/ivy/core/trunk/CHANGES.txt
URL:
http://svn.apache.org/viewvc/incubator/ivy/core/trunk/CHANGES.txt?view=diff&rev=516010&r1=516009&r2=516010
==============================================================================
--- incubator/ivy/core/trunk/CHANGES.txt (original)
+++ incubator/ivy/core/trunk/CHANGES.txt Thu Mar 8 03:14:01 2007
@@ -16,7 +16,8 @@
- IMPROVE: Add a unit test to verify that latest.integration accepts released
modules (IVY-394) (thanks to Gilles Scokart)
- IMPROVE: New "modules in use" section in console report at the end of
resolve (IVY-373) (thanks to John Wiliams)
-- FIX: FileUtil#copy(File src, File dest, CopyProgressListener l, boolean
overwrite) (IVY-420)
+- FIX: NPE when no organisation or no name is provided in module element of
ivyconf (IVY-422)
+- FIX: FileUtil#copy(File src, File dest, CopyProgressListener l, boolean
overwrite) (IVY-420)
- FIX: Ivy doesn't recognize maven2 classifiers (IVY-418)
- FIX: Static revision replacement is not working when delivering an artifact
with a dependency having extra attributes (IVY-415)
- FIX: Static revision replacement is not working when delivering an artifact
with a dependency on a branch (IVY-404)
Modified:
incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ModuleId.java
URL:
http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ModuleId.java?view=diff&rev=516010&r1=516009&r2=516010
==============================================================================
---
incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ModuleId.java
(original)
+++
incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ModuleId.java
Thu Mar 8 03:14:01 2007
@@ -49,14 +49,18 @@
return false;
}
ModuleId other = (ModuleId)obj;
- return other._organisation.equals(_organisation) &&
other._name.equals(_name);
+ if (other._organisation == null) {
+ return _organisation == null && other._name.equals(_name);
+ } else {
+ return other._organisation.equals(_organisation) &&
other._name.equals(_name);
+ }
}
public int hashCode() {
return _hash;
}
public int _hashCode() {
int hash = 31;
- hash = hash * 13 + _organisation.hashCode();
+ hash = hash * 13 + (_organisation == null ? 0 :
_organisation.hashCode());
hash = hash * 13 + _name.hashCode();
return hash;
}
Modified:
incubator/ivy/core/trunk/src/java/org/apache/ivy/core/settings/XmlSettingsParser.java
URL:
http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/core/settings/XmlSettingsParser.java?view=diff&rev=516010&r1=516009&r2=516010
==============================================================================
---
incubator/ivy/core/trunk/src/java/org/apache/ivy/core/settings/XmlSettingsParser.java
(original)
+++
incubator/ivy/core/trunk/src/java/org/apache/ivy/core/settings/XmlSettingsParser.java
Thu Mar 8 03:14:01 2007
@@ -296,10 +296,18 @@
String cm =
_ivy.substitute((String)attributes.get("conflict-manager"));
String matcher =
_ivy.substitute((String)attributes.get("matcher"));
matcher = matcher == null ? PatternMatcher.EXACT_OR_REGEXP :
matcher;
+ if (organisation == null) {
+ throw new IllegalArgumentException("'organisation' is
mandatory in module element: check your configuration");
+ }
+ if (module == null) {
+ throw new IllegalArgumentException("'name' is mandatory in
module element: check your configuration");
+ }
_ivy.addModuleConfiguration(new ModuleId(organisation,
module), _ivy.getMatcher(matcher), resolver, branch, cm);
}
- } catch (Exception ex) {
+ } catch (ParseException ex) {
throw new SAXException("problem in config file: "+ex.getMessage(),
ex);
+ } catch (IOException ex) {
+ throw new SAXException("io problem while parsing config file:
"+ex.getMessage(), ex);
}
}
Modified:
incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/matcher/ModuleIdMatcher.java
URL:
http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/matcher/ModuleIdMatcher.java?view=diff&rev=516010&r1=516009&r2=516010
==============================================================================
---
incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/matcher/ModuleIdMatcher.java
(original)
+++
incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/matcher/ModuleIdMatcher.java
Thu Mar 8 03:14:01 2007
@@ -29,7 +29,10 @@
public ModuleIdMatcher(ModuleId mid, PatternMatcher pm) {
_mid = mid;
_pm = pm;
- _orgMatcher = pm.getMatcher(mid.getOrganisation());
+ _orgMatcher = pm.getMatcher(
+ mid.getOrganisation()==null?
+ PatternMatcher.ANY_EXPRESSION
+ :mid.getOrganisation());
_moduleMatcher = pm.getMatcher(mid.getName());
}
Modified:
incubator/ivy/core/trunk/test/java/org/apache/ivy/core/settings/XmlSettingsParserTest.java
URL:
http://svn.apache.org/viewvc/incubator/ivy/core/trunk/test/java/org/apache/ivy/core/settings/XmlSettingsParserTest.java?view=diff&rev=516010&r1=516009&r2=516010
==============================================================================
---
incubator/ivy/core/trunk/test/java/org/apache/ivy/core/settings/XmlSettingsParserTest.java
(original)
+++
incubator/ivy/core/trunk/test/java/org/apache/ivy/core/settings/XmlSettingsParserTest.java
Thu Mar 8 03:14:01 2007
@@ -18,6 +18,8 @@
package org.apache.ivy.core.settings;
import java.io.File;
+import java.io.IOException;
+import java.text.ParseException;
import java.util.List;
import junit.framework.TestCase;
@@ -99,6 +101,28 @@
assertEquals("internal", settings.getResolver(new ModuleId("apache",
"ant")).getName());
assertEquals("int1", settings.getResolver(new ModuleId("apache",
"ivy")).getName());
assertEquals("int1", settings.getResolver(new ModuleId("apache",
"ivyde")).getName());
+ }
+
+ public void testNoOrgInModule() throws Exception {
+ IvySettings settings = new IvySettings();
+ XmlSettingsParser parser = new XmlSettingsParser(settings);
+ try {
+
parser.parse(XmlSettingsParserTest.class.getResource("ivyconf-no-org-in-module.xml"));
+ fail("no organisation in module is supposed to raise an
exception");
+ } catch (ParseException e) {
+ assertTrue("bad exception message: "+e.getMessage(),
e.getMessage().indexOf("'organisation'") != -1);
+ }
+ }
+
+ public void testNoNameInModule() throws Exception {
+ IvySettings settings = new IvySettings();
+ XmlSettingsParser parser = new XmlSettingsParser(settings);
+ try {
+
parser.parse(XmlSettingsParserTest.class.getResource("ivyconf-no-name-in-module.xml"));
+ fail("no name in module is supposed to raise an
exception");
+ } catch (ParseException e) {
+ assertTrue("bad exception message: "+e.getMessage(),
e.getMessage().indexOf("'name'") != -1);
+ }
}
public void testTypedef() throws Exception {
Added:
incubator/ivy/core/trunk/test/java/org/apache/ivy/core/settings/ivyconf-no-name-in-module.xml
URL:
http://svn.apache.org/viewvc/incubator/ivy/core/trunk/test/java/org/apache/ivy/core/settings/ivyconf-no-name-in-module.xml?view=auto&rev=516010
==============================================================================
---
incubator/ivy/core/trunk/test/java/org/apache/ivy/core/settings/ivyconf-no-name-in-module.xml
(added)
+++
incubator/ivy/core/trunk/test/java/org/apache/ivy/core/settings/ivyconf-no-name-in-module.xml
Thu Mar 8 03:14:01 2007
@@ -0,0 +1,5 @@
+<ivyconf>
+ <modules>
+ <module organisation=".*" branch="internal"/>
+ </modules>
+</ivyconf>
Added:
incubator/ivy/core/trunk/test/java/org/apache/ivy/core/settings/ivyconf-no-org-in-module.xml
URL:
http://svn.apache.org/viewvc/incubator/ivy/core/trunk/test/java/org/apache/ivy/core/settings/ivyconf-no-org-in-module.xml?view=auto&rev=516010
==============================================================================
---
incubator/ivy/core/trunk/test/java/org/apache/ivy/core/settings/ivyconf-no-org-in-module.xml
(added)
+++
incubator/ivy/core/trunk/test/java/org/apache/ivy/core/settings/ivyconf-no-org-in-module.xml
Thu Mar 8 03:14:01 2007
@@ -0,0 +1,5 @@
+<ivyconf>
+ <modules>
+ <module name=".*" branch="internal"/>
+ </modules>
+</ivyconf>