Skip to content
Permalink
Browse files

Add hack to get around the "" -> java.net.URL exception (JENKINS-18229)

  • Loading branch information
milkboy committed Jun 12, 2013
1 parent deb1d45 commit f92de0cae0a3555ba94daa967a609c8bfea63b0e
Showing with 21 additions and 1 deletion.
  1. +21 −1 src/main/java/hudson/plugins/jira/JiraProjectProperty.java
@@ -7,9 +7,13 @@
import hudson.model.JobPropertyDescriptor;
import hudson.util.CopyOnWriteList;
import net.sf.json.JSONObject;
import org.apache.commons.beanutils.Converter;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.Stapler;
import org.kohsuke.stapler.StaplerRequest;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.logging.Logger;

/**
@@ -102,7 +106,23 @@ public void setSites(JiraSite site) {

@Override
public boolean configure(StaplerRequest req, JSONObject formData) {
sites.replaceBy(req.bindJSONToList(JiraSite.class, formData.get("sites")));
//Fix^H^H^HDirty hack for empty string to URL conversion error
Stapler.CONVERT_UTILS.deregister(java.net.URL.class);
Converter tmpUrlConverter = new Converter() {
public Object convert(Class aClass, Object o) {
if(o == null || "".equals(o) || "null".equals(o)) return null;
try {
return new URL((String) o);
} catch (MalformedURLException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
return null;
}
}
};
Stapler.CONVERT_UTILS.register(tmpUrlConverter, java.net.URL.class);
//End hack

sites.replaceBy(req.bindJSONToList(JiraSite.class, formData.get("sites")));
save();
return true;
}

0 comments on commit f92de0c

Please sign in to comment.
You can’t perform that action at this time.