[freenet-cvs] r14602 - trunk/freenet/src/freenet/node

toad at freenetproject.org toad at freenetproject.org
Sat Aug 11 13:54:33 UTC 2007


Author: toad
Date: 2007-08-11 13:54:33 +0000 (Sat, 11 Aug 2007)
New Revision: 14602

Modified:
   trunk/freenet/src/freenet/node/TextModeClientInterfaceServer.java
Log:
Fix NPE, create the NetworkInterface in the constructor as other code does.

Modified: trunk/freenet/src/freenet/node/TextModeClientInterfaceServer.java
===================================================================
--- trunk/freenet/src/freenet/node/TextModeClientInterfaceServer.java	2007-08-11 13:50:20 UTC (rev 14601)
+++ trunk/freenet/src/freenet/node/TextModeClientInterfaceServer.java	2007-08-11 13:54:33 UTC (rev 14602)
@@ -35,9 +35,9 @@
     String bindTo;
     String allowedHosts;
     boolean isEnabled;
-    NetworkInterface networkInterface;
+    final NetworkInterface networkInterface;
 
-    TextModeClientInterfaceServer(Node node, NodeClientCore core, int port, String bindTo, String allowedHosts) {
+    TextModeClientInterfaceServer(Node node, NodeClientCore core, int port, String bindTo, String allowedHosts) throws IOException {
     	this.n = node;
     	this.core = n.clientCore;
         this.r = n.random;
@@ -47,6 +47,7 @@
         this.bindTo=bindTo;
         this.allowedHosts = allowedHosts;
         this.isEnabled=true;
+		networkInterface = NetworkInterface.create(port, bindTo, allowedHosts);
     }
     
     void start() {
@@ -212,13 +213,6 @@
     		int curPort = port;
     		String tempBindTo = this.bindTo;
     		try {
-    			networkInterface = NetworkInterface.create(curPort, tempBindTo, allowedHosts);
-    		} catch (IOException e) {
-    			Logger.error(this, "Could not bind to TMCI port: "+tempBindTo+ ':' +port);
-    			System.err.println("Could not bind to TMCI port: "+tempBindTo+ ':' +port);
-    			return;
-    		}
-    		try {
     			networkInterface.setSoTimeout(1000);
     		} catch (SocketException e1) {
     			Logger.error(this, "Could not set timeout: "+e1, e1);




More information about the cvs mailing list