Skip to content
Permalink
Browse files
[FIXED JENKINS-17402] getItem may return null but may not throw IAE.
  • Loading branch information
jglick committed Apr 25, 2013
1 parent 4057463 commit 7fa8fe4096d0134f598a9d475df1c6199b9b05e7
@@ -63,6 +63,9 @@
<li class=bug>
NPE from <code>MatrixConfiguration.newBuild</code>.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-17728">issue 17728</a>)
<li class='major bug'>
NPE configuring Copy Artifact with Maven jobs.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-17402">issue 17402</a>)
<li class=rfe>
<code>/about</code> now links to license information for plugins as well.
<li class=rfe>
@@ -26,6 +26,7 @@
import java.io.IOException;
import java.util.Collection;
import java.io.File;
import javax.annotation.CheckForNull;

/**
* Represents a grouping inherent to a kind of {@link Item}s.
@@ -64,9 +65,9 @@
String getUrlChildPrefix();

/**
* Gets the {@link Item} inside this group that has a given name.
* Gets the {@link Item} inside this group that has a given name, or null if it does not exist.
*/
T getItem(String name);
@CheckForNull T getItem(String name);

/**
* Assigns the {@link Item#getRootDir() root directory} for children.
@@ -434,7 +434,11 @@ public String getUrlChildPrefix() {
}

public MavenModule getItem(String name) {
return modules.get(ModuleName.fromString(name));
try {
return modules.get(ModuleName.fromString(name));
} catch (IllegalArgumentException x) {
return null; // not a Maven module name, ignore
}
}

public MavenModule getModule(String name) {
@@ -2,6 +2,7 @@

import hudson.maven.local_repo.PerJobLocalRepositoryLocator;
import hudson.model.Item;
import org.jvnet.hudson.test.Bug;

import org.jvnet.hudson.test.HudsonTestCase;

@@ -22,4 +23,10 @@ public void testConfigRoundtripLocalRepository() throws Exception {
assertEqualDataBoundBeans(p.getLocalRepository(),before);
assertTrue(before!=p.getLocalRepository());
}

@Bug(17402)
public void testGetItem() throws Exception {
assertNull(createMavenProject().getItem("invalid"));
}

}

0 comments on commit 7fa8fe4

Please sign in to comment.