feat: Adds checkstyle module. (#233)

* feat: Adds checkstyle module.
This commit is contained in:
Дамян Минков 2021-09-02 12:54:33 -05:00 committed by GitHub
parent adca67b17f
commit 9dc08bd299
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
82 changed files with 570 additions and 494 deletions

40
checkstyle.xml Normal file
View File

@ -0,0 +1,40 @@
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
"https://checkstyle.org/dtds/configuration_1_3.dtd">
<module name="Checker">
<module name="SuppressWithPlainTextCommentFilter"/>
<module name="LineLength">
<property name="fileExtensions" value="java"/>
<property name="max" value="120"/>
<property name="ignorePattern" value="http://|https://"/>
</module>
<module name="TreeWalker">
<module name="LeftCurly">
<property name="option" value="nl"/>
<property name="tokens" value="LITERAL_CATCH"/>
<property name="tokens" value="LITERAL_ELSE"/>
<property name="tokens" value="LITERAL_FINALLY"/>
<property name="tokens" value="LITERAL_IF"/>
<property name="tokens" value="LITERAL_TRY"/>
</module>
<!-- Skips empty blocks {}, to not skip them: value="alone" -->
<module name="RightCurly">
<property name="option" value="alone_or_singleline"/>
</module>
<module name="WhitespaceAfter">
<!-- Drops TYPECAST from default tokens -->
<property name="tokens" value="COMMA , SEMI , LITERAL_IF , LITERAL_ELSE , LITERAL_WHILE , LITERAL_DO , LITERAL_FOR , DO_WHILE"/>
</module>
</module>
<module name="FileTabCharacter">
<property name="eachLine" value="true"/>
</module>
</module>

15
pom.xml
View File

@ -191,6 +191,21 @@
</compilerArgs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<configLocation>checkstyle.xml</configLocation>
</configuration>
<executions>
<execution>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.github.gantsign.maven</groupId>
<artifactId>ktlint-maven-plugin</artifactId>

View File

@ -99,22 +99,22 @@ public enum Transport
public static Transport parse(String transportName)
throws IllegalArgumentException
{
if(UDP.toString().equals(transportName))
if (UDP.toString().equals(transportName))
return UDP;
if(TCP.toString().equals(transportName))
if (TCP.toString().equals(transportName))
return TCP;
if(TLS.toString().equals(transportName))
if (TLS.toString().equals(transportName))
return TLS;
if(SCTP.toString().equals(transportName))
if (SCTP.toString().equals(transportName))
return SCTP;
if(DTLS.toString().equals(transportName))
if (DTLS.toString().equals(transportName))
return DTLS;
if(SSLTCP.toString().equals(transportName))
if (SSLTCP.toString().equals(transportName))
return SSLTCP;
throw new IllegalArgumentException(

View File

@ -148,14 +148,14 @@ public class TransportAddress
public String toString()
{
String hostAddress = getHostAddress();
if(hostAddress == null)
if (hostAddress == null)
{
hostAddress = getHostName();
}
StringBuilder bldr = new StringBuilder(hostAddress);
if(isIPv6())
if (isIPv6())
bldr.insert(0, "[").append("]");
bldr.append(":").append(getPort());
@ -175,7 +175,7 @@ public class TransportAddress
String addressStr
= addr != null ? addr.getHostAddress() : null;
if(addr instanceof Inet6Address)
if (addr instanceof Inet6Address)
addressStr = NetworkUtils.stripScopeID(addressStr);
return addressStr;
@ -258,7 +258,7 @@ public class TransportAddress
*/
public boolean canReach(TransportAddress dst)
{
if( getTransport() != dst.getTransport() )
if ( getTransport() != dst.getTransport() )
return false;
if (isIPv6() != dst.isIPv6())
@ -269,7 +269,7 @@ public class TransportAddress
Inet6Address srcAddr = (Inet6Address)getAddress();
Inet6Address dstAddr = (Inet6Address)dst.getAddress();
if(srcAddr.isLinkLocalAddress() != dstAddr.isLinkLocalAddress())
if (srcAddr.isLinkLocalAddress() != dstAddr.isLinkLocalAddress())
{
//this one may actually work if for example we are contacting
//the public address of someone in our local network. however

View File

@ -176,7 +176,7 @@ abstract class AddressAttribute extends Attribute
return false;
//addresses
if( att.getAddress() == null && getAddress() == null)
if ( att.getAddress() == null && getAddress() == null)
return true;
return true;
@ -221,10 +221,12 @@ abstract class AddressAttribute extends Attribute
binValue[7] = (byte)(getPort() & 0x00FF);
//address
if(getFamily() == ADDRESS_FAMILY_IPV6){
if (getFamily() == ADDRESS_FAMILY_IPV6)
{
System.arraycopy(getAddressBytes(), 0, binValue, 8, 16);
}
else{
else
{
System.arraycopy(getAddressBytes(), 0, binValue, 8, 4);
}
@ -307,7 +309,7 @@ abstract class AddressAttribute extends Attribute
//address
byte address[] = null;
if(family == ADDRESS_FAMILY_IPV6)
if (family == ADDRESS_FAMILY_IPV6)
{
address = new byte[16];
}

View File

@ -47,7 +47,7 @@ public class AttributeDecoder
int length)
throws StunException
{
if(bytes == null || bytes.length < Attribute.HEADER_LENGTH)
if (bytes == null || bytes.length < Attribute.HEADER_LENGTH)
{
throw new StunException( StunException.ILLEGAL_ARGUMENT,
"Could not decode the specified binary array.");
@ -59,7 +59,7 @@ public class AttributeDecoder
char attributeLength = (char)
(((bytes[offset + 2] & 0xFF) << 8) | (bytes[offset + 3] & 0xFF));
if(attributeLength > bytes.length - offset )
if (attributeLength > bytes.length - offset )
throw new StunException( StunException.ILLEGAL_ARGUMENT,
"Could not decode the specified binary array.");

View File

@ -628,7 +628,7 @@ public class AttributeFactory
= new RequestedAddressFamilyAttribute();
boolean isSet = attribute.setFamily(family);
if(!isSet)
if (!isSet)
{
attribute = null;
}

View File

@ -137,7 +137,7 @@ public class ChannelNumberAttribute extends Attribute
void decodeAttributeBody(byte[] attributeValue, char offset, char length)
throws StunException
{
if(length != 4)
if (length != 4)
{
throw new StunException("length invalid");
}
@ -172,7 +172,7 @@ public class ChannelNumberAttribute extends Attribute
*/
public static boolean isValidRange(char channelNo)
{
if(channelNo >= 0x4000)
if (channelNo >= 0x4000)
{
return true;
}

View File

@ -137,7 +137,7 @@ public class ConnectionIdAttribute
void decodeAttributeBody(byte[] attributeValue, char offset, char length)
throws StunException
{
if(length != DATA_LENGTH)
if (length != DATA_LENGTH)
{
throw new StunException("length invalid: " + length);
}

View File

@ -112,7 +112,7 @@ public class DontFragmentAttribute extends Attribute
void decodeAttributeBody(byte[] attributeValue, char offset, char length)
throws StunException
{
if(length != 0)
if (length != 0)
{
throw new StunException("length invalid");
}

View File

@ -288,7 +288,7 @@ public class ErrorCodeAttribute extends Attribute
public void setErrorClass(byte errorClass)
throws IllegalArgumentException
{
if(errorClass < 0 || errorClass > 99)
if (errorClass < 0 || errorClass > 99)
throw new IllegalArgumentException(
errorClass + " is not a valid error number!");
this.errorClass = errorClass;
@ -415,7 +415,7 @@ public class ErrorCodeAttribute extends Attribute
*/
public String getReasonPhrase()
{
if(reasonPhrase == null)
if (reasonPhrase == null)
return null;
return new String(reasonPhrase);
@ -472,7 +472,7 @@ public class ErrorCodeAttribute extends Attribute
binValue[6] = getErrorClass();
binValue[7] = getErrorNumber();
if(reasonPhrase != null)
if (reasonPhrase != null)
System.arraycopy(reasonPhrase, 0, binValue, 8, reasonPhrase.length);
return binValue;

View File

@ -132,7 +132,7 @@ public class EvenPortAttribute extends Attribute
void decodeAttributeBody(byte[] attributeValue, char offset, char length)
throws StunException
{
if(length != 4)
if (length != 4)
{
throw new StunException("length invalid");
}

View File

@ -212,7 +212,7 @@ public class FingerprintAttribute
char length)
throws StunException
{
if(length != 4)
if (length != 4)
{
throw new StunException("length invalid");
}

View File

@ -125,14 +125,14 @@ public abstract class IceControlAttribute
*/
public boolean equals(Object obj)
{
if(!(obj instanceof IceControlAttribute))
if (!(obj instanceof IceControlAttribute))
return false;
if(obj == this)
if (obj == this)
return true;
IceControlAttribute iceControlAtt = (IceControlAttribute)obj;
if(iceControlAtt.getAttributeType() != getAttributeType()
if (iceControlAtt.getAttributeType() != getAttributeType()
|| iceControlAtt.isControlling != isControlling
|| iceControlAtt.getDataLength() != DATA_LENGTH_ICE_CONTROL
|| getTieBreaker() != iceControlAtt.getTieBreaker())

View File

@ -138,7 +138,7 @@ public class LifetimeAttribute
void decodeAttributeBody(byte[] attributeValue, char offset, char length)
throws StunException
{
if(length != 4)
if (length != 4)
{
throw new StunException("length invalid");
}

View File

@ -138,7 +138,7 @@ public class MagicCookieAttribute
void decodeAttributeBody(byte[] attributeValue, char offset, char length)
throws StunException
{
if(length != 4)
if (length != 4)
{
throw new StunException("length invalid");
}

View File

@ -134,7 +134,7 @@ public class OptionalAttribute
*/
public boolean equals(Object obj)
{
if(! (obj instanceof OptionalAttribute) )
if (! (obj instanceof OptionalAttribute) )
return false;
return

View File

@ -174,7 +174,7 @@ public class PriorityAttribute
throws IllegalArgumentException
{
/* Priority must be between 1 and (2^31 - 1) */
if(priority <= 0 || priority > 0x7FFFFFFFL)
if (priority <= 0 || priority > 0x7FFFFFFFL)
{
throw new IllegalArgumentException("Priority must be " +
"between 0 and (2**31 - 1)");

View File

@ -144,14 +144,14 @@ public class RequestedAddressFamilyAttribute extends Attribute
void decodeAttributeBody(byte[] attributeValue, char offset, char length)
throws StunException
{
if(length != DATA_LENGTH)
if (length != DATA_LENGTH)
{
throw new StunException("length invalid: " + length);
}
family = (char)(attributeValue[offset] & 0xff);
if(family != IPv4 && family != IPv6)
if (family != IPv4 && family != IPv6)
{
// instead throw TurnException
throw new StunException("invalid family value: " + family);
@ -174,7 +174,7 @@ public class RequestedAddressFamilyAttribute extends Attribute
*/
public boolean setFamily(char family)
{
if(family == IPv4 || family == IPv6)
if (family == IPv4 || family == IPv6)
{
this.family = family;
return true;

View File

@ -147,7 +147,7 @@ public class RequestedTransportAttribute extends Attribute
void decodeAttributeBody(byte[] attributeValue, char offset, char length)
throws StunException
{
if(length != 4)
if (length != 4)
{
throw new StunException("length invalid");
}

View File

@ -75,7 +75,7 @@ public class ReservationTokenAttribute
void decodeAttributeBody(byte[] attributeValue, char offset, char length)
throws StunException
{
if(length != 8)
if (length != 8)
{
throw new StunException("Length mismatch!");
}
@ -189,12 +189,12 @@ public class ReservationTokenAttribute
private static void generateReservationTokenAttribute(
ReservationTokenAttribute token, int nb)
{
long left = System.currentTimeMillis();// the first nb/2 bytes of the
long left = System.currentTimeMillis(); // the first nb/2 bytes of the
// token
long right = random.nextLong();// the last nb/2 bytes of the token
long right = random.nextLong(); // the last nb/2 bytes of the token
int b = nb / 2;
for(int i = 0; i < b; i++)
for (int i = 0; i < b; i++)
{
token.reservationToken[i] = (byte)((left >> (i * 8)) & 0xFFL);
token.reservationToken[i + b] = (byte)((right >> (i * 8)) & 0xFFL);

View File

@ -84,7 +84,7 @@ public class UnknownAttributesAttribute extends Attribute
{
char len = (char)unknownAttributes.size();
if( (len % 2 ) != 0 )
if ( (len % 2 ) != 0 )
len++;
return (char)(len * 2);
@ -99,7 +99,7 @@ public class UnknownAttributesAttribute extends Attribute
{
//some attributes may be repeated for padding
//(packet length should be divisable by 4)
if(!contains(attributeID))
if (!contains(attributeID))
unknownAttributes.add(attributeID);
}
@ -172,7 +172,7 @@ public class UnknownAttributesAttribute extends Attribute
// If the number of unknown attributes is an odd number, one of the
// attributes MUST be repeated in the list, so that the total length of
// the list is a multiple of 4 bytes.
if(offset < binValue.length)
if (offset < binValue.length)
{
char att = getAttribute(0);
binValue[offset++] = (byte) (att >> 8);
@ -221,12 +221,12 @@ public class UnknownAttributesAttribute extends Attribute
void decodeAttributeBody(byte[] attributeValue, char offset, char length)
throws StunException
{
if( (length % 2 ) != 0)
if ( (length % 2 ) != 0)
throw new StunException("Attribute IDs are 2 bytes long and the "
+ "passed binary array has an odd length " +
"value.");
char originalOffset = offset;
for(int i = offset; i < originalOffset + length; i += 2)
for (int i = offset; i < originalOffset + length; i += 2)
{
char attributeID = (char) (((attributeValue[offset++] & 0xFF) << 8)
| (attributeValue[offset++] & 0xFF));

View File

@ -89,14 +89,14 @@ public class UseCandidateAttribute
*/
public boolean equals(Object obj)
{
if(!(obj instanceof UseCandidateAttribute))
if (!(obj instanceof UseCandidateAttribute))
return false;
if(obj == this)
if (obj == this)
return true;
UseCandidateAttribute useCandidateAtt = (UseCandidateAttribute)obj;
if(useCandidateAtt.getAttributeType() != getAttributeType()
if (useCandidateAtt.getAttributeType() != getAttributeType()
|| useCandidateAtt.getDataLength() != getDataLength())
return false;

View File

@ -102,7 +102,7 @@ public class XorMappedAddressAttribute
port ^= portModifier;
for(int i = 0; i < addressBytes.length; i++)
for (int i = 0; i < addressBytes.length; i++)
addressBytes[i] ^= transactionID[i];
TransportAddress xoredAdd;

View File

@ -438,17 +438,17 @@ public abstract class Candidate<T extends Candidate<?>>
/* Google Talk priority is in range 0 - 1, we multiply this by 1000
* to have a long rather than float
*/
if(candidateType == CandidateType.HOST_CANDIDATE)
if (candidateType == CandidateType.HOST_CANDIDATE)
{
priority += 0.95 * 1000 -
(this.getBase().getTransport() == Transport.TCP ? 200 : 0);
}
else if(candidateType == CandidateType.PEER_REFLEXIVE_CANDIDATE)
else if (candidateType == CandidateType.PEER_REFLEXIVE_CANDIDATE)
{
priority += (long)(0.9 * 1000) -
(this.getBase().getTransport() == Transport.TCP ? 200 : 0);
}
else if(candidateType == CandidateType.SERVER_REFLEXIVE_CANDIDATE)
else if (candidateType == CandidateType.SERVER_REFLEXIVE_CANDIDATE)
{
priority += (long)(0.9 * 1000);
}
@ -462,9 +462,9 @@ public abstract class Candidate<T extends Candidate<?>>
InetAddress addr = getTransportAddress().getAddress();
// IPv6 has better priority than IPv4
if(addr instanceof Inet6Address)
if (addr instanceof Inet6Address)
{
if(addr.isLinkLocalAddress())
if (addr.isLinkLocalAddress())
{
priority += 40;
}
@ -499,15 +499,15 @@ public abstract class Candidate<T extends Candidate<?>>
{
int typePreference;
if(candidateType == CandidateType.HOST_CANDIDATE)
if (candidateType == CandidateType.HOST_CANDIDATE)
{
typePreference = MAX_TYPE_PREFERENCE; // 126
}
else if(candidateType == CandidateType.PEER_REFLEXIVE_CANDIDATE)
else if (candidateType == CandidateType.PEER_REFLEXIVE_CANDIDATE)
{
typePreference = 110;
}
else if(candidateType == CandidateType.SERVER_REFLEXIVE_CANDIDATE)
else if (candidateType == CandidateType.SERVER_REFLEXIVE_CANDIDATE)
{
typePreference = 100;
}
@ -540,13 +540,13 @@ public abstract class Candidate<T extends Candidate<?>>
{
//The ICE spec says: When there is only a single IP address, this value
//SHOULD be set to.
if(getParentComponent().countLocalHostCandidates() < 2)
if (getParentComponent().countLocalHostCandidates() < 2)
return MAX_LOCAL_PREFERENCE;
//The ICE spec also says: Furthermore, if an agent is multi-homed and
//has multiple IP addresses, the local preference for host candidates
//from a VPN interface SHOULD have a priority of 0.
if(isVirtual())
if (isVirtual())
return MIN_LOCAL_PREFERENCE;
InetAddress addr = getTransportAddress().getAddress();
@ -556,10 +556,10 @@ public abstract class Candidate<T extends Candidate<?>>
//Johnnie seems to think.
//prefer IPv6 to IPv4
if(addr instanceof Inet6Address)
if (addr instanceof Inet6Address)
{
//prefer link local addresses to global ones
if(addr.isLinkLocalAddress())
if (addr.isLinkLocalAddress())
return 30;
else
return 40;
@ -719,7 +719,7 @@ public abstract class Candidate<T extends Candidate<?>>
*/
public TransportAddress getRelatedAddress()
{
if(getRelatedCandidate() != null)
if (getRelatedCandidate() != null)
{
return getRelatedCandidate().getTransportAddress();
}
@ -770,7 +770,7 @@ public abstract class Candidate<T extends Candidate<?>>
TransportAddress relAddr = getRelatedAddress();
if(relAddr != null)
if (relAddr != null)
{
buff.append(" raddr ").append(relAddr.getHostAddress());
buff.append(" rport ").append(relAddr.getPort());
@ -873,19 +873,19 @@ public abstract class Candidate<T extends Candidate<?>>
switch (getType())
{
case SERVER_REFLEXIVE_CANDIDATE:
if(getBase() != null)
if (getBase() != null)
{
return getBase().getHostAddress();
}
break;
case PEER_REFLEXIVE_CANDIDATE:
if(getBase() != null)
if (getBase() != null)
{
return getBase().getHostAddress();
}
break;
case RELAYED_CANDIDATE:
if(getRelatedCandidate() != null)
if (getRelatedCandidate() != null)
{
return getRelatedCandidate().getHostAddress();
}
@ -912,7 +912,7 @@ public abstract class Candidate<T extends Candidate<?>>
return getTransportAddress();
case RELAYED_CANDIDATE:
// Corresponding to getMappedAddress();
if(getRelatedCandidate() != null)
if (getRelatedCandidate() != null)
{
return getRelatedCandidate().getReflexiveAddress();
}
@ -965,19 +965,19 @@ public abstract class Candidate<T extends Candidate<?>>
*/
public T getRelatedCandidate()
{
if(this.relatedCandidate == null)
if (this.relatedCandidate == null)
{
TransportAddress relatedAddress = null;
switch (getType())
{
case SERVER_REFLEXIVE_CANDIDATE:
if(getBase() != null)
if (getBase() != null)
{
relatedAddress = getBase().getTransportAddress();
}
break;
case PEER_REFLEXIVE_CANDIDATE:
if(getBase() != null)
if (getBase() != null)
{
relatedAddress = getBase().getTransportAddress();
}

View File

@ -122,25 +122,25 @@ public enum CandidateExtendedType
public static CandidateExtendedType parse(String extendedTypeName)
throws IllegalArgumentException
{
if(HOST_CANDIDATE.toString().equals(extendedTypeName))
if (HOST_CANDIDATE.toString().equals(extendedTypeName))
return HOST_CANDIDATE;
else if(UPNP_CANDIDATE.toString().equals(extendedTypeName))
else if (UPNP_CANDIDATE.toString().equals(extendedTypeName))
return UPNP_CANDIDATE;
else if(STUN_PEER_REFLEXIVE_CANDIDATE.toString().equals(
else if (STUN_PEER_REFLEXIVE_CANDIDATE.toString().equals(
extendedTypeName))
return STUN_PEER_REFLEXIVE_CANDIDATE;
else if(STUN_SERVER_REFLEXIVE_CANDIDATE.toString().equals(
else if (STUN_SERVER_REFLEXIVE_CANDIDATE.toString().equals(
extendedTypeName))
return STUN_SERVER_REFLEXIVE_CANDIDATE;
else if(TURN_RELAYED_CANDIDATE.toString().equals(extendedTypeName))
else if (TURN_RELAYED_CANDIDATE.toString().equals(extendedTypeName))
return TURN_RELAYED_CANDIDATE;
else if(GOOGLE_TURN_RELAYED_CANDIDATE.toString().equals(
else if (GOOGLE_TURN_RELAYED_CANDIDATE.toString().equals(
extendedTypeName))
return GOOGLE_TURN_RELAYED_CANDIDATE;
else if(GOOGLE_TCP_TURN_RELAYED_CANDIDATE.toString().equals(
else if (GOOGLE_TCP_TURN_RELAYED_CANDIDATE.toString().equals(
extendedTypeName))
return GOOGLE_TCP_TURN_RELAYED_CANDIDATE;
else if(JINGLE_NODE_CANDIDATE.toString().equals(extendedTypeName))
else if (JINGLE_NODE_CANDIDATE.toString().equals(extendedTypeName))
return JINGLE_NODE_CANDIDATE;
throw new IllegalArgumentException(

View File

@ -123,23 +123,23 @@ public enum CandidateType
public static CandidateType parse(String candidateTypeName)
throws IllegalArgumentException
{
if(PEER_REFLEXIVE_CANDIDATE.toString().equals(candidateTypeName))
if (PEER_REFLEXIVE_CANDIDATE.toString().equals(candidateTypeName))
return PEER_REFLEXIVE_CANDIDATE;
if(SERVER_REFLEXIVE_CANDIDATE.toString().equals(candidateTypeName))
if (SERVER_REFLEXIVE_CANDIDATE.toString().equals(candidateTypeName))
return SERVER_REFLEXIVE_CANDIDATE;
if(RELAYED_CANDIDATE.toString().equals(candidateTypeName))
if (RELAYED_CANDIDATE.toString().equals(candidateTypeName))
return RELAYED_CANDIDATE;
if(HOST_CANDIDATE.toString().equals(candidateTypeName))
if (HOST_CANDIDATE.toString().equals(candidateTypeName))
return HOST_CANDIDATE;
// old name but returns the standard name
if(STUN_CANDIDATE.toString().equals(candidateTypeName))
if (STUN_CANDIDATE.toString().equals(candidateTypeName))
return SERVER_REFLEXIVE_CANDIDATE;
if(LOCAL_CANDIDATE.toString().equals(candidateTypeName))
if (LOCAL_CANDIDATE.toString().equals(candidateTypeName))
return HOST_CANDIDATE;
throw new IllegalArgumentException(

View File

@ -135,7 +135,7 @@ public class CheckList
{
synchronized(triggeredCheckQueue)
{
if(!triggeredCheckQueue.contains(pair))
if (!triggeredCheckQueue.contains(pair))
{
triggeredCheckQueue.add(pair);
pair.setStateWaiting();
@ -154,7 +154,7 @@ public class CheckList
{
synchronized(triggeredCheckQueue)
{
if(triggeredCheckQueue.size() > 0)
if (triggeredCheckQueue.size() > 0)
return triggeredCheckQueue.remove(0);
}
return null;
@ -182,7 +182,7 @@ public class CheckList
{
if (pair.getState() == CandidatePairState.WAITING)
{
if(highestPriorityPair == null
if (highestPriorityPair == null
|| pair.getPriority() > highestPriorityPair.getPriority())
{
highestPriorityPair = pair;
@ -190,14 +190,14 @@ public class CheckList
}
}
if(highestPriorityPair != null)
if (highestPriorityPair != null)
return highestPriorityPair;
for (CandidatePair pair : this)
{
if (pair.getState() == CandidatePairState.FROZEN)
{
if(highestPriorityPair == null
if (highestPriorityPair == null
|| pair.getPriority() > highestPriorityPair.getPriority())
{
highestPriorityPair = pair;
@ -319,14 +319,14 @@ public class CheckList
Map<String, CandidatePair> pairsToWait = new Hashtable<>();
//first, determine the pairs that we'd need to put in the waiting state.
for(CandidatePair pair : this)
for (CandidatePair pair : this)
{
//we need to check whether the pair is already in the wait list. if
//so we'll compare it with this one and determine which of the two
//needs to stay.
CandidatePair prevPair = pairsToWait.get(pair.getFoundation());
if(prevPair == null)
if (prevPair == null)
{
//first pair with this foundation.
pairsToWait.put(pair.getFoundation(), pair);
@ -336,9 +336,9 @@ public class CheckList
//we already have a pair with the same foundation. determine which
//of the two has the lower component id and higher priority and
//keep that one in the list.
if( prevPair.getParentComponent() == pair.getParentComponent())
if ( prevPair.getParentComponent() == pair.getParentComponent())
{
if(pair.getPriority() > prevPair.getPriority())
if (pair.getPriority() > prevPair.getPriority())
{
//need to replace the pair in the list.
pairsToWait.put(pair.getFoundation(), pair);
@ -346,7 +346,7 @@ public class CheckList
}
else
{
if(pair.getParentComponent().getComponentID()
if (pair.getParentComponent().getComponentID()
< prevPair.getParentComponent().getComponentID())
{
//need to replace the pair in the list.
@ -368,7 +368,7 @@ public class CheckList
protected synchronized void recomputePairPriorities()
{
//first, determine the pairs that we'd need to put in the waiting state.
for(CandidatePair pair : this)
for (CandidatePair pair : this)
pair.computePriority();
}
@ -398,7 +398,7 @@ public class CheckList
{
Component cmp = nominatedPair.getParentComponent();
if(cmp.getSelectedPair() != null)
if (cmp.getSelectedPair() != null)
{
return;
}
@ -410,7 +410,7 @@ public class CheckList
cmp.setSelectedPair(nominatedPair);
Iterator<CandidatePair> pairsIter = iterator();
while(pairsIter.hasNext())
while (pairsIter.hasNext())
{
CandidatePair pair = pairsIter.next();
if (pair.getParentComponent() == cmp
@ -427,7 +427,7 @@ public class CheckList
{
Iterator<CandidatePair> triggeredPairsIter
= triggeredCheckQueue.iterator();
while(triggeredPairsIter.hasNext())
while (triggeredPairsIter.hasNext())
{
CandidatePair pair = triggeredPairsIter.next();
if (pair.getParentComponent() == cmp
@ -493,7 +493,7 @@ public class CheckList
{
synchronized(stateListeners)
{
if(!stateListeners.contains(l))
if (!stateListeners.contains(l))
this.stateListeners.add(l);
}
}
@ -532,7 +532,7 @@ public class CheckList
PropertyChangeEvent evt = new PropertyChangeEvent(
this, PROPERTY_CHECK_LIST_STATE, oldState, newState);
for(PropertyChangeListener l : listenersCopy)
for (PropertyChangeListener l : listenersCopy)
{
l.propertyChange(evt);
}
@ -548,7 +548,7 @@ public class CheckList
{
synchronized(checkListeners)
{
if(!checkListeners.contains(l))
if (!checkListeners.contains(l))
{
checkListeners.add(l);
}
@ -564,7 +564,7 @@ public class CheckList
{
synchronized(checkListeners)
{
if(checkListeners.contains(l))
if (checkListeners.contains(l))
{
checkListeners.remove(l);
}
@ -587,7 +587,7 @@ public class CheckList
PropertyChangeEvent evt = new PropertyChangeEvent(
this, PROPERTY_CHECK_LIST_CHECKS, false, true);
for(PropertyChangeListener l : listenersCopy)
for (PropertyChangeListener l : listenersCopy)
{
l.propertyChange(evt);
}

View File

@ -468,15 +468,18 @@ public class Component
* since those candidates aren't added to the candidate list even
* though the pair is added to the check list).
*/
CandidatePair existingPair = streamCheckList.findPairMatching(pair.getLocalCandidate(), pair.getRemoteCandidate());
if (existingPair != null) {
CandidatePair existingPair
= streamCheckList.findPairMatching(pair.getLocalCandidate(), pair.getRemoteCandidate());
if (existingPair != null)
{
logger.info("existing Pair updated: " +
existingPair.toShortString() +
" to " + pair.toShortString() + ".");
existingPair.setRemoteCandidate(pair.getRemoteCandidate());
existingPair.computePriority();
}
else {
else
{
streamCheckList.add(pair);
logger.info("new Pair added: " + pair.toShortString()
+ ".");

View File

@ -124,14 +124,14 @@ class ConnectivityCheckServer
UsernameAttribute uname = (UsernameAttribute)request
.getAttribute(Attribute.USERNAME);
if( uname == null
if ( uname == null
|| !checkLocalUserName(new String(uname.getUsername())))
{
return;
}
//detect role conflicts
if( ( parentAgent.isControlling()
if ( ( parentAgent.isControlling()
&& request.containsAttribute(Attribute.ICE_CONTROLLING))
|| ( ! parentAgent.isControlling()
&& request.containsAttribute(Attribute.ICE_CONTROLLED)))
@ -214,7 +214,7 @@ class ConnectivityCheckServer
//apply tie-breaking
//extract priority
if(priorityAttr == null)
if (priorityAttr == null)
{
logger.debug(() -> "Received a connectivity check with"
+ "no PRIORITY attribute. Discarding.");
@ -255,7 +255,8 @@ class ConnectivityCheckServer
final boolean bothControlledConflict = !selfIceControlling &&
req.containsAttribute(Attribute.ICE_CONTROLLED);
if (!(bothControllingConflict || bothControlledConflict)) {
if (!(bothControllingConflict || bothControlledConflict))
{
// we don't have a role conflict
return true;
}
@ -379,7 +380,7 @@ class ConnectivityCheckServer
public byte[] getRemoteKey(String username, String media)
{
IceMediaStream stream = parentAgent.getStream(media);
if(stream == null)
if (stream == null)
{
return null;
}
@ -399,7 +400,7 @@ class ConnectivityCheckServer
//caller gave us the entire username.
if (username.equals(parentAgent.generateLocalUserName(media)))
{
if(stream.getRemotePassword() != null)
if (stream.getRemotePassword() != null)
return stream.getRemotePassword().getBytes();
}
}

View File

@ -83,7 +83,7 @@ public class FoundationsRegistry
StringBuffer foundationStringBuff = new StringBuffer(type);
foundationStringBuff.append(base);
if(server != null)
if (server != null)
foundationStringBuff.append(server);
foundationStringBuff.append(transport);
@ -97,7 +97,7 @@ public class FoundationsRegistry
//obtain a new foundation number if we don't have one for this kind
//of candidates.
if(foundationValue == null)
if (foundationValue == null)
{
foundationValue = Integer.toString(++lastAssignedFoundation);
foundations.put(foundationString, foundationValue);

View File

@ -103,7 +103,7 @@ public class GoogleRelayedCandidate
turnCandidateHarvest.hostCandidate.getParentComponent()
.findLocalCandidate(mappedAddress));
if(transportAddress.getTransport() == Transport.TCP)
if (transportAddress.getTransport() == Transport.TCP)
{
super.setExtendedType(
CandidateExtendedType.GOOGLE_TCP_TURN_RELAYED_CANDIDATE);
@ -200,13 +200,13 @@ public class GoogleRelayedCandidate
{
try
{
if(getTransport() == Transport.UDP)
if (getTransport() == Transport.UDP)
{
socket
= new IceUdpSocketWrapper(new MultiplexingDatagramSocket(
getRelayedCandidateDatagramSocket()));
}
else if(getTransport() == Transport.TCP)
else if (getTransport() == Transport.TCP)
{
final Socket s = getRelayedCandidateSocket();
socket = new IceTcpSocketWrapper(new MultiplexingSocket(s));

View File

@ -374,7 +374,7 @@ public class IceMediaStream
*/
protected void createCheckList(List<CandidatePair> checkList)
{
for(Component cmp : getComponents())
for (Component cmp : getComponents())
createCheckList(cmp, checkList);
}
@ -393,22 +393,22 @@ public class IceMediaStream
List<RemoteCandidate> remoteCnds = component.getRemoteCandidates();
LocalCandidate upnpBase = null;
for(LocalCandidate lc : localCnds)
for (LocalCandidate lc : localCnds)
{
// XXX do we assume a single UPNPCandidate here?
if(lc instanceof UPNPCandidate)
if (lc instanceof UPNPCandidate)
upnpBase = lc.getBase();
}
for(LocalCandidate localCnd : localCnds)
for (LocalCandidate localCnd : localCnds)
{
// Don't take into consideration UPnP base candidate
if(localCnd == upnpBase)
if (localCnd == upnpBase)
continue;
for(RemoteCandidate remoteCnd : remoteCnds)
for (RemoteCandidate remoteCnd : remoteCnds)
{
if(localCnd.canReach(remoteCnd)
if (localCnd.canReach(remoteCnd)
&& remoteCnd.getTransportAddress().getPort() != 0)
{
CandidatePair pair
@ -454,12 +454,12 @@ public class IceMediaStream
Iterator<CandidatePair> ckListIter = checkList.iterator();
while(ckListIter.hasNext())
while (ckListIter.hasNext())
{
CandidatePair pair = ckListIter.next();
//drop all pairs above MAX_CHECK_LIST_SIZE.
if(tmpCheckList.size() > maxCheckListSize)
if (tmpCheckList.size() > maxCheckListSize)
{
ckListIter.remove();
continue;
@ -467,14 +467,14 @@ public class IceMediaStream
//replace local server reflexive candidates with their base.
LocalCandidate localCnd = pair.getLocalCandidate();
if( localCnd.getType()
if ( localCnd.getType()
== CandidateType.SERVER_REFLEXIVE_CANDIDATE)
{
pair.setLocalCandidate(localCnd.getBase());
//if the new pair corresponds to another one with a higher
//priority, then remove it.
if(tmpCheckList.contains(pair))
if (tmpCheckList.contains(pair))
{
ckListIter.remove();
continue;
@ -550,11 +550,11 @@ public class IceMediaStream
*/
public RemoteCandidate findRemoteCandidate(TransportAddress remoteAddress)
{
for( Component cmp : components.values())
for ( Component cmp : components.values())
{
RemoteCandidate cnd = cmp.findRemoteCandidate(remoteAddress);
if(cnd != null)
if (cnd != null)
return cnd;
}

View File

@ -614,13 +614,13 @@ public class NetworkUtils
return IN4_ADDR_ANY;
}
while(ifaces.hasMoreElements())
while (ifaces.hasMoreElements())
{
Enumeration<InetAddress> addrs
= ifaces.nextElement().getInetAddresses();
while (addrs.hasMoreElements())
{
if(addrs.nextElement() instanceof Inet6Address)
if (addrs.nextElement() instanceof Inet6Address)
return IN6_ADDR_ANY;
}
}
@ -752,7 +752,7 @@ public class NetworkUtils
//in case this was an IPv6 literal and we remove the closing bracket,
//put it back in now.
if(ipv6Address.charAt(0) == '['
if (ipv6Address.charAt(0) == '['
&& ipv6Address.charAt(ipv6Address.length()-1) != ']')
{
ipv6Address += ']';

View File

@ -123,7 +123,7 @@ public class ServerReflexiveCandidate
{
super.free();
if(stunHarvest != null)
if (stunHarvest != null)
stunHarvest.close();
}
}

View File

@ -80,7 +80,7 @@ public class UPNPCandidate
}
IceSocketWrapper socket = getCandidateIceSocketWrapper();
if(socket != null)
if (socket != null)
{
socket.close();
}

View File

@ -91,7 +91,7 @@ public abstract class AbstractTcpListener
Enumeration<InetAddress> ifaceAddresses = iface.getInetAddresses();
while(ifaceAddresses.hasMoreElements())
while (ifaceAddresses.hasMoreElements())
{
InetAddress addr = ifaceAddresses.nextElement();
@ -956,7 +956,7 @@ public abstract class AbstractTcpListener
bytesRead, 2, bytesRead.length);
// if we had read enough data
if(channel.length <= bytesRead.length - 2)
if (channel.length <= bytesRead.length - 2)
{
processFirstDatagram(
preBuffered, channel, key);
@ -991,7 +991,7 @@ public abstract class AbstractTcpListener
channel.buffer.flip();
channel.buffer.get(bytesRead);
if(channel.preBuffered != null)
if (channel.preBuffered != null)
{
// will store preBuffered and currently read data
byte[] newBytesRead = new byte[

View File

@ -96,7 +96,7 @@ class CandidateHarvesterSetElement
{
setEnabled(false);
}
else if(trickleCallback != null)
else if (trickleCallback != null)
{
trickleCallback.onIceCandidates(candidates);
}

View File

@ -105,7 +105,7 @@ public class GoogleTurnCandidateHarvest
Attribute attribute
= response.getAttribute(Attribute.MAPPED_ADDRESS);
if(attribute != null)
if (attribute != null)
{
TransportAddress relayedAddress
= ((MappedAddressAttribute) attribute).getAddress();

View File

@ -279,7 +279,7 @@ public class GoogleTurnSSLCandidateHarvester
outputStream = null;
inputStream = null;
if(Arrays.equals(data, SSL_SERVER_HANDSHAKE))
if (Arrays.equals(data, SSL_SERVER_HANDSHAKE))
{
return true;
}

View File

@ -75,7 +75,7 @@ public class HarvestStatistics
protected void stopHarvestTiming(Collection<LocalCandidate> harvest)
{
//count total candidates
if(harvest != null)
if (harvest != null)
stopHarvestTiming(harvest.size());
else
stopHarvestTiming(0);
@ -108,13 +108,13 @@ public class HarvestStatistics
*/
public long getHarvestDuration()
{
if(this.lastStartHarvestingTime != -1)
if (this.lastStartHarvestingTime != -1)
{
long currentHarvestingTime
= System.currentTimeMillis() - lastStartHarvestingTime;
// Retest here, while the harvesting may be end while computing the
// harvesting time.
if(this.lastStartHarvestingTime != -1)
if (this.lastStartHarvestingTime != -1)
{
return this.lastHarvestingTime + currentHarvestingTime;
}

View File

@ -304,7 +304,7 @@ public class HostCandidateHarvester
Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces();
if(transport != Transport.UDP && transport != Transport.TCP)
if (transport != Transport.UDP && transport != Transport.TCP)
{
throw new IllegalArgumentException("Transport protocol not supported: " + transport);
}
@ -327,7 +327,7 @@ public class HostCandidateHarvester
Enumeration<InetAddress> addresses = iface.getInetAddresses();
while(addresses.hasMoreElements())
while (addresses.hasMoreElements())
{
InetAddress addr = addresses.nextElement();
@ -342,19 +342,19 @@ public class HostCandidateHarvester
}
foundAtLeastOneUsableAddress = true;
if((addr instanceof Inet4Address) || !config.useIpv6())
if ((addr instanceof Inet4Address) || !config.useIpv6())
{
IceSocketWrapper sock = null;
try
{
if(transport == Transport.UDP)
if (transport == Transport.UDP)
{
sock = createDatagramSocket(addr, preferredPort, minPort, maxPort);
boundAtLeastOneSocket = true;
}
else if(transport == Transport.TCP)
else if (transport == Transport.TCP)
{
if(addr instanceof Inet6Address)
if (addr instanceof Inet6Address)
continue;
sock = createServerSocket(
addr,
@ -564,7 +564,7 @@ public class HostCandidateHarvester
new DelegatingServerSocket(sock),
component);
if(logger.isLoggable(Level.FINEST))
if (logger.isLoggable(Level.FINEST))
{
logger.log(
Level.FINEST,
@ -647,7 +647,7 @@ public class HostCandidateHarvester
= new IceUdpSocketWrapper(new
MultiplexingDatagramSocket(port, laddr));
if(logger.isLoggable(Level.FINEST))
if (logger.isLoggable(Level.FINEST))
{
logger.log(
Level.FINEST,

View File

@ -196,7 +196,8 @@ public class MappingCandidateHarvesters
for (MappingCandidateHarvester h : harvesters)
{
if (face.getAddress().equals(h.getFace().getAddress()) && mask.getAddress().equals(h.getMask().getAddress()))
if (face.getAddress().equals(h.getFace().getAddress())
&& mask.getAddress().equals(h.getMask().getAddress()))
{
logger.info("Discarding a mapping harvester with duplicate "
+ "addresses: " + harvester + ". Kept: " + h);

View File

@ -547,7 +547,7 @@ public class StunCandidateHarvest
Attribute attribute
= response.getAttribute(Attribute.XOR_MAPPED_ADDRESS);
if(attribute instanceof XorMappedAddressAttribute)
if (attribute instanceof XorMappedAddressAttribute)
{
return
((XorMappedAddressAttribute) attribute)
@ -558,7 +558,7 @@ public class StunCandidateHarvest
attribute
= response.getAttribute(Attribute.MAPPED_ADDRESS);
if(attribute instanceof MappedAddressAttribute)
if (attribute instanceof MappedAddressAttribute)
{
return
((MappedAddressAttribute) attribute)

View File

@ -111,9 +111,9 @@ public class StunCandidateHarvester
this.shortTermCredentialUsername = shortTermCredentialUsername;
//these should be configurable.
if(System.getProperty(StackProperties.MAX_CTRAN_RETRANS_TIMER) == null)
if (System.getProperty(StackProperties.MAX_CTRAN_RETRANS_TIMER) == null)
System.setProperty(StackProperties.MAX_CTRAN_RETRANS_TIMER, "400");
if(System.getProperty(StackProperties.MAX_CTRAN_RETRANSMISSIONS) == null)
if (System.getProperty(StackProperties.MAX_CTRAN_RETRANSMISSIONS) == null)
System.setProperty(StackProperties.MAX_CTRAN_RETRANSMISSIONS, "3");
}
@ -150,7 +150,7 @@ public class StunCandidateHarvester
synchronized(startedHarvests)
{
if(doNotify)
if (doNotify)
startedHarvests.notify();
}
}
@ -290,7 +290,7 @@ public class StunCandidateHarvester
private String listCandidates(Collection<? extends Candidate<?>> candidates)
{
StringBuilder retval = new StringBuilder();
for(Candidate<?> candidate : candidates)
for (Candidate<?> candidate : candidates)
{
retval.append(candidate.toShortString());
}
@ -313,7 +313,7 @@ public class StunCandidateHarvester
HostCandidate cand = getHostCandidate(hostCand);
if(cand == null)
if (cand == null)
{
logger.info(
"server/candidate address type mismatch,"

View File

@ -93,10 +93,10 @@ public class UPNPHarvester
logger.fine("Begin UPnP harvesting");
try
{
if(device == null)
if (device == null)
{
// do it only once
if(finishThreads == 0)
if (finishThreads == 0)
{
try
{
@ -108,17 +108,17 @@ public class UPNPHarvester
synchronized(rootSync)
{
while(finishThreads != 2)
while (finishThreads != 2)
{
rootSync.wait();
}
}
if(wanIPThread.getDevice() != null)
if (wanIPThread.getDevice() != null)
{
device = wanIPThread.getDevice();
}
else if(wanPPPThread.getDevice() != null)
else if (wanPPPThread.getDevice() != null)
{
device = wanPPPThread.getDevice();
}
@ -130,7 +130,7 @@ public class UPNPHarvester
}
}
if(device == null)
if (device == null)
return candidates;
}
@ -143,12 +143,12 @@ public class UPNPHarvester
int port = socket.getLocalPort();
int externalPort = socket.getLocalPort();
while(retries < MAX_RETRIES)
while (retries < MAX_RETRIES)
{
if(!device.getSpecificPortMappingEntry(port, "UDP",
if (!device.getSpecificPortMappingEntry(port, "UDP",
portMapping))
{
if(device.addPortMapping(
if (device.addPortMapping(
externalPort,
port,
localAddress.getHostAddress(),
@ -165,11 +165,11 @@ public class UPNPHarvester
// if we don't add the base, we won't be able to add
// peer reflexive candidate if someone contact us on the
// UPNPCandidate
for(LocalCandidate cand : cands)
for (LocalCandidate cand : cands)
{
//try to add the candidate to the component and then
//only add it to the harvest not redundant
if(component.addLocalCandidate(cand))
if (component.addLocalCandidate(cand))
{
candidates.add(cand);
}
@ -280,7 +280,7 @@ public class UPNPHarvester
gd.discover();
if(gd.getValidGateway() != null)
if (gd.getValidGateway() != null)
{
device = gd.getValidGateway();
}
@ -294,7 +294,7 @@ public class UPNPHarvester
* a method, it is important that it be rethrown so that the
* thread actually dies.
*/
if(e instanceof ThreadDeath)
if (e instanceof ThreadDeath)
throw (ThreadDeath)e;
}
finally

View File

@ -151,15 +151,15 @@ public class IceSdpUtils
Component firstComponent = null;
//add candidates
for(Component component : iceMediaStream.getComponents())
for (Component component : iceMediaStream.getComponents())
{
//if this is the first component, remember it so that we can
//later use it for default candidates.
if(firstComponent == null)
if (firstComponent == null)
firstComponent = component;
Vector attributes = mediaDescription.getAttributes(true);
for(Candidate<?> candidate : component.getLocalCandidates())
for (Candidate<?> candidate : component.getLocalCandidates())
{
attributes.add(new CandidateAttribute(candidate));
}
@ -184,12 +184,12 @@ public class IceSdpUtils
Component rtcpComponent
= iceMediaStream.getComponent(Component.RTCP);
if( rtcpComponent != null )
if ( rtcpComponent != null )
{
TransportAddress defaultRtcpCandidate = rtcpComponent
.getDefaultCandidate().getTransportAddress();
if(defaultRtcpCandidate.getPort() != defaultAddress.getPort()+1)
if (defaultRtcpCandidate.getPort() != defaultAddress.getPort()+1)
{
mediaDescription.setAttribute(
RTCP, Integer.toString(defaultRtcpCandidate.getPort()));
@ -255,7 +255,7 @@ public class IceSdpUtils
//origin
Origin o = sDes.getOrigin();
if( o == null || "user".equals(o.getUsername()))
if ( o == null || "user".equals(o.getUsername()))
{
//looks like there wasn't any origin set: jain-sdp creates a
//default origin that has "user" as the user name so we use this
@ -277,7 +277,7 @@ public class IceSdpUtils
List<IceMediaStream> streams = agent.getStreams();
Vector<MediaDescription> mDescs
= new Vector<>(agent.getStreamCount());
for(IceMediaStream stream : streams)
for (IceMediaStream stream : streams)
{
MediaDescription mLine = sdpFactory.createMediaDescription(
stream.getName(), 0, //default port comes later
@ -320,7 +320,7 @@ public class IceSdpUtils
{
List<Attribute> trickleUpdate = null;
if(localCandidates == null || localCandidates.size() == 0)
if (localCandidates == null || localCandidates.size() == 0)
{
trickleUpdate = new ArrayList<>(1);
trickleUpdate.add(
@ -333,7 +333,7 @@ public class IceSdpUtils
String streamName = null;
for(LocalCandidate candidate : localCandidates)
for (LocalCandidate candidate : localCandidates)
{
streamName = candidate.getParentComponent()
.getParentStream().getName();

View File

@ -106,7 +106,7 @@ public class ChannelData
*/
public char getDataLength()
{
if(data == null)
if (data == null)
return 0;
return (char)data.length;
@ -159,7 +159,7 @@ public class ChannelData
byte binMsg[] = new byte[HEADER_LENGTH + dataLength];
int offset = 0;
if(!validateChannelNumber(channelNumber))
if (!validateChannelNumber(channelNumber))
{
throw new StunException(StunException.ILLEGAL_ARGUMENT, "Channel number invalid");
}
@ -172,7 +172,7 @@ public class ChannelData
binMsg[offset++] = (byte)((data != null) ? data.length >> 8 : 0);
binMsg[offset++] = (byte)((data != null) ? data.length & 0xff : 0);
if(data != null)
if (data != null)
{
System.arraycopy(data, 0, binMsg, offset, data.length);
}
@ -210,14 +210,14 @@ public class ChannelData
ChannelData channelData = null;
byte data[] = null;
if((binMessage.length - offset) < HEADER_LENGTH)
if ((binMessage.length - offset) < HEADER_LENGTH)
{
throw new StunException(StunException.ILLEGAL_ARGUMENT, "Size too short");
}
channelNumber = (char)((binMessage[offset++]<<8) | (binMessage[offset++]&0xFF));
if(!validateChannelNumber(channelNumber))
if (!validateChannelNumber(channelNumber))
{
throw new StunException(StunException.ILLEGAL_ARGUMENT, "Channel number invalid");
}

View File

@ -50,7 +50,7 @@ public class Indication
/* old TURN DATA indication type is an indication despite
* 0x0115 & 0x0110 indicates STUN error response type
*/
if(!isIndicationType(indicationType) &&
if (!isIndicationType(indicationType) &&
indicationType != OLD_DATA_INDICATION)
throw new IllegalArgumentException(
(int)(indicationType)

View File

@ -469,6 +469,7 @@ public abstract class Message
/* Old TURN attributes */
protected static final byte DESTINATION_ADDRESS_PRESENTITY_INDEX = 29;
// CHECKSTYLE:OFF
protected final static byte attributePresentities[][] = new byte[][]{
// Binding Shared Shared Shared Alloc Alloc Rfrsh Rfrsh ChnlBnd ChnlBnd Send Data
// Binding Binding Error Secret Secret Secret Req. Resp. Req. Resp. Req. Resp. Indic. Indic.
@ -509,6 +510,7 @@ public abstract class Message
/*USE-CANDIDATE*/ { O, N_A, N_A, N_A, N_A, N_A, N_A, N_A, N_A, N_A, N_A, N_A, N_A, N_A},
/*DESTINATION-ADDRESS*/{N_A, N_A, N_A, N_A, N_A, N_A, N_A, N_A, O, N_A, N_A, N_A, M, N_A},
};
// CHECKSTYLE:ON
/**
* Creates an empty STUN Message.
@ -687,7 +689,7 @@ public abstract class Message
public void setTransactionID(byte[] tranID)
throws StunException
{
if(tranID == null
if (tranID == null
|| (tranID.length != TRANSACTION_ID_LENGTH &&
tranID.length != RFC3489_TRANSACTION_ID_LENGTH))
throw new StunException(StunException.ILLEGAL_ARGUMENT,
@ -721,7 +723,7 @@ public abstract class Message
*/
protected byte getAttributePresentity(char attributeType)
{
if(!rfc3489CompatibilityMode)
if (!rfc3489CompatibilityMode)
return O;
byte msgIndex = -1;
@ -872,22 +874,22 @@ public abstract class Message
@Override
public boolean equals(Object obj)
{
if(!(obj instanceof Message))
if (!(obj instanceof Message))
return false;
if(obj == this)
if (obj == this)
return true;
Message msg = (Message) obj;
if( msg.getMessageType() != getMessageType())
if ( msg.getMessageType() != getMessageType())
return false;
if(msg.getDataLength() != getDataLength())
if (msg.getDataLength() != getDataLength())
return false;
//compare attributes
for (Attribute localAtt : attributes.values())
{
if(!localAtt.equals(msg.getAttribute(localAtt.getAttributeType())))
if (!localAtt.equals(msg.getAttribute(localAtt.getAttributeType())))
return false;
}
@ -930,7 +932,7 @@ public abstract class Message
byte tranID[] = getTransactionID();
if(tranID.length == 12)
if (tranID.length == 12)
{
System.arraycopy(MAGIC_COOKIE, 0, binMsg, offset, 4);
offset += 4;
@ -1063,7 +1065,7 @@ public abstract class Message
int originalOffset = offset;
arrayLen = Math.min(binMessage.length, arrayLen);
if(arrayLen - offset < Message.HEADER_LENGTH)
if (arrayLen - offset < Message.HEADER_LENGTH)
{
throw new StunException( StunException.ILLEGAL_ARGUMENT,
"The given binary array is not a valid StunMessage");
@ -1077,7 +1079,7 @@ public abstract class Message
if (Message.isResponseType(messageType) &&
messageType != OLD_DATA_INDICATION)
message = new Response();
else if(Message.isRequestType(messageType))
else if (Message.isRequestType(messageType))
message = new Request();
else /* indication */
message = new Indication();
@ -1094,12 +1096,12 @@ public abstract class Message
boolean rfc3489Compat = false;
if(!Arrays.equals(MAGIC_COOKIE, cookie))
if (!Arrays.equals(MAGIC_COOKIE, cookie))
{
rfc3489Compat = true;
}
if(arrayLen - offset - TRANSACTION_ID_LENGTH < length)
if (arrayLen - offset - TRANSACTION_ID_LENGTH < length)
{
throw
new StunException(
@ -1117,7 +1119,7 @@ public abstract class Message
System.arraycopy(binMessage, offset, tranID, 0, TRANSACTION_ID_LENGTH);
try
{
if(rfc3489Compat)
if (rfc3489Compat)
{
byte[] rfc3489TranID = new byte[TRANSACTION_ID_LENGTH + 4];
System.arraycopy(cookie, 0, rfc3489TranID, 0, 4);
@ -1139,7 +1141,7 @@ public abstract class Message
offset += TRANSACTION_ID_LENGTH;
while(offset - Message.HEADER_LENGTH < length)
while (offset - Message.HEADER_LENGTH < length)
{
Attribute att = AttributeDecoder.decode(
binMessage, offset, (char)(length - offset));
@ -1152,7 +1154,7 @@ public abstract class Message
//now also skip any potential padding that might have come with
//this attribute.
if((att.getDataLength() % 4) > 0)
if ((att.getDataLength() % 4) > 0)
{
offset += (4 - (att.getDataLength() % 4));
}
@ -1249,11 +1251,11 @@ public abstract class Message
protected void validateAttributePresentity()
throws IllegalStateException
{
if(! rfc3489CompatibilityMode )
if (! rfc3489CompatibilityMode )
return;
for(char i = Attribute.MAPPED_ADDRESS; i < Attribute.REFLECTED_FROM;i++)
if(getAttributePresentity(i) == M && getAttribute(i) == null)
for (char i = Attribute.MAPPED_ADDRESS; i < Attribute.REFLECTED_FROM; i++)
if (getAttributePresentity(i) == M && getAttribute(i) == null)
throw new IllegalStateException(
"A mandatory attribute (type=" + (int)i + ") is missing!");
}

View File

@ -54,7 +54,8 @@ public class MessageFactory
try
{
bindingRequest.setMessageType(Message.BINDING_REQUEST);
} catch (IllegalArgumentException ex)
}
catch (IllegalArgumentException ex)
{
// there should be no exc here since we're the creators.
logger.log(Level.FINE, "Failed to set message type.", ex);
@ -122,7 +123,8 @@ public class MessageFactory
IceControllingAttribute iceControllingAttribute = AttributeFactory
.createIceControllingAttribute(tieBreaker);
bindingRequest.putAttribute(iceControllingAttribute);
} else
}
else
{
IceControlledAttribute iceControlledAttribute = AttributeFactory
.createIceControlledAttribute(tieBreaker);
@ -356,7 +358,8 @@ public class MessageFactory
try
{
allocateRequest.setMessageType(Message.ALLOCATE_REQUEST);
} catch (IllegalArgumentException ex)
}
catch (IllegalArgumentException ex)
{
// there should be no exc here since we're the creators.
logger.log(Level.FINE, "Failed to set message type.", ex);
@ -429,7 +432,7 @@ public class MessageFactory
throws IllegalArgumentException
{
return createAllocationResponse(
request, mappedAddress, relayedAddress, null ,lifetime);
request, mappedAddress, relayedAddress, null , lifetime);
}
/**
@ -484,7 +487,7 @@ public class MessageFactory
allocationSuccessResponse.putAttribute(lifetimeAttribute);
if(token != null)
if (token != null)
{
//reservation token
ReservationTokenAttribute reservationTokenAttribute
@ -508,7 +511,7 @@ public class MessageFactory
*/
public static Response createAllocationErrorResponse(char errorCode)
{
return createAllocationErrorResponse(errorCode,null);
return createAllocationErrorResponse(errorCode, null);
}
/**
@ -669,7 +672,8 @@ public class MessageFactory
LifetimeAttribute lifetimeReq = AttributeFactory
.createLifetimeAttribute(lifetime);
refreshRequest.putAttribute(lifetimeReq);
} catch (IllegalArgumentException ex)
}
catch (IllegalArgumentException ex)
{
logger.log(Level.FINE, "Failed to set message type.", ex);
}
@ -826,7 +830,7 @@ public class MessageFactory
ErrorCodeAttribute errorCodeAttribute
= AttributeFactory
.createErrorCodeAttribute(errorCode,reasonPhrase);
.createErrorCodeAttribute(errorCode, reasonPhrase);
channelBindErrorResponse.putAttribute(errorCodeAttribute);
@ -912,7 +916,7 @@ public class MessageFactory
ErrorCodeAttribute errorCodeAttribute
= AttributeFactory
.createErrorCodeAttribute(
errorCode,reasonPhrase);
errorCode, reasonPhrase);
createPermissionErrorResponse.putAttribute(errorCodeAttribute);
@ -949,7 +953,8 @@ public class MessageFactory
.createDataAttribute(data);
sendIndication.putAttribute(dataAttribute);
}
} catch (IllegalArgumentException ex)
}
catch (IllegalArgumentException ex)
{
logger.log(Level.FINE, "Failed to set message type.", ex);
}
@ -1270,7 +1275,7 @@ public class MessageFactory
public static Response createConnectionBindErrorResponse(char errorCode)
throws IllegalArgumentException
{
return createConnectionBindErrorResponse(errorCode,null);
return createConnectionBindErrorResponse(errorCode, null);
}
/**

View File

@ -44,7 +44,7 @@ public class Request extends Message
public void setMessageType(char requestType)
throws IllegalArgumentException
{
if(!isRequestType(requestType))
if (!isRequestType(requestType))
throw new IllegalArgumentException(
(int)(requestType)
+ " - is not a valid request type.");

View File

@ -68,7 +68,7 @@ public class Response
public void setMessageType(char responseType)
throws IllegalArgumentException
{
if(!isResponseType(responseType))
if (!isResponseType(responseType))
throw new IllegalArgumentException(
Integer.toString(responseType)
+ " is not a valid response type.");

View File

@ -445,7 +445,8 @@ public class PseudoTCPBase
long nInFlight = m_snd_nxt - m_snd_una;
m_ssthresh = Math.max(nInFlight / 2, 2 * m_mss);
//Logger.Log(LS_INFO) << "m_ssthresh: " << m_ssthresh << " nInFlight: " << nInFlight << " m_mss: " << m_mss;
//Logger.Log(LS_INFO)
// << "m_ssthresh: " << m_ssthresh << " nInFlight: " << nInFlight << " m_mss: " << m_mss;
m_cwnd = m_mss;
// Back off retransmit timer. Note: the limit is lower when connecting.
@ -914,7 +915,7 @@ public class PseudoTCPBase
public static String segToStr(Segment seg)
{
String data="data: ";
for(byte b : seg.data)
for (byte b : seg.data)
{
data += b;
}
@ -1064,7 +1065,7 @@ public class PseudoTCPBase
bConnect = true;
// TCP options are in the remainder of the payload after CTL_CONNECT.
if(!parseOptions(seg.data, 1, seg.len - 1))
if (!parseOptions(seg.data, 1, seg.len - 1))
{
return false;
}
@ -1252,7 +1253,8 @@ public class PseudoTCPBase
m_recover = m_snd_nxt;
long nInFlight = m_snd_nxt - m_snd_una;
m_ssthresh = Math.max(nInFlight / 2, 2 * m_mss);
//Logger.Log(LS_INFO) << "m_ssthresh: " << m_ssthresh << " nInFlight: " << nInFlight << " m_mss: " << m_mss;
//Logger.Log(LS_INFO)
// << "m_ssthresh: " << m_ssthresh << " nInFlight: " << nInFlight << " m_mss: " << m_mss;
m_cwnd = m_ssthresh + 3 * m_mss;
}
else
@ -2123,7 +2125,7 @@ public class PseudoTCPBase
void setConversationID(long convID)
{
if(m_state != PseudoTcpState.TCP_LISTEN)
if (m_state != PseudoTcpState.TCP_LISTEN)
throw new IllegalStateException();
this.m_conv = convID;
}

View File

@ -250,9 +250,9 @@ class PseudoTcpSocketImpl
public void bind(InetAddress host, int port)
throws IOException
{
if(socket != null)
if (socket != null)
socket.close();
InetSocketAddress newAddr = new InetSocketAddress(host.getHostAddress(),port);
InetSocketAddress newAddr = new InetSocketAddress(host.getHostAddress(), port);
this.socket = new DatagramSocket(newAddr);
}
@ -282,14 +282,14 @@ class PseudoTcpSocketImpl
throws SocketException
{
//TODO: map options to PTCP options/method calls
if(optID == SocketOptions.TCP_NODELAY)
if (optID == SocketOptions.TCP_NODELAY)
{
Object ret = options.get(Option.OPT_NODELAY.ordinal());
return ret != null;
}
Object option = options.get(optID);
if(option == null)
if (option == null)
{
logger.warning("Asked for unknown optID" + optID);
}
@ -298,11 +298,11 @@ class PseudoTcpSocketImpl
public long getPTCPOption(Option opt)
{
if(Option.OPT_READ_TIMEOUT == opt)
if (Option.OPT_READ_TIMEOUT == opt)
{
return this.readTimeout;
}
else if(Option.OPT_WRITE_TIMEOUT == opt)
else if (Option.OPT_WRITE_TIMEOUT == opt)
{
return this.writeTimeout;
}
@ -314,11 +314,11 @@ class PseudoTcpSocketImpl
public void setPTCPOption(Option opt, long optValue)
{
if(Option.OPT_WRITE_TIMEOUT == opt)
if (Option.OPT_WRITE_TIMEOUT == opt)
{
this.writeTimeout = optValue >= 0 ? optValue : 0;
}
else if(Option.OPT_READ_TIMEOUT == opt)
else if (Option.OPT_READ_TIMEOUT == opt)
{
this.readTimeout = optValue >= 0 ? optValue : 0;
}
@ -503,7 +503,7 @@ class PseudoTcpSocketImpl
*/
public void onTcpReadable(PseudoTCPBase tcp)
{
if(logger.isLoggable(Level.FINER))
if (logger.isLoggable(Level.FINER))
{
logger.log(
Level.FINER,
@ -709,7 +709,7 @@ class PseudoTcpSocketImpl
*/
private void runClock()
{
if(!runClock)
if (!runClock)
{
return;
}
@ -753,7 +753,7 @@ class PseudoTcpSocketImpl
{
// Cancel any existing tasks, to make sure we don't run duplicates.
cancelClockTask(false);
if(runClock)
if (runClock)
{
currentlyScheduledClockTask
= clockExecutor.schedule(
@ -766,7 +766,7 @@ class PseudoTcpSocketImpl
{
// Copy the reference, in case it changes.
ScheduledFuture<?> taskToCancel = this.currentlyScheduledClockTask;
if(taskToCancel != null)
if (taskToCancel != null)
{
taskToCancel.cancel(interruptIfRunning);
}
@ -926,12 +926,12 @@ class PseudoTcpSocketImpl
return read;
}
logger.log(Level.FINER, "Read wait for data available");
if(readTimeout > 0)
if (readTimeout > 0)
{
//Check for timeout
long elapsed = System.currentTimeMillis() - start;
long left = readTimeout - elapsed;
if(left <= 0)
if (left <= 0)
{
IOException exc =
new IOException("Read operation timeout");
@ -940,7 +940,7 @@ class PseudoTcpSocketImpl
}
synchronized (read_notify)
{
if(pseudoTcp.getAvailable() == 0)
if (pseudoTcp.getAvailable() == 0)
{
read_notify.wait(left);
}
@ -950,7 +950,7 @@ class PseudoTcpSocketImpl
{
synchronized (read_notify)
{
if(pseudoTcp.getAvailable() == 0)
if (pseudoTcp.getAvailable() == 0)
{
read_notify.wait();
}
@ -1071,11 +1071,11 @@ class PseudoTcpSocketImpl
logger.log(Level.FINER, "Write wait for notify");
synchronized (write_notify)
{
if(writeTimeout > 0)
if (writeTimeout > 0)
{
long elapsed = System.currentTimeMillis() - start;
long left = writeTimeout - elapsed;
if(left <= 0)
if (left <= 0)
{
IOException exc =
new IOException("Write operation timeout");
@ -1129,12 +1129,12 @@ class PseudoTcpSocketImpl
{
try
{
if(writeTimeout > 0)
if (writeTimeout > 0)
{
//Check write timeout
long elapsed = System.currentTimeMillis() - start;
long left = writeTimeout - elapsed;
if(left <= 0)
if (left <= 0)
{
IOException e =
new IOException("Flush operation timeout");

View File

@ -26,23 +26,23 @@ public enum PseudoTcpState
/**
* Initial state, can accept connection
*/
TCP_LISTEN,// = 0,
TCP_LISTEN, // = 0,
/**
* SYN sent to remote peer, wits for SYN
*/
TCP_SYN_SENT,// = 1,
TCP_SYN_SENT, // = 1,
/**
* SYN received from remote peer, sends back SYN
*/
TCP_SYN_RECEIVED,// = 2;
TCP_SYN_RECEIVED, // = 2;
/**
* SYN sent and received - connection established
*/
TCP_ESTABLISHED,// = 3;
TCP_ESTABLISHED, // = 3;
/**
* Closed state. In current implementation reached on error
* or explicite by close method with force option
* TODO: closing procedure
*/
TCP_CLOSED// = 4;
TCP_CLOSED // = 4;
}

View File

@ -225,7 +225,7 @@ public class DelegatingDatagramSocket
// Delegates the DatagramSocket functionality to the DatagramSocket
// given in parameter.
if(delegate != null)
if (delegate != null)
{
this.delegate = delegate;
}
@ -233,7 +233,7 @@ public class DelegatingDatagramSocket
{
// Creates a custom DatagramSocket to replace classical "java"
// DatagramSocket and set it as a delegate Socket
if(delegateFactory != null)
if (delegateFactory != null)
{
this.delegate = delegateFactory.createUnboundDatagramSocket();
}
@ -741,7 +741,7 @@ public class DelegatingDatagramSocket
catch(Exception ex)
{
InetAddress tmpAddr = p.getAddress();
if(((ex instanceof NoRouteToHostException)
if (((ex instanceof NoRouteToHostException)
|| (ex.getMessage() != null
&& ex.getMessage().equals("No route to host")))
&& (tmpAddr instanceof Inet6Address)
@ -755,8 +755,9 @@ public class DelegatingDatagramSocket
p.setAddress(newAddr);
super.send(p);
} else if (ex instanceof IOException) {
}
else if (ex instanceof IOException)
{
throw((IOException)ex);
}
}
@ -940,7 +941,7 @@ public class DelegatingDatagramSocket
throws SocketException
{
// Only change the buffer size on the real underlying DatagramSocket.
if(delegate == null && defaultReceiveBufferSize > 0)
if (delegate == null && defaultReceiveBufferSize > 0)
{
super.setReceiveBufferSize(defaultReceiveBufferSize);
}

View File

@ -796,7 +796,7 @@ public class DelegatingSocket
*/
public void setOriginalInputStream(InputStream inputStream)
{
if(this.inputStream == null && inputStream != null)
if (this.inputStream == null && inputStream != null)
this.inputStream = inputStream;
}

View File

@ -250,12 +250,12 @@ public class GoogleRelayedCandidateSocket
public OutputStream getOutputStream()
throws IOException
{
if(outputStream == null)
if (outputStream == null)
{
CandidatePair pair =
relayedCandidate.getParentComponent().getSelectedPair();
if(pair.getLocalCandidate() == relayedCandidate)
if (pair.getLocalCandidate() == relayedCandidate)
{
TransportAddress target = pair.getRemoteCandidate().
getTransportAddress();

View File

@ -107,7 +107,7 @@ public class IceTcpServerSocketWrapper
{
isRun = false;
serverSocket.close();
for(Socket s : sockets)
for (Socket s : sockets)
{
s.close();
}
@ -150,7 +150,7 @@ public class IceTcpServerSocketWrapper
@Override
public Socket getTCPSocket()
{
if(sockets.size() > 0)
if (sockets.size() > 0)
{
return sockets.get(0);
}
@ -182,13 +182,13 @@ public class IceTcpServerSocketWrapper
{
isRun = true;
while(isRun)
while (isRun)
{
try
{
Socket tcpSocket = serverSocket.accept();
if(tcpSocket != null)
if (tcpSocket != null)
{
MultiplexingSocket multiplexingSocket =
new MultiplexingSocket(tcpSocket);

View File

@ -276,7 +276,7 @@ public class MultiplexedSocket
public void reset()
throws IOException
{
if(!markSupported())
if (!markSupported())
{
throw new IOException(
"InputStreamImpl does not support reset()");

View File

@ -159,7 +159,7 @@ public class MuxServerSocketChannelFactory
* @throws IOException if an I/O error occurs
*/
public static ServerSocketChannel openAndBindMuxServerSocketChannel(
Map<String,Object> properties,
Map<String, Object> properties,
SocketAddress endpoint,
int backlog,
DatagramPacketFilter filter)
@ -225,7 +225,7 @@ public class MuxServerSocketChannelFactory
* @throws IOException if an I/O error occurs
*/
public static ServerSocketChannel openAndBindServerSocketChannel(
Map<String,Object> properties,
Map<String, Object> properties,
SocketAddress endpoint,
int backlog)
throws IOException
@ -236,7 +236,7 @@ public class MuxServerSocketChannelFactory
if (properties != null && !properties.isEmpty())
{
for (Map.Entry<String,Object> property
for (Map.Entry<String, Object> property
: properties.entrySet())
{
String name = property.getKey();

View File

@ -184,11 +184,11 @@ public class StunDatagramPacketFilter
// All STUN messages MUST start with a 20-byte header followed by zero
// or more Attributes.
if(length >= 20)
if (length >= 20)
{
// If the MAGIC COOKIE is present this is a STUN packet (RFC5389
// compliant).
if(data[offset + 4] == Message.MAGIC_COOKIE[0]
if (data[offset + 4] == Message.MAGIC_COOKIE[0]
&& data[offset + 5] == Message.MAGIC_COOKIE[1]
&& data[offset + 6] == Message.MAGIC_COOKIE[2]
&& data[offset + 7] == Message.MAGIC_COOKIE[3])

View File

@ -54,7 +54,7 @@ public class MuxServerSocketChannel
* @throws IOException if an I/O error occurs
*/
public static MuxServerSocketChannel openAndBind(
Map<String,Object> properties,
Map<String, Object> properties,
SocketAddress endpoint,
int backlog,
DatagramPacketFilter filter)

View File

@ -270,7 +270,7 @@ class MuxingServerSocketChannel
* @throws IOException if an I/O error occurs
*/
public static MuxServerSocketChannel openAndBind(
Map<String,Object> properties,
Map<String, Object> properties,
SocketAddress endpoint,
int backlog,
DatagramPacketFilter filter)

View File

@ -210,7 +210,8 @@ class Connector
if (!running)
return;
if (logger.isLoggable(Level.FINEST)){
if (logger.isLoggable(Level.FINEST))
{
logger.finest("received datagram packet - addr: "
+ packet.getAddress() + " port: " + packet.getPort());
}

View File

@ -109,7 +109,7 @@ public class EventDispatcher
{
synchronized(messageListeners)
{
if(!messageListeners.contains(messageListener))
if (!messageListeners.contains(messageListener))
messageListeners.add(messageListener);
}
}
@ -289,7 +289,7 @@ public class EventDispatcher
{
synchronized(messageListeners)
{
if(!messageListeners.isEmpty())
if (!messageListeners.isEmpty())
{
// there is a generic listener
return true;

View File

@ -301,7 +301,8 @@ class NetAccessManager
{
logger.log(Level.WARNING, "Removing connector:" + connector,
error);
} else if (logger.isLoggable(Level.FINE))
}
else if (logger.isLoggable(Level.FINE))
{
logger.fine("Removing connector " + connector);
}
@ -434,7 +435,7 @@ class NetAccessManager
}
}
if(connector != null)
if (connector != null)
connector.stop();
}

View File

@ -306,7 +306,7 @@ public class StunClientTransaction
TransactionID transactionID = getTransactionID();
logger.fine("handleResponse tid " + transactionID);
if(!Boolean.getBoolean(StackProperties.KEEP_CRANS_AFTER_A_RESPONSE))
if (!Boolean.getBoolean(StackProperties.KEEP_CRANS_AFTER_A_RESPONSE))
{
cancel();
}
@ -340,7 +340,7 @@ public class StunClientTransaction
String maxRetransmissionsStr
= System.getProperty(StackProperties.MAX_CTRAN_RETRANSMISSIONS);
if(maxRetransmissionsStr != null
if (maxRetransmissionsStr != null
&& maxRetransmissionsStr.trim().length() > 0)
{
try
@ -360,7 +360,7 @@ public class StunClientTransaction
String originalWaitIntervalStr
= System.getProperty(StackProperties.FIRST_CTRAN_RETRANS_AFTER);
if(originalWaitIntervalStr != null
if (originalWaitIntervalStr != null
&& originalWaitIntervalStr.trim().length() > 0)
{
try
@ -381,7 +381,7 @@ public class StunClientTransaction
String maxWaitIntervalStr
= System.getProperty(StackProperties.MAX_CTRAN_RETRANS_TIMER);
if(maxWaitIntervalStr != null
if (maxWaitIntervalStr != null
&& maxWaitIntervalStr.trim().length() > 0)
{
try

View File

@ -165,7 +165,8 @@ public class StunServerTransaction
IOException,
IllegalArgumentException
{
if(!isRetransmitting){
if (!isRetransmitting)
{
this.response = response;
//the transaction id might already have been set, but its our job
//to make sure of that
@ -195,7 +196,7 @@ public class StunServerTransaction
{
//don't retransmit if we are expired or if the user application
//hasn't yet transmitted a first response
if(isExpired() || !isRetransmitting)
if (isExpired() || !isRetransmitting)
return;
stackCallback.getNetAccessManager().sendMessage(

View File

@ -262,7 +262,7 @@ public class StunStack
StunClientTransaction clientTransaction
= clientTransactions.get(transactionID);
if(clientTransaction != null)
if (clientTransaction != null)
clientTransaction.cancel();
}
@ -405,7 +405,7 @@ public class StunStack
*/
public StunStack()
{
this(null,null);
this(null, null);
}
/**
@ -741,14 +741,14 @@ public class StunStack
= TransactionID.createTransactionID(this, transactionID);
StunServerTransaction sTran = getServerTransaction(tid);
if(sTran == null)
if (sTran == null)
{
throw new StunException(StunException.TRANSACTION_DOES_NOT_EXIST,
"The transaction specified in the response "
+ "(tid="+ tid.toString() +") "
+ "object does not exist.");
}
else if( sTran.isRetransmitting())
else if ( sTran.isRetransmitting())
{
throw new StunException(StunException.TRANSACTION_ALREADY_ANSWERED,
"The transaction specified in the response "
@ -891,7 +891,7 @@ public class StunStack
{
Message msg = ev.getMessage();
if(logger.isLoggable(Level.FINEST))
if (logger.isLoggable(Level.FINEST))
{
logger.finest(
"Received a message on " + ev.getLocalAddress()
@ -899,14 +899,14 @@ public class StunStack
}
//request
if(msg instanceof Request)
if (msg instanceof Request)
{
logger.finest("parsing request");
TransactionID serverTid = ev.getTransactionID();
StunServerTransaction sTran = getServerTransaction(serverTid);
if( sTran != null)
if ( sTran != null)
{
//requests from this transaction have already been seen
//retransmit the response if there was any
@ -925,7 +925,7 @@ public class StunStack
ex);
}
if(!Boolean.getBoolean(
if (!Boolean.getBoolean(
StackProperties.PROPAGATE_RECEIVED_RETRANSMISSIONS))
{
return;
@ -982,7 +982,7 @@ public class StunStack
logger.log(Level.INFO, "Received an invalid request.", t);
Throwable cause = t.getCause();
if(((t instanceof StunException)
if (((t instanceof StunException)
&& ((StunException) t).getID()
== StunException
.TRANSACTION_ALREADY_ANSWERED)
@ -996,7 +996,7 @@ public class StunStack
return;
}
if(t instanceof IllegalArgumentException)
if (t instanceof IllegalArgumentException)
{
error
= createCorrespondingErrorResponse(
@ -1030,12 +1030,12 @@ public class StunStack
}
}
//response
else if(msg instanceof Response)
else if (msg instanceof Response)
{
TransactionID tid = ev.getTransactionID();
StunClientTransaction tran = clientTransactions.remove(tid);
if(tran != null)
if (tran != null)
{
tran.handleResponse(ev);
}
@ -1193,7 +1193,7 @@ public class StunStack
"Wrong MESSAGE-INTEGRITY value.");
}
}
else if(Boolean.getBoolean(StackProperties.REQUIRE_MESSAGE_INTEGRITY))
else if (Boolean.getBoolean(StackProperties.REQUIRE_MESSAGE_INTEGRITY))
{
// no message integrity
Response error = createCorrespondingErrorResponse(
@ -1211,9 +1211,9 @@ public class StunStack
//look for unknown attributes.
List<Attribute> allAttributes = request.getAttributes();
StringBuffer sBuff = new StringBuffer();
for(Attribute attr : allAttributes)
for (Attribute attr : allAttributes)
{
if(attr instanceof OptionalAttribute
if (attr instanceof OptionalAttribute
&& attr.getAttributeType()
< Attribute.UNKNOWN_OPTIONAL_ATTRIBUTE)
sBuff.append(attr.getAttributeType());
@ -1264,7 +1264,7 @@ public class StunStack
|| (shortTermCredentialMechanism
&& ((colon = username.indexOf(":")) < 1)))
{
if(logger.isLoggable(Level.FINE))
if (logger.isLoggable(Level.FINE))
{
logger.log(Level.FINE, "Received a message with an improperly "
+"formatted username");
@ -1277,7 +1277,7 @@ public class StunStack
byte[] key = getCredentialsManager().getLocalKey(username);
if(key == null)
if (key == null)
return false;
/*
@ -1323,7 +1323,7 @@ public class StunStack
expectedMsgIntHmacSha1Content,
msgIntHmacSha1Content))
{
if(logger.isLoggable(Level.FINE))
if (logger.isLoggable(Level.FINE))
{
logger.log(
Level.FINE,
@ -1391,7 +1391,7 @@ public class StunStack
if ((username.length() < 1) || (colon < 1))
{
if(logger.isLoggable(Level.FINE))
if (logger.isLoggable(Level.FINE))
{
logger.log(Level.FINE, "Received a message with an improperly "
+"formatted username");
@ -1444,7 +1444,7 @@ public class StunStack
* @return corresponding Error Response object.
*/
public Response createCorrespondingErrorResponse(char requestType,
char errorCode, String reasonPhrase,char... unknownAttributes)
char errorCode, String reasonPhrase, char... unknownAttributes)
{
if (requestType == Message.BINDING_REQUEST)
{

View File

@ -125,11 +125,11 @@ public class TransactionID
*/
private static void generateTransactionID(TransactionID tid, int nb)
{
long left = System.currentTimeMillis();//the first nb/2 bytes of the id
long right = random.nextLong();//the last nb/2 bytes of the id
long left = System.currentTimeMillis(); //the first nb/2 bytes of the id
long right = random.nextLong(); //the last nb/2 bytes of the id
int b = nb / 2;
for(int i = 0; i < b; i++)
for (int i = 0; i < b; i++)
{
tid.transactionID[i] = (byte)((left >> (i * 8)) & 0xFFL);
tid.transactionID[i + b] = (byte)((right >> (i * 8)) & 0xFFL);
@ -166,13 +166,13 @@ public class TransactionID
StunClientTransaction cliTran
= stunStack.getClientTransaction(transactionID);
if(cliTran != null)
if (cliTran != null)
return cliTran.getTransactionID();
StunServerTransaction serTran
= stunStack.getServerTransaction(transactionID);
if(serTran != null)
if (serTran != null)
return serTran.getTransactionID();
//seems that the caller really wants a new ID
@ -219,9 +219,9 @@ public class TransactionID
*/
public boolean equals(Object obj)
{
if(this == obj)
if (this == obj)
return true;
if(!(obj instanceof TransactionID))
if (!(obj instanceof TransactionID))
return false;
byte targetBytes[] = ((TransactionID)obj).transactionID;
@ -272,10 +272,10 @@ public class TransactionID
StringBuilder idStr = new StringBuilder();
idStr.append("0x");
for(int i = 0; i < transactionID.length; i++)
for (int i = 0; i < transactionID.length; i++)
{
if((transactionID[i] & 0xFF) <= 15)
if ((transactionID[i] & 0xFF) <= 15)
idStr.append("0");
idStr.append(

View File

@ -168,7 +168,7 @@ public class BlockingRequestSender
}
ended = false;
while(!ended)
while (!ended)
{
try
{
@ -212,11 +212,11 @@ public class BlockingRequestSender
synchronized(sendLock)
{
stunStack.sendRequest(request, serverAddress, localAddress,
BlockingRequestSender.this,tranID);
BlockingRequestSender.this, tranID);
}
ended = false;
while(!ended)
while (!ended)
{
try
{

View File

@ -201,7 +201,7 @@ public class NetworkConfigurationDiscoveryProcess
StunDiscoveryReport report = new StunDiscoveryReport();
StunMessageEvent evt = doTestI(serverAddress);
if(evt == null)
if (evt == null)
{
//UDP Blocked
report.setNatType(StunDiscoveryReport.UDP_BLOCKING_FIREWALL);
@ -213,7 +213,7 @@ public class NetworkConfigurationDiscoveryProcess
=((MappedAddressAttribute)evt.getMessage()
.getAttribute(Attribute.MAPPED_ADDRESS)).getAddress();
if(mappedAddress == null)
if (mappedAddress == null)
{
/* maybe we contact a STUNbis server and which do not
* understand our request.
@ -257,7 +257,7 @@ public class NetworkConfigurationDiscoveryProcess
if (evt == null)
{
evt = doTestI(backupServerAddress);
if(evt == null)
if (evt == null)
{
logger.info("Failed to receive a response from "
+"backup stun server!");
@ -267,10 +267,10 @@ public class NetworkConfigurationDiscoveryProcess
((MappedAddressAttribute)evt.getMessage().
getAttribute(Attribute.MAPPED_ADDRESS))
.getAddress();
if(mappedAddress.equals(mappedAddress2))
if (mappedAddress.equals(mappedAddress2))
{
evt = doTestIII(serverAddress);
if(evt == null)
if (evt == null)
{
//port restricted cone
report.setNatType(StunDiscoveryReport
@ -350,7 +350,7 @@ public class NetworkConfigurationDiscoveryProcess
return null;
}
if(evt != null)
if (evt != null)
logger.fine("TEST I res="+evt.getRemoteAddress().toString()
+" - "+ evt.getRemoteAddress().getHostAddress());
else
@ -385,7 +385,7 @@ public class NetworkConfigurationDiscoveryProcess
StunMessageEvent evt
= requestSender.sendRequestAndWaitForResponse(request,
serverAddress);
if(evt != null)
if (evt != null)
logger.fine("Test II res="+evt.getRemoteAddress().toString()
+" - "+ evt.getRemoteAddress().getHostAddress());
else
@ -409,7 +409,8 @@ public class NetworkConfigurationDiscoveryProcess
{
Request request = MessageFactory.createBindingRequest();
/* ChangeRequestAttribute changeRequest = (ChangeRequestAttribute)request.getAttribute(Attribute.CHANGE_REQUEST); */
/* ChangeRequestAttribute changeRequest
= (ChangeRequestAttribute)request.getAttribute(Attribute.CHANGE_REQUEST); */
/* add a change request attribute */
ChangeRequestAttribute changeRequest = AttributeFactory.createChangeRequestAttribute();
changeRequest.setChangeIpFlag(false);
@ -418,7 +419,7 @@ public class NetworkConfigurationDiscoveryProcess
StunMessageEvent evt = requestSender.sendRequestAndWaitForResponse(
request, serverAddress);
if(evt != null)
if (evt != null)
logger.fine("Test III res="+evt.getRemoteAddress().toString()
+" - "+ evt.getRemoteAddress().getHostAddress());
else
@ -435,7 +436,7 @@ public class NetworkConfigurationDiscoveryProcess
private void checkStarted()
throws StunException
{
if(!started)
if (!started)
throw new StunException(StunException.ILLEGAL_STATE,
"The Discoverer must be started before "
+"launching the discovery process!");

View File

@ -137,14 +137,14 @@ public class SimpleAddressDetector
stunStack.removeSocket(localAddress);
}
if(evt != null)
if (evt != null)
{
Response res = (Response)evt.getMessage();
/* in classic STUN, the response contains a MAPPED-ADDRESS */
MappedAddressAttribute maAtt = (MappedAddressAttribute)
res.getAttribute(Attribute.MAPPED_ADDRESS);
if(maAtt != null)
if (maAtt != null)
{
return maAtt.getAddress();
}
@ -152,7 +152,7 @@ public class SimpleAddressDetector
/* in STUN bis, the response contains a XOR-MAPPED-ADDRESS */
XorMappedAddressAttribute xorAtt = (XorMappedAddressAttribute)res
.getAttribute(Attribute.XOR_MAPPED_ADDRESS);
if(xorAtt != null)
if (xorAtt != null)
{
byte xoring[] = new byte[16];

View File

@ -129,10 +129,10 @@ public class StunDiscoveryReport
*/
public boolean equals(Object obj)
{
if(! (obj instanceof StunDiscoveryReport))
if (! (obj instanceof StunDiscoveryReport))
return false;
if(obj == this)
if (obj == this)
return true;
StunDiscoveryReport target = (StunDiscoveryReport)obj;

View File

@ -68,10 +68,10 @@ public class Ice4jLogFormatter
int lineNumber = inferCaller(record);
String loggerName = record.getLoggerName();
if(loggerName == null)
if (loggerName == null)
loggerName = record.getSourceClassName();
if(loggerName.startsWith("net.java.sip.communicator."))
if (loggerName.startsWith("net.java.sip.communicator."))
{
sb.append(loggerName.substring("net.java.sip.communicator."
.length()));
@ -85,7 +85,7 @@ public class Ice4jLogFormatter
sb.append(record.getSourceMethodName());
//include the line number if we have it.
if(lineNumber != -1)
if (lineNumber != -1)
sb.append("().").append(Integer.toString(lineNumber));
else
sb.append("()");