From d98926aebb0859dc63a57283df237fff7fb1f76f Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Thu, 19 Apr 2012 13:28:26 +0200 Subject: [PATCH] Fixes NPE. if the root URL isn't configured, clients won't be able to find this, so might as well not advertise at all. --- core/src/main/java/hudson/DNSMultiCast.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/hudson/DNSMultiCast.java b/core/src/main/java/hudson/DNSMultiCast.java index 000bbcfd90..d238a86daa 100644 --- a/core/src/main/java/hudson/DNSMultiCast.java +++ b/core/src/main/java/hudson/DNSMultiCast.java @@ -28,8 +28,9 @@ public class DNSMultiCast implements Closeable { Map props = new HashMap(); String rootURL = hudson.getRootUrl(); - if (rootURL!=null) - props.put("url", rootURL); + if (rootURL==null) return; + + props.put("url", rootURL); try { props.put("version",String.valueOf(Jenkins.getVersion())); } catch (IllegalArgumentException e) { @@ -50,7 +51,7 @@ public class DNSMultiCast implements Closeable { if (jenkins_url.getPath().length() > 0) { props.put("path", jenkins_url.getPath()); } - + jmdns.registerService(ServiceInfo.create("_hudson._tcp.local.","hudson", jenkins_port,0,0,props)); // for backward compatibility jmdns.registerService(ServiceInfo.create("_jenkins._tcp.local.","jenkins", -- GitLab