normalocity/keyspace — Issue #85: KeySetServer needs to handle BindException
Author: normalocity
Created: 2011-10-17 12:30:03+00:00
State: open
Labels: Bug

If you accidentally try to start two KeySetServers on the same machine, using the same port, it will fail. This is fine, except that the application doesn't close - it just keeps running in the background forever. It should instead perform a System.exit(error_code).

Sample log output:

Mon Oct 17 07:24:29 CDT 2011 :: \/\/ :: Server STOP due to error.
Mon Oct 17 07:24:29 CDT 2011 :: \/\/ :: class keyspace.services.ServerInfoService shutting down...
Mon Oct 17 07:24:29 CDT 2011 :: \/\/ :: class keyspace.services.KeySetGeneratorBackupService shutting down...
Mon Oct 17 07:25:54 CDT 2011 :: /\/\ :: Server start request | v2.09 - 2011.10.08 | PARAMS: test.peer.group --no-daemon
Mon Oct 17 07:25:54 CDT 2011 :: ERR :: I/O error related to network socket - KEYSET REQUEST THREAD.
Mon Oct 17 07:25:54 CDT 2011 :: TRACE :: EXC: class java.net.BindException
Mon Oct 17 07:25:54 CDT 2011 :: TRACE :: MSG: Address already in use
Mon Oct 17 07:25:54 CDT 2011 :: TRACE :: java.net.PlainDatagramSocketImpl.bind0(Native Method)
Mon Oct 17 07:25:54 CDT 2011 :: TRACE :: java.net.PlainDatagramSocketImpl.bind(PlainDatagramSocketImpl.java:91)
Mon Oct 17 07:25:54 CDT 2011 :: TRACE :: java.net.DatagramSocket.bind(DatagramSocket.java:372)
Mon Oct 17 07:25:54 CDT 2011 :: TRACE :: java.net.DatagramSocket.(DatagramSocket.java:211)
Mon Oct 17 07:25:54 CDT 2011 :: TRACE :: java.net.DatagramSocket.(DatagramSocket.java:262)
Mon Oct 17 07:25:54 CDT 2011 :: TRACE :: java.net.DatagramSocket.(DatagramSocket.java:235)
Mon Oct 17 07:25:54 CDT 2011 :: TRACE :: keyspace.services.KeySetRequestService.createListeningSocket(KeySetRequestService.java:50)
Mon Oct 17 07:25:54 CDT 2011 :: TRACE :: keyspace.services.KeySetRequestService.setup(KeySetRequestService.java:34)
Mon Oct 17 07:25:54 CDT 2011 :: TRACE :: keyspace.services.Service.requestStart(Service.java:126)
Mon Oct 17 07:25:54 CDT 2011 :: TRACE :: keyspace.server.KeySetServer.setupAndStartServices(KeySetServer.java:108)
Mon Oct 17 07:25:54 CDT 2011 :: TRACE :: keyspace.server.KeySetServer.main(KeySetServer.java:72)
Mon Oct 17 07:25:54 CDT 2011 :: \/\/ :: Server STOP due to error.
Mon Oct 17 07:25:54 CDT 2011 :: \/\/ :: class keyspace.services.KeySetRequestService shutting down...
Mon Oct 17 07:25:54 CDT 2011 :: /\/\ :: class keyspace.services.KeySetRequestService started.
Mon Oct 17 07:25:54 CDT 2011 :: ERR :: I/O error related to network socket - SERVER INFO THREAD.
Mon Oct 17 07:25:54 CDT 2011 :: TRACE :: EXC: class java.net.BindException
Mon Oct 17 07:25:54 CDT 2011 :: TRACE :: MSG: Address already in use
Mon Oct 17 07:25:54 CDT 2011 :: TRACE :: java.net.PlainDatagramSocketImpl.bind0(Native Method)
Mon Oct 17 07:25:54 CDT 2011 :: TRACE :: java.net.PlainDatagramSocketImpl.bind(PlainDatagramSocketImpl.java:91)
Mon Oct 17 07:25:54 CDT 2011 :: TRACE :: java.net.DatagramSocket.bind(DatagramSocket.java:372)
Mon Oct 17 07:25:54 CDT 2011 :: TRACE :: java.net.DatagramSocket.(DatagramSocket.java:211)
Mon Oct 17 07:25:54 CDT 2011 :: TRACE :: java.net.DatagramSocket.(DatagramSocket.java:262)
Mon Oct 17 07:25:54 CDT 2011 :: TRACE :: java.net.DatagramSocket.(DatagramSocket.java:235)
Mon Oct 17 07:25:54 CDT 2011 :: TRACE :: keyspace.services.ServerInfoService.createListeningSocket(ServerInfoService.java:105)
Mon Oct 17 07:25:54 CDT 2011 :: TRACE :: keyspace.services.ServerInfoService.setup(ServerInfoService.java:46)
Mon Oct 17 07:25:54 CDT 2011 :: TRACE :: keyspace.services.Service.requestStart(Service.java:126)
Mon Oct 17 07:25:54 CDT 2011 :: TRACE :: keyspace.server.KeySetServer.setupAndStartServices(KeySetServer.java:109)
Mon Oct 17 07:25:54 CDT 2011 :: TRACE :: keyspace.server.KeySetServer.main(KeySetServer.java:72)
Mon Oct 17 07:25:54 CDT 2011 :: \/\/ :: Server STOP due to error.
Mon Oct 17 07:25:54 CDT 2011 :: \/\/ :: class keyspace.services.KeySetRequestService shutting down...
Mon Oct 17 07:25:54 CDT 2011 :: ERR :: I/O error when trying to read KeyGenerator state.
Mon Oct 17 07:25:54 CDT 2011 :: TRACE :: EXC: class java.io.EOFException
Mon Oct 17 07:25:54 CDT 2011 :: TRACE :: MSG: null
Mon Oct 17 07:25:54 CDT 2011 :: TRACE :: java.io.ObjectInputStream$BlockDataInputStream.peekByte(ObjectInputStream.java:2553)
Mon Oct 17 07:25:54 CDT 2011 :: TRACE :: java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1296)
Mon Oct 17 07:25:54 CDT 2011 :: TRACE :: java.io.ObjectInputStream.readObject(ObjectInputStream.java:350)
Mon Oct 17 07:25:54 CDT 2011 :: TRACE :: keyspace.base.KeySetGenerator.loadState(KeySetGenerator.java:116)
Mon Oct 17 07:25:54 CDT 2011 :: TRACE :: keyspace.services.KeySetRequestService.loadOrResetKeyGeneratorState(KeySetRequestService.java:151)
Mon Oct 17 07:25:54 CDT 2011 :: TRACE :: keyspace.services.KeySetRequestService.run(KeySetRequestService.java:60)
Mon Oct 17 07:25:54 CDT 2011 :: TRACE :: java.lang.Thread.run(Thread.java:680)
Mon Oct 17 07:25:54 CDT 2011 :: \/\/ :: Server STOP due to error.
Mon Oct 17 07:25:54 CDT 2011 :: \/\/ :: class keyspace.services.ServerInfoService shutting down...
Mon Oct 17 07:25:54 CDT 2011 :: \/\/ :: class keyspace.services.KeySetGeneratorBackupService shutting down...