Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2007-12-12 06:10:20 +0000
committerslewis2007-12-12 06:10:20 +0000
commit3b8c952fbbd67fbe357ef96e0831437ca94b0d0e (patch)
treebc36e952de02c573ae2037402ccb38930496858c /providers/bundles/org.eclipse.ecf.provider.jmdns
parent2bd547709e34581aece65c125369ca9d852d56ab (diff)
downloadorg.eclipse.ecf-3b8c952fbbd67fbe357ef96e0831437ca94b0d0e.tar.gz
org.eclipse.ecf-3b8c952fbbd67fbe357ef96e0831437ca94b0d0e.tar.xz
org.eclipse.ecf-3b8c952fbbd67fbe357ef96e0831437ca94b0d0e.zip
Fix for jmdns contract violation
Diffstat (limited to 'providers/bundles/org.eclipse.ecf.provider.jmdns')
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.jmdns/src/org/eclipse/ecf/internal/provider/jmdns/Messages.java1
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.jmdns/src/org/eclipse/ecf/internal/provider/jmdns/messages.properties1
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.jmdns/src/org/eclipse/ecf/provider/jmdns/container/JMDNSDiscoveryContainer.java17
3 files changed, 17 insertions, 2 deletions
diff --git a/providers/bundles/org.eclipse.ecf.provider.jmdns/src/org/eclipse/ecf/internal/provider/jmdns/Messages.java b/providers/bundles/org.eclipse.ecf.provider.jmdns/src/org/eclipse/ecf/internal/provider/jmdns/Messages.java
index 39474c61d..4d2ba6590 100644
--- a/providers/bundles/org.eclipse.ecf.provider.jmdns/src/org/eclipse/ecf/internal/provider/jmdns/Messages.java
+++ b/providers/bundles/org.eclipse.ecf.provider.jmdns/src/org/eclipse/ecf/internal/provider/jmdns/Messages.java
@@ -25,6 +25,7 @@ public class Messages extends NLS {
public static String JMDNSDiscoveryContainer_EXCEPTION_CREATE_JMDNS_INSTANCE;
public static String JMDNSDiscoveryContainer_DISCOVERY_NOT_INITIALIZED;
public static String JMDNSDiscoveryContainer_EXCEPTION_REGISTER_SERVICE;
+ public static String JMDNSDiscoveryContainer_EXCEPTION_SERVICEINFO_INVALID;
public static String JMDNSDiscoveryContainer_JMDNS_LOCAL_SUFFIX;
public static String JMDNSDiscoveryContainer_SERVICE_NAME_NOT_NULL;
public static String JMDNSNamespace_EXCEPTION_ID_CREATE_SERVICE_TYPE_CANNOT_BE_EMPTY;
diff --git a/providers/bundles/org.eclipse.ecf.provider.jmdns/src/org/eclipse/ecf/internal/provider/jmdns/messages.properties b/providers/bundles/org.eclipse.ecf.provider.jmdns/src/org/eclipse/ecf/internal/provider/jmdns/messages.properties
index 94196097c..e7e61c983 100644
--- a/providers/bundles/org.eclipse.ecf.provider.jmdns/src/org/eclipse/ecf/internal/provider/jmdns/messages.properties
+++ b/providers/bundles/org.eclipse.ecf.provider.jmdns/src/org/eclipse/ecf/internal/provider/jmdns/messages.properties
@@ -7,6 +7,7 @@ JMDNSNamespace_EXCEPTION_ID_WRONG_PARAM_COUNT=Wrong parameter count
JMDNSServiceTypeID_EXCEPTION_INVALID_TYPE_ID={0} is not a valid JMDNSServiceTypeID
JMDNSDiscoveryContainer_DISCOVERY_NOT_INITIALIZED=Discovery not initialized. May need to connect.
JMDNSDiscoveryContainer_EXCEPTION_REGISTER_SERVICE=registerService
+JMDNSDiscoveryContainer_EXCEPTION_SERVICEINFO_INVALID=ServiceInfo is invalid.
ContainerInstantiator_EXCEPTION_CONTAINER_CREATE=Exception making JMDNS container
ContainerInstantiator_EXCEPTION_GETTING_INETADDRESS=Exception getting InetAddress for JMDNS container
JMDNSNamespace_EXCEPTION_TYPE_PARAM_NOT_STRING=First parameter cannot be cast to String
diff --git a/providers/bundles/org.eclipse.ecf.provider.jmdns/src/org/eclipse/ecf/provider/jmdns/container/JMDNSDiscoveryContainer.java b/providers/bundles/org.eclipse.ecf.provider.jmdns/src/org/eclipse/ecf/provider/jmdns/container/JMDNSDiscoveryContainer.java
index d1d3ecc13..024af46b9 100644
--- a/providers/bundles/org.eclipse.ecf.provider.jmdns/src/org/eclipse/ecf/provider/jmdns/container/JMDNSDiscoveryContainer.java
+++ b/providers/bundles/org.eclipse.ecf.provider.jmdns/src/org/eclipse/ecf/provider/jmdns/container/JMDNSDiscoveryContainer.java
@@ -11,6 +11,7 @@
package org.eclipse.ecf.provider.jmdns.container;
import java.io.IOException;
+import java.io.InvalidObjectException;
import java.net.InetAddress;
import java.util.*;
import javax.jmdns.*;
@@ -249,7 +250,10 @@ public class JMDNSDiscoveryContainer extends AbstractDiscoveryContainerAdapter i
*/
public void serviceTypeAdded(final ServiceEvent arg0) {
Trace.trace(JMDNSPlugin.PLUGIN_ID, "serviceTypeAdded(" + arg0 + ")"); //$NON-NLS-1$ //$NON-NLS-2$
- final IServiceTypeID serviceType = createServiceTypeID(arg0.getType());
+ String st = arg0.getType();
+ if (st == null)
+ return;
+ final IServiceTypeID serviceType = createServiceTypeID(st);
runInThread(new Runnable() {
public void run() {
if (jmdns != null) {
@@ -336,13 +340,22 @@ public class JMDNSDiscoveryContainer extends AbstractDiscoveryContainerAdapter i
}
private IServiceTypeID createServiceTypeID(String type) {
- return createServiceID(type, null).getServiceTypeID();
+ IServiceID serviceID = createServiceID(type, null);
+ if (serviceID == null)
+ return null;
+ return serviceID.getServiceTypeID();
}
IServiceInfo createIServiceInfoFromServiceInfo(final ServiceInfo serviceInfo) throws Exception {
if (serviceInfo == null)
return null;
+ String st = serviceInfo.getType();
+ String n = serviceInfo.getName();
+ if (st == null || n == null)
+ throw new InvalidObjectException(Messages.JMDNSDiscoveryContainer_EXCEPTION_SERVICEINFO_INVALID);
final ServiceID sID = createServiceID(serviceInfo.getType(), serviceInfo.getName());
+ if (sID == null)
+ throw new InvalidObjectException(Messages.JMDNSDiscoveryContainer_EXCEPTION_SERVICEINFO_INVALID);
final InetAddress addr = serviceInfo.getAddress();
final int port = serviceInfo.getPort();
final int priority = serviceInfo.getPriority();

Back to the top