Skip to content
Permalink
Browse files
[FIXED JENKINS-17402] getItem may return null but may not throw IAE.(…
…cherry picked from commit 7fa8fe4)

Conflicts:
	changelog.html
  • Loading branch information
jglick authored and vjuranek committed May 17, 2013
1 parent 83b5ccb commit 01f09f66caf0cc96d1d5fd01d3105b65f745a8a4
@@ -55,7 +55,9 @@
<!-- Record your changes in the trunk here. -->
<div id="trunk" style="display:none"><!--=TRUNK-BEGIN=-->
<ul class=image>
<li class=>
<li class='major bug'>
NPE configuring Copy Artifact with Maven jobs.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-17402">issue 17402</a>)
</ul>
</div><!--=TRUNK-END=-->

@@ -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.
@@ -432,7 +432,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 01f09f6

Please sign in to comment.