[virtualcommons-svn] SF.net SVN: virtualcommons:[423] csidex/trunk/src/main/java/edu/asu/commons /n
Status: Beta
Brought to you by:
alllee
From: <al...@us...> - 2010-01-05 19:28:53
|
Revision: 423 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=423&view=rev Author: alllee Date: 2010-01-05 19:28:43 +0000 (Tue, 05 Jan 2010) Log Message: ----------- NPE fix for SocketIdentifier.compareTo Modified Paths: -------------- csidex/trunk/src/main/java/edu/asu/commons/net/SocketIdentifier.java Modified: csidex/trunk/src/main/java/edu/asu/commons/net/SocketIdentifier.java =================================================================== --- csidex/trunk/src/main/java/edu/asu/commons/net/SocketIdentifier.java 2010-01-05 08:04:55 UTC (rev 422) +++ csidex/trunk/src/main/java/edu/asu/commons/net/SocketIdentifier.java 2010-01-05 19:28:43 UTC (rev 423) @@ -20,6 +20,7 @@ private final InetSocketAddress localSocketAddress; private final InetSocketAddress remoteSocketAddress; + // FIXME: refactor, is this necessary if we're also maintaining the station number? logic is convoluted. private boolean stationed; private Integer stationNumber; @@ -107,8 +108,8 @@ */ public String toString() { - int stationNumber = getStationNumber(); - return (stationed) ? String.format("Station %d:%d", stationNumber, id) : remoteSocketAddress.toString(); + int stationNumberInt = getStationNumber(); + return (stationed) ? String.format("Station %d:%d", stationNumberInt, id) : remoteSocketAddress.toString(); } /** @@ -139,11 +140,11 @@ public int compareTo(SocketIdentifier socketId) { int comparison = 0; - if (stationed) { + if (stationNumber != null) { comparison = stationNumber.compareTo(socketId.stationNumber); } if (comparison == 0) { - // ensure that these two are .equals. + // if these two socket ids are .equals, comparison of 0 is fine. Otherwise go by the id. if (! equals(socketId)) { comparison = Integer.valueOf(id).compareTo(Integer.valueOf(socketId.id)); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |