Fixes warnings, manually formats source code.

This commit is contained in:
lubomir.marinov 2014-09-05 13:17:16 +00:00
parent e497af1850
commit fd616daa1c
4 changed files with 53 additions and 33 deletions

View File

@ -691,7 +691,7 @@ class PseudoTcpSocketImpl
private final static ScheduledThreadPoolExecutor clockExecutor private final static ScheduledThreadPoolExecutor clockExecutor
= new ScheduledThreadPoolExecutor(1); = new ScheduledThreadPoolExecutor(1);
private volatile ScheduledFuture currentlyScheduledClockTask = null; private volatile ScheduledFuture<?> currentlyScheduledClockTask = null;
/** /**
* Method runs cyclic notification about time progress for TCP logic class * Method runs cyclic notification about time progress for TCP logic class
@ -755,7 +755,7 @@ class PseudoTcpSocketImpl
private void cancelClockTask(boolean interruptIfRunning) private void cancelClockTask(boolean interruptIfRunning)
{ {
// Copy the reference, in case it changes. // Copy the reference, in case it changes.
ScheduledFuture taskToCancel = this.currentlyScheduledClockTask; ScheduledFuture<?> taskToCancel = this.currentlyScheduledClockTask;
if(taskToCancel != null) if(taskToCancel != null)
{ {
taskToCancel.cancel(interruptIfRunning); taskToCancel.cancel(interruptIfRunning);

View File

@ -84,17 +84,25 @@ class Connector
this.errorHandler = errorHandler; this.errorHandler = errorHandler;
Transport transport Transport transport
= socket.getUDPSocket() != null ? Transport.UDP : Transport.TCP; = socket.getUDPSocket() != null ? Transport.UDP : Transport.TCP;
this.listenAddress
= new TransportAddress(socket.getLocalAddress(), listenAddress
socket.getLocalPort(), = new TransportAddress(socket.getLocalAddress(),
transport); socket.getLocalPort(),
this.remoteAddress transport);
= transport == Transport.UDP if (transport == Transport.UDP)
? null {
: new TransportAddress(socket.getTCPSocket().getInetAddress(), remoteAddress = null;
socket.getTCPSocket().getPort(), }
else
{
Socket tcpSocket = socket.getTCPSocket();
remoteAddress
= new TransportAddress(tcpSocket.getInetAddress(),
tcpSocket.getPort(),
transport); transport);
}
} }
/** /**
@ -103,7 +111,9 @@ class Connector
void start() void start()
{ {
this.running = true; this.running = true;
Thread thread = new Thread(this, "IceConnector@"+hashCode());
Thread thread = new Thread(this, "IceConnector@" + hashCode());
thread.setDaemon(true); thread.setDaemon(true);
thread.start(); thread.start();
} }
@ -122,6 +132,7 @@ class Connector
/** /**
* The listening thread's run method. * The listening thread's run method.
*/ */
@Override
public void run() public void run()
{ {
DatagramPacket packet = null; DatagramPacket packet = null;
@ -281,8 +292,8 @@ class Connector
void sendMessage(byte[] message, TransportAddress address) void sendMessage(byte[] message, TransportAddress address)
throws IOException throws IOException
{ {
DatagramPacket datagramPacket = new DatagramPacket( DatagramPacket datagramPacket
message, 0, message.length, address); = new DatagramPacket(message, 0, message.length, address);
sock.send(datagramPacket); sock.send(datagramPacket);
} }

View File

@ -7,6 +7,7 @@
package org.ice4j.stack; package org.ice4j.stack;
import java.io.*; import java.io.*;
import java.net.*;
import java.util.*; import java.util.*;
import java.util.logging.*; import java.util.logging.*;
@ -292,7 +293,7 @@ class NetAccessManager
if (!netUDPAccessPoints.containsKey(localAddr)) if (!netUDPAccessPoints.containsKey(localAddr))
{ {
Connector connector Connector connector
= new Connector(socket, messageQueue, this); = new Connector(socket, messageQueue, this);
netUDPAccessPoints.put(localAddr, connector); netUDPAccessPoints.put(localAddr, connector);
connector.start(); connector.start();
@ -301,23 +302,25 @@ class NetAccessManager
case TCP: case TCP:
List<Connector> connectors = netTCPAccessPoints.get(localAddr); List<Connector> connectors = netTCPAccessPoints.get(localAddr);
if (connectors == null) if (connectors == null)
{ {
connectors = new LinkedList<Connector>(); connectors = new LinkedList<Connector>();
netTCPAccessPoints.put(localAddr, connectors); netTCPAccessPoints.put(localAddr, connectors);
} }
Socket tcpSocket = socket.getTCPSocket();
Connector connector Connector connector
= findTCPConnectorByRemoteAddress( = findTCPConnectorByRemoteAddress(
connectors, connectors,
new TransportAddress( new TransportAddress(
socket.getTCPSocket().getInetAddress(), tcpSocket.getInetAddress(),
socket.getTCPSocket().getPort(), tcpSocket.getPort(),
Transport.TCP)); Transport.TCP));
if (connector == null) if (connector == null)
{ {
connector = new Connector(socket, messageQueue, this); connector = new Connector(socket, messageQueue, this);
connectors.add(connector); connectors.add(connector);
connector.start(); connector.start();
} }
@ -373,6 +376,7 @@ class NetAccessManager
case TCP: case TCP:
List<Connector> connectors = netTCPAccessPoints.remove(src); List<Connector> connectors = netTCPAccessPoints.remove(src);
if (connectors != null) if (connectors != null)
{ {
connector connector
@ -418,9 +422,10 @@ class NetAccessManager
throws IllegalArgumentException throws IllegalArgumentException
{ {
if(threadPoolSize < 1) if(threadPoolSize < 1)
{
throw new IllegalArgumentException( throw new IllegalArgumentException(
threadPoolSize threadPoolSize + " is not a legal thread pool size value.");
+ " is not a legal thread pool size value."); }
//if we are not running just record the size //if we are not running just record the size
//so that we could init later. //so that we could init later.
@ -442,8 +447,8 @@ class NetAccessManager
*/ */
private void initThreadPool() private void initThreadPool()
{ {
//create additional processors //create additional processors
fillUpThreadPool(initialThreadPoolSize); fillUpThreadPool(initialThreadPoolSize);
} }
/** /**
@ -499,10 +504,9 @@ class NetAccessManager
return netUDPAccessPoints.get(src); return netUDPAccessPoints.get(src);
case TCP: case TCP:
List<Connector> connectors = netTCPAccessPoints.get(src); List<Connector> connectors = netTCPAccessPoints.get(src);
if (connectors != null) if (connectors != null)
{
return findTCPConnectorByRemoteAddress(connectors, dst); return findTCPConnectorByRemoteAddress(connectors, dst);
}
} }
} }
@ -532,10 +536,12 @@ class NetAccessManager
byte[] bytes = stunMessage.encode(stunStack); byte[] bytes = stunMessage.encode(stunStack);
Connector ap = getConnector(srcAddr, remoteAddr); Connector ap = getConnector(srcAddr, remoteAddr);
if (ap == null) if (ap == null)
{ {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"No socket has been added for: " + srcAddr + " <-> " + remoteAddr); "No socket has been added for: " + srcAddr + " <-> "
+ remoteAddr);
} }
ap.sendMessage(bytes, remoteAddr); ap.sendMessage(bytes, remoteAddr);
@ -564,6 +570,7 @@ class NetAccessManager
byte[] bytes = channelData.encode(); byte[] bytes = channelData.encode();
Connector ap = getConnector(srcAddr, remoteAddr); Connector ap = getConnector(srcAddr, remoteAddr);
if (ap == null) if (ap == null)
{ {
throw new IllegalArgumentException( throw new IllegalArgumentException(
@ -594,11 +601,13 @@ class NetAccessManager
IOException, StunException IOException, StunException
{ {
Connector ap = getConnector(srcAddr, remoteAddr); Connector ap = getConnector(srcAddr, remoteAddr);
if (ap == null) if (ap == null)
{ {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"No socket has been added for source address: " + srcAddr); "No socket has been added for source address: " + srcAddr);
} }
ap.sendMessage(bytes, remoteAddr); ap.sendMessage(bytes, remoteAddr);
} }
} }

View File

@ -20,22 +20,22 @@ public class RawMessage
/** /**
* The message itself. * The message itself.
*/ */
private byte[] messageBytes = null; private final byte[] messageBytes;
/** /**
* The length of the message. * The length of the message.
*/ */
private int messageLength = -1; private final int messageLength;
/** /**
* The address and port where the message was sent from. * The address and port where the message was sent from.
*/ */
private TransportAddress remoteAddress = null; private final TransportAddress remoteAddress;
/** /**
* The address that this message was received on. * The address that this message was received on.
*/ */
private TransportAddress localAddress = null; private final TransportAddress localAddress;
/** /**
* Constructs a raw message with the specified field values. All parameters * Constructs a raw message with the specified field values. All parameters