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:
parent
59f3034f00
commit
362722f555
@ -34,6 +34,7 @@
|
|||||||
deprecation="true"
|
deprecation="true"
|
||||||
destdir="${dest}"
|
destdir="${dest}"
|
||||||
nowarn="false"
|
nowarn="false"
|
||||||
|
optimize="true"
|
||||||
target="1.5"
|
target="1.5"
|
||||||
source="1.5">
|
source="1.5">
|
||||||
<src path="${src}"/>
|
<src path="${src}"/>
|
||||||
|
|||||||
@ -12,7 +12,7 @@ public class PseudoTcpSocketFactory
|
|||||||
* Default conversation ID
|
* Default conversation ID
|
||||||
*/
|
*/
|
||||||
public static final long DEFAULT_CONVERSATION_ID=0;
|
public static final long DEFAULT_CONVERSATION_ID=0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default timeout for connect operation
|
* Default timeout for connect operation
|
||||||
*/
|
*/
|
||||||
@ -22,7 +22,6 @@ public class PseudoTcpSocketFactory
|
|||||||
* Creates a socket and connects it to the specified
|
* Creates a socket and connects it to the specified
|
||||||
* port number at the specified address.
|
* port number at the specified address.
|
||||||
*/
|
*/
|
||||||
@Override
|
|
||||||
public Socket createSocket(String host, int port)
|
public Socket createSocket(String host, int port)
|
||||||
throws IOException,
|
throws IOException,
|
||||||
UnknownHostException
|
UnknownHostException
|
||||||
@ -36,20 +35,19 @@ public class PseudoTcpSocketFactory
|
|||||||
* Creates a socket and connect it to the specified remote address
|
* Creates a socket and connect it to the specified remote address
|
||||||
* on the specified remote port.
|
* on the specified remote port.
|
||||||
*/
|
*/
|
||||||
@Override
|
|
||||||
public Socket createSocket(InetAddress host, int port) throws IOException
|
public Socket createSocket(InetAddress host, int port) throws IOException
|
||||||
{
|
{
|
||||||
Socket socket = createSocket();
|
Socket socket = createSocket();
|
||||||
connectSocket(socket, new InetSocketAddress(host, port));
|
connectSocket(socket, new InetSocketAddress(host, port));
|
||||||
return socket;
|
return socket;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void connectSocket(Socket socket, InetSocketAddress remoteSockAddr)
|
private void connectSocket(Socket socket, InetSocketAddress remoteSockAddr)
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
socket.connect(remoteSockAddr, DEFAULT_CONNECT_TIMEOUT);
|
socket.connect(remoteSockAddr, DEFAULT_CONNECT_TIMEOUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates socket bound to local <tt>sockAddr</tt>
|
* Creates socket bound to local <tt>sockAddr</tt>
|
||||||
* @param sockAddr
|
* @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.
|
* Creates a socket and connects it to the specified remote host at the specified remote port.
|
||||||
*/
|
*/
|
||||||
@Override
|
|
||||||
public Socket createSocket(String host,
|
public Socket createSocket(String host,
|
||||||
int port,
|
int port,
|
||||||
InetAddress localHost,
|
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.
|
* Creates a socket and connects it to the specified remote host on the specified remote port.
|
||||||
*/
|
*/
|
||||||
@Override
|
|
||||||
public Socket createSocket(InetAddress address, int port,
|
public Socket createSocket(InetAddress address, int port,
|
||||||
InetAddress localAddress, int localPort) throws IOException
|
InetAddress localAddress, int localPort) throws IOException
|
||||||
{
|
{
|
||||||
@ -107,14 +103,14 @@ public class PseudoTcpSocketFactory
|
|||||||
return new PseudoTcpSocket(
|
return new PseudoTcpSocket(
|
||||||
new PseudoTcpSocketImpl(DEFAULT_CONVERSATION_ID, datagramSocket));
|
new PseudoTcpSocketImpl(DEFAULT_CONVERSATION_ID, datagramSocket));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the PseudoTcp socket and binds it to any available port
|
* Creates the PseudoTcp socket and binds it to any available port
|
||||||
* on the local host machine. The socket will be bound to the
|
* on the local host machine. The socket will be bound to the
|
||||||
* {@link InetAddress#isAnyLocalAddress wildcard} address,
|
* {@link InetAddress#isAnyLocalAddress wildcard} address,
|
||||||
* an IP address chosen by the kernel.
|
* an IP address chosen by the kernel.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public PseudoTcpSocket createSocket()
|
public PseudoTcpSocket createSocket()
|
||||||
throws SocketException
|
throws SocketException
|
||||||
{
|
{
|
||||||
@ -122,7 +118,6 @@ public class PseudoTcpSocketFactory
|
|||||||
new PseudoTcpSocketImpl(DEFAULT_CONVERSATION_ID));
|
new PseudoTcpSocketImpl(DEFAULT_CONVERSATION_ID));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public SocketImpl createSocketImpl()
|
public SocketImpl createSocketImpl()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -134,5 +129,4 @@ public class PseudoTcpSocketFactory
|
|||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,8 +27,8 @@ class Connector
|
|||||||
/**
|
/**
|
||||||
* Our class logger.
|
* Our class logger.
|
||||||
*/
|
*/
|
||||||
private static final Logger logger =
|
private static final Logger logger
|
||||||
Logger.getLogger(Connector.class.getName());
|
= Logger.getLogger(Connector.class.getName());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The message queue is where incoming messages are added.
|
* The message queue is where incoming messages are added.
|
||||||
@ -204,10 +204,10 @@ class Connector
|
|||||||
stop();
|
stop();
|
||||||
//Something wrong has happened
|
//Something wrong has happened
|
||||||
errorHandler.handleFatalError(
|
errorHandler.handleFatalError(
|
||||||
this,
|
this,
|
||||||
"A socket exception was thrown while trying to "
|
"A socket exception was thrown"
|
||||||
+ "receive a message.",
|
+ " while trying to receive a message.",
|
||||||
ex);
|
ex);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -230,24 +230,26 @@ class Connector
|
|||||||
|
|
||||||
stop();
|
stop();
|
||||||
errorHandler.handleFatalError(
|
errorHandler.handleFatalError(
|
||||||
this,
|
this,
|
||||||
"Unknown error occurred while listening for messages!",
|
"Unknown error occurred while listening for messages!",
|
||||||
ex);
|
ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Makes the access point stop listening on its socket.
|
* Makes the access point stop listening on its socket.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
protected void stop()
|
protected void stop()
|
||||||
{
|
{
|
||||||
synchronized(sockLock)
|
synchronized(sockLock)
|
||||||
{
|
{
|
||||||
this.running = false;
|
this.running = false;
|
||||||
this.sock.close();
|
if (this.sock != null)
|
||||||
this.sock = null;
|
{
|
||||||
|
this.sock.close();
|
||||||
|
this.sock = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -232,15 +232,19 @@ class NetAccessManager
|
|||||||
*/
|
*/
|
||||||
protected void removeSocket(TransportAddress address)
|
protected void removeSocket(TransportAddress address)
|
||||||
{
|
{
|
||||||
Connector ap = null;
|
Connector ap;
|
||||||
|
|
||||||
if(address.getTransport() == Transport.UDP)
|
switch (address.getTransport())
|
||||||
{
|
|
||||||
ap = netUDPAccessPoints.remove(address);
|
|
||||||
}
|
|
||||||
else if(address.getTransport() == Transport.TCP)
|
|
||||||
{
|
{
|
||||||
|
case TCP:
|
||||||
ap = netTCPAccessPoints.remove(address);
|
ap = netTCPAccessPoints.remove(address);
|
||||||
|
break;
|
||||||
|
case UDP:
|
||||||
|
ap = netUDPAccessPoints.remove(address);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ap = null;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ap != null)
|
if(ap != null)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user