Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoreutarass2010-05-06 15:03:04 -0400
committereutarass2010-05-06 15:03:04 -0400
commit9c38a012cd770e765f922e8b989606f97f08d603 (patch)
tree75abbf4a50f1e3f5a91b4bccd2a6567974163d8e /plugins/org.eclipse.tm.tcf.core
parent1571bb8aa1fe7300e4578d1545e8aa353abe1889 (diff)
downloadorg.eclipse.tcf-9c38a012cd770e765f922e8b989606f97f08d603.tar.gz
org.eclipse.tcf-9c38a012cd770e765f922e8b989606f97f08d603.tar.xz
org.eclipse.tcf-9c38a012cd770e765f922e8b989606f97f08d603.zip
Bug 304331: Fail to connect peer if port is specified non-decimal
Diffstat (limited to 'plugins/org.eclipse.tm.tcf.core')
-rw-r--r--plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/internal/tcf/core/TransportManager.java23
-rw-r--r--plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/tcf/protocol/IPeer.java17
2 files changed, 34 insertions, 6 deletions
diff --git a/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/internal/tcf/core/TransportManager.java b/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/internal/tcf/core/TransportManager.java
index 631e5ecab..c16ba481b 100644
--- a/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/internal/tcf/core/TransportManager.java
+++ b/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/internal/tcf/core/TransportManager.java
@@ -51,9 +51,8 @@ public class TransportManager {
Map<String,String> attrs = peer.getAttributes();
String host = attrs.get(IPeer.ATTR_IP_HOST);
String port = attrs.get(IPeer.ATTR_IP_PORT);
- if (host == null) throw new Error("No host name");
- if (port == null) throw new Error("No port number");
- return new ChannelTCP(peer, host, Integer.parseInt(port), false);
+ if (host == null) throw new IllegalArgumentException("No host name");
+ return new ChannelTCP(peer, host, parsePort(port), false);
}
});
@@ -68,9 +67,8 @@ public class TransportManager {
Map<String,String> attrs = peer.getAttributes();
String host = attrs.get(IPeer.ATTR_IP_HOST);
String port = attrs.get(IPeer.ATTR_IP_PORT);
- if (host == null) throw new Error("No host name");
- if (port == null) throw new Error("No port number");
- return new ChannelTCP(peer, host, Integer.parseInt(port), true);
+ if (host == null) throw new IllegalArgumentException("No host name");
+ return new ChannelTCP(peer, host, parsePort(port), true);
}
});
@@ -87,6 +85,19 @@ public class TransportManager {
});
}
+ private static int parsePort(String port) {
+ if (port == null) throw new Error("No port number");
+ try {
+ return Integer.parseInt(port);
+ }
+ catch (NumberFormatException x) {
+ IllegalArgumentException y = new IllegalArgumentException(
+ "Invalid value of \"Port\" attribute. Must be decimal number.");
+ y.initCause(x);
+ throw y;
+ }
+ }
+
public static void addTransportProvider(ITransportProvider transport) {
String name = transport.getName();
assert name != null;
diff --git a/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/tcf/protocol/IPeer.java b/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/tcf/protocol/IPeer.java
index ecacb224a..5677fb246 100644
--- a/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/tcf/protocol/IPeer.java
+++ b/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/tcf/protocol/IPeer.java
@@ -28,14 +28,31 @@ public interface IPeer {
* Peer property names. Implementation can define additional properties.
*/
static final String
+ /** Peer unique ID */
ATTR_ID = "ID",
+
+ /** Peer name */
ATTR_NAME = "Name",
+
+ /** Name of the peer operating system */
ATTR_OS_NAME = "OSName",
+
+ /** Transport name, for example TCP, SSL */
ATTR_TRANSPORT_NAME = "TransportName",
+
+ /** If present, indicates that the peer can forward traffic to other peers */
ATTR_PROXY = "Proxy",
+
+ /** Host DNS name or IP address */
ATTR_IP_HOST = "Host",
+
+ /** Optional list of host aliases */
ATTR_IP_ALIASES = "Aliases",
+
+ /** Optional list of host addresses */
ATTR_IP_ADDRESSES = "Addresses",
+
+ /** IP port number, must be decimal number */
ATTR_IP_PORT = "Port";

Back to the top