Prevents a NullPointerException in Connector#stop(). Removes a few @Override annotations from abstract method implementations because they are not compatible with Java 5.

This commit is contained in:
lubomir.marinov 2012-11-06 12:17:07 +00:00
parent 59f3034f00
commit 362722f555
4 changed files with 30 additions and 29 deletions

View File

@ -34,6 +34,7 @@
deprecation="true"
destdir="${dest}"
nowarn="false"
optimize="true"
target="1.5"
source="1.5">
<src path="${src}"/>

View File

@ -12,7 +12,7 @@ public class PseudoTcpSocketFactory
* Default conversation ID
*/
public static final long DEFAULT_CONVERSATION_ID=0;
/**
* Default timeout for connect operation
*/
@ -22,7 +22,6 @@ public class PseudoTcpSocketFactory
* Creates a socket and connects it to the specified
* port number at the specified address.
*/
@Override
public Socket createSocket(String host, int port)
throws IOException,
UnknownHostException
@ -36,20 +35,19 @@ public class PseudoTcpSocketFactory
* Creates a socket and connect it to the specified remote address
* on the specified remote port.
*/
@Override
public Socket createSocket(InetAddress host, int port) throws IOException
{
Socket socket = createSocket();
connectSocket(socket, new InetSocketAddress(host, port));
return socket;
}
private void connectSocket(Socket socket, InetSocketAddress remoteSockAddr)
throws IOException
{
socket.connect(remoteSockAddr, DEFAULT_CONNECT_TIMEOUT);
}
/**
* Creates socket bound to local <tt>sockAddr</tt>
* @param sockAddr
@ -67,7 +65,6 @@ public class PseudoTcpSocketFactory
/**
* Creates a socket and connects it to the specified remote host at the specified remote port.
*/
@Override
public Socket createSocket(String host,
int port,
InetAddress localHost,
@ -84,7 +81,6 @@ public class PseudoTcpSocketFactory
/**
* Creates a socket and connects it to the specified remote host on the specified remote port.
*/
@Override
public Socket createSocket(InetAddress address, int port,
InetAddress localAddress, int localPort) throws IOException
{
@ -107,14 +103,14 @@ public class PseudoTcpSocketFactory
return new PseudoTcpSocket(
new PseudoTcpSocketImpl(DEFAULT_CONVERSATION_ID, datagramSocket));
}
/**
* Creates the PseudoTcp socket and binds it to any available port
* on the local host machine. The socket will be bound to the
* {@link InetAddress#isAnyLocalAddress wildcard} address,
* an IP address chosen by the kernel.
*
*/
@Override
public PseudoTcpSocket createSocket()
throws SocketException
{
@ -122,7 +118,6 @@ public class PseudoTcpSocketFactory
new PseudoTcpSocketImpl(DEFAULT_CONVERSATION_ID));
}
@Override
public SocketImpl createSocketImpl()
{
try
@ -134,5 +129,4 @@ public class PseudoTcpSocketFactory
throw new RuntimeException(e);
}
}
}

View File

@ -27,8 +27,8 @@ class Connector
/**
* Our class logger.
*/
private static final Logger logger =
Logger.getLogger(Connector.class.getName());
private static final Logger logger
= Logger.getLogger(Connector.class.getName());
/**
* The message queue is where incoming messages are added.
@ -204,10 +204,10 @@ class Connector
stop();
//Something wrong has happened
errorHandler.handleFatalError(
this,
"A socket exception was thrown while trying to "
+ "receive a message.",
ex);
this,
"A socket exception was thrown"
+ " while trying to receive a message.",
ex);
}
else
{
@ -230,24 +230,26 @@ class Connector
stop();
errorHandler.handleFatalError(
this,
"Unknown error occurred while listening for messages!",
ex);
this,
"Unknown error occurred while listening for messages!",
ex);
}
}
}
/**
* Makes the access point stop listening on its socket.
*
*/
protected void stop()
{
synchronized(sockLock)
{
this.running = false;
this.sock.close();
this.sock = null;
if (this.sock != null)
{
this.sock.close();
this.sock = null;
}
}
}

View File

@ -232,15 +232,19 @@ class NetAccessManager
*/
protected void removeSocket(TransportAddress address)
{
Connector ap = null;
Connector ap;
if(address.getTransport() == Transport.UDP)
{
ap = netUDPAccessPoints.remove(address);
}
else if(address.getTransport() == Transport.TCP)
switch (address.getTransport())
{
case TCP:
ap = netTCPAccessPoints.remove(address);
break;
case UDP:
ap = netUDPAccessPoints.remove(address);
break;
default:
ap = null;
break;
}
if(ap != null)