Fixes compilaiton using jdk older than 1.8 (based on Matt Fredrickson's patch).
This commit is contained in:
parent
eb35310969
commit
8443e7e914
@ -32,6 +32,23 @@ class ConnectivityCheckServer
|
||||
private static final Logger logger
|
||||
= Logger.getLogger(ConnectivityCheckServer.class.getName());
|
||||
|
||||
/**
|
||||
* Compares <tt>a</tt> and <tt>b</tt> as unsigned long values. Serves the
|
||||
* same purpose as the <tt>Long.compareUnsigned</tt> method available in
|
||||
* Java 1.8.
|
||||
* @return <tt>-1</tt> if <tt>a</tt> is less than <tt>b</tt>, <tt>0</tt> if
|
||||
* they are equal and <tt>1</tt> if <tt>a</tt> is bigger.
|
||||
*/
|
||||
private static int compareUnsignedLong(long a, long b)
|
||||
{
|
||||
if (a == b)
|
||||
return 0;
|
||||
else if ((a + Long.MIN_VALUE) < (b + Long.MIN_VALUE))
|
||||
return -1;
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* The agent that created us.
|
||||
*/
|
||||
@ -257,7 +274,7 @@ class ConnectivityCheckServer
|
||||
// contents of the ICE-CONTROLLING attribute, the agent generates
|
||||
// a Binding error response and includes an ERROR-CODE attribute
|
||||
// with a value of 487 (Role Conflict) but retains its role.
|
||||
if(Long.compareUnsigned(ourTieBreaker, theirTieBreaker) >= 0)
|
||||
if(compareUnsignedLong(ourTieBreaker, theirTieBreaker) >= 0)
|
||||
{
|
||||
Response response = MessageFactory.createBindingErrorResponse(
|
||||
ErrorCodeAttribute.ROLE_CONFLICT);
|
||||
@ -284,7 +301,7 @@ class ConnectivityCheckServer
|
||||
else
|
||||
{
|
||||
logger.finer(
|
||||
"Swithing to controlled because theirTieBreaker="
|
||||
"Switching to controlled because theirTieBreaker="
|
||||
+ theirTieBreaker + " and ourTieBreaker="
|
||||
+ ourTieBreaker);
|
||||
parentAgent.setControlling(false);
|
||||
@ -304,7 +321,7 @@ class ConnectivityCheckServer
|
||||
//If the agent's tie-breaker is larger than or equal to the
|
||||
//contents of the ICE-CONTROLLED attribute, the agent switches to
|
||||
//the controlling role.
|
||||
if(Long.compareUnsigned(ourTieBreaker, theirTieBreaker) >= 0)
|
||||
if(compareUnsignedLong(ourTieBreaker, theirTieBreaker) >= 0)
|
||||
{
|
||||
logger.finer(
|
||||
"Switching to controlling because theirTieBreaker="
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user