Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[FIXED JENKINS-14769] NPE from UpdateSite$Plugin.getNeededDependencies.
  • Loading branch information
jglick committed Aug 10, 2012
1 parent 9074318 commit e46e167
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
3 changes: 3 additions & 0 deletions changelog.html
Expand Up @@ -55,6 +55,9 @@
<!-- Record your changes in the trunk here. -->
<div id="trunk" style="display:none"><!--=TRUNK-BEGIN=-->
<ul class=image>
<li class=bug>
NPE from <code>UpdateSite$Plugin.getNeededDependencies</code>.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-14769">issue 14769</a>)
<li class=bug>
Description preview and syntax highlighting broken since 1.477.
</ul>
Expand Down
3 changes: 2 additions & 1 deletion core/src/main/java/hudson/model/UpdateCenter.java
Expand Up @@ -83,6 +83,7 @@
import java.util.jar.JarFile;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.CheckForNull;
import org.acegisecurity.context.SecurityContextHolder;
import org.kohsuke.stapler.export.Exported;
import org.kohsuke.stapler.export.ExportedBean;
Expand Down Expand Up @@ -289,7 +290,7 @@ public String getDefaultBaseUrl() {
/**
* Gets the plugin with the given name from the first {@link UpdateSite} to contain it.
*/
public Plugin getPlugin(String artifactId) {
public @CheckForNull Plugin getPlugin(String artifactId) {
for (UpdateSite s : sites) {
Plugin p = s.getPlugin(artifactId);
if (p!=null) return p;
Expand Down
9 changes: 4 additions & 5 deletions core/src/main/java/hudson/model/UpdateSite.java
Expand Up @@ -35,7 +35,6 @@
import hudson.util.HttpResponses;
import hudson.util.IOUtils;
import hudson.util.TextFile;
import hudson.util.TimeUnit2;
import hudson.util.VersionNumber;
import jenkins.model.Jenkins;
import net.sf.json.JSONException;
Expand All @@ -46,20 +45,16 @@
import org.jvnet.hudson.crypto.SignatureOutputStream;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.HttpResponse;
import org.kohsuke.stapler.QueryParameter;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;
import org.kohsuke.stapler.export.Exported;
import org.kohsuke.stapler.export.ExportedBean;
import org.kohsuke.stapler.interceptor.RequirePOST;

import javax.servlet.ServletContext;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.security.DigestOutputStream;
import java.security.GeneralSecurityException;
import java.security.MessageDigest;
Expand Down Expand Up @@ -722,6 +717,10 @@ public List<Plugin> getNeededDependencies() {

for(Map.Entry<String,String> e : dependencies.entrySet()) {
Plugin depPlugin = Jenkins.getInstance().getUpdateCenter().getPlugin(e.getKey());
if (depPlugin == null) {
LOGGER.log(Level.WARNING, "Could not find dependency {0} of {1}", new Object[] {e.getKey(), name});
continue;
}
VersionNumber requiredVersion = new VersionNumber(e.getValue());

// Is the plugin installed already? If not, add it.
Expand Down

0 comments on commit e46e167

Please sign in to comment.