From 890ddfd96dbf77e7a7daba9c07fab64fd5a1ad15 Mon Sep 17 00:00:00 2001
From: "lubomir.marinov"
Date: Fri, 19 Feb 2010 08:35:15 +0000
Subject: [PATCH] Fixes warnings.
---
src/org/ice4j/StunException.java | 12 ++-----
src/org/ice4j/attribute/AttributeDecoder.java | 6 ++--
.../attribute/ChannelNumberAttribute.java | 2 --
.../attribute/DontFragmentAttribute.java | 3 --
.../ice4j/attribute/ErrorCodeAttribute.java | 6 ++--
.../ice4j/attribute/EvenPortAttribute.java | 4 +--
.../ice4j/attribute/FingerprintAttribute.java | 2 --
.../ice4j/attribute/LifetimeAttribute.java | 2 --
.../RequestedTransportAttribute.java | 4 +--
.../attribute/XorPeerAddressAttribute.java | 2 --
.../attribute/XorRelayedAddressAttribute.java | 2 --
src/org/ice4j/ice/Agent.java | 2 +-
.../ice/harvest/StunCandidateHarvester.java | 33 ++++++++++---------
src/org/ice4j/message/Message.java | 5 ++-
.../ice4j/stack/StunClientTransaction.java | 2 --
.../stunclient/BlockingRequestSender.java | 1 -
test/org/ice4j/MsgFixture.java | 3 --
.../org/ice4j/message/MessageFactoryTest.java | 3 --
test/org/ice4j/message/MessageTest.java | 20 -----------
.../StunAddressDiscovererTest_v4v6.java | 2 +-
20 files changed, 31 insertions(+), 85 deletions(-)
diff --git a/src/org/ice4j/StunException.java b/src/org/ice4j/StunException.java
index dc8ed14..489e668 100644
--- a/src/org/ice4j/StunException.java
+++ b/src/org/ice4j/StunException.java
@@ -10,12 +10,11 @@ package org.ice4j;
* A StunException is thrown when a general STUN exception is encountered.
*
* Copyright: Copyright (c) 2003
- * Organisation: Louis Pasteur University, Strasbourg, France
- * Network Research Team (http://www-r2.u-strasbg.fr)
+ * Organization: Louis Pasteur University, Strasbourg, France
+ * Network Research Team (http://www-r2.u-strasbg.fr)
* @author Emil Ivov
* @version 0.1
*/
-
public class StunException extends Exception
{
/**
@@ -23,11 +22,6 @@ public class StunException extends Exception
*/
private static final long serialVersionUID = 35367793L;
- /**
- * Error ID.
- */
- private int errorID = 0;
-
/**
* Means that the the reason that caused the exception was unclear.
*/
@@ -50,7 +44,7 @@ public class StunException extends Exception
public static final int INTERNAL_ERROR = 3;
/**
- * Thrown when trying to send responses through a non-existant transaction
+ * Thrown when trying to send responses through a non-existent transaction
* That may happen when a corresponding request has already been responded
* to or when no such request has been received.
*/
diff --git a/src/org/ice4j/attribute/AttributeDecoder.java b/src/org/ice4j/attribute/AttributeDecoder.java
index f0a9505..3f54bd0 100644
--- a/src/org/ice4j/attribute/AttributeDecoder.java
+++ b/src/org/ice4j/attribute/AttributeDecoder.java
@@ -7,15 +7,14 @@
package org.ice4j.attribute;
import org.ice4j.*;
-import org.ice4j.message.*;
/**
* The class provides utilities for decoding a binary stream into an Attribute
* class.
*
* Copyright: Copyright (c) 2003-2008
- * Organisation: Louis Pasteur University, Strasbourg, France
- * Network Research Team (http://www-r2.u-strasbg.fr)
+ * Organization: Louis Pasteur University, Strasbourg, France
+ * Network Research Team (http://www-r2.u-strasbg.fr)
* @author Emil Ivov
* @author Sebastien Vincent
* @version 0.1
@@ -128,5 +127,4 @@ public class AttributeDecoder
return decodedAttribute;
}
-
}
diff --git a/src/org/ice4j/attribute/ChannelNumberAttribute.java b/src/org/ice4j/attribute/ChannelNumberAttribute.java
index 673815c..675027a 100644
--- a/src/org/ice4j/attribute/ChannelNumberAttribute.java
+++ b/src/org/ice4j/attribute/ChannelNumberAttribute.java
@@ -6,8 +6,6 @@
*/
package org.ice4j.attribute;
-import java.lang.*;
-
import org.ice4j.*;
/**
diff --git a/src/org/ice4j/attribute/DontFragmentAttribute.java b/src/org/ice4j/attribute/DontFragmentAttribute.java
index 8b4115f..2a7964e 100644
--- a/src/org/ice4j/attribute/DontFragmentAttribute.java
+++ b/src/org/ice4j/attribute/DontFragmentAttribute.java
@@ -6,8 +6,6 @@
*/
package org.ice4j.attribute;
-import java.lang.*;
-
import org.ice4j.*;
/**
@@ -112,4 +110,3 @@ public class DontFragmentAttribute extends Attribute
}
}
}
-
diff --git a/src/org/ice4j/attribute/ErrorCodeAttribute.java b/src/org/ice4j/attribute/ErrorCodeAttribute.java
index 8cc3188..3bfc010 100644
--- a/src/org/ice4j/attribute/ErrorCodeAttribute.java
+++ b/src/org/ice4j/attribute/ErrorCodeAttribute.java
@@ -6,8 +6,6 @@
*/
package org.ice4j.attribute;
-import java.util.Hashtable;
-
import org.ice4j.*;
/**
@@ -74,8 +72,8 @@ import org.ice4j.*;
* The client should not retry.
*
* Copyright: Copyright (c) 2003
- * Organisation: Louis Pasteur University, Strasbourg, France
- * Network Research Team (http://www-r2.u-strasbg.fr)
+ * Organization: Louis Pasteur University, Strasbourg, France
+ * Network Research Team (http://www-r2.u-strasbg.fr)
* @author Emil Ivov
* @version 0.1
*/
diff --git a/src/org/ice4j/attribute/EvenPortAttribute.java b/src/org/ice4j/attribute/EvenPortAttribute.java
index 15233d2..babdeeb 100644
--- a/src/org/ice4j/attribute/EvenPortAttribute.java
+++ b/src/org/ice4j/attribute/EvenPortAttribute.java
@@ -6,13 +6,11 @@
*/
package org.ice4j.attribute;
-import java.lang.*;
-
import org.ice4j.*;
/**
* The EVEN-PORT attribute is used to ask the TURN
- * server to allocate an even port and optionnaly allocate
+ * server to allocate an even port and optionally allocate
* the next higher port number.
*
* There are one flag supported :
diff --git a/src/org/ice4j/attribute/FingerprintAttribute.java b/src/org/ice4j/attribute/FingerprintAttribute.java
index 1edadfb..f237e69 100644
--- a/src/org/ice4j/attribute/FingerprintAttribute.java
+++ b/src/org/ice4j/attribute/FingerprintAttribute.java
@@ -6,8 +6,6 @@
*/
package org.ice4j.attribute;
-import java.util.*;
-
import org.ice4j.*;
/**
diff --git a/src/org/ice4j/attribute/LifetimeAttribute.java b/src/org/ice4j/attribute/LifetimeAttribute.java
index 7db5516..6050912 100644
--- a/src/org/ice4j/attribute/LifetimeAttribute.java
+++ b/src/org/ice4j/attribute/LifetimeAttribute.java
@@ -6,8 +6,6 @@
*/
package org.ice4j.attribute;
-import java.lang.*;
-
import org.ice4j.*;
/**
diff --git a/src/org/ice4j/attribute/RequestedTransportAttribute.java b/src/org/ice4j/attribute/RequestedTransportAttribute.java
index b0143b8..69deab6 100644
--- a/src/org/ice4j/attribute/RequestedTransportAttribute.java
+++ b/src/org/ice4j/attribute/RequestedTransportAttribute.java
@@ -6,8 +6,6 @@
*/
package org.ice4j.attribute;
-import java.lang.*;
-
import org.ice4j.*;
/**
@@ -15,7 +13,7 @@ import org.ice4j.*;
* TURN address of certain transport protocol.
*
* In the original TURN specification, only UDP is supported.
- * Support of TCP is detailled in draft-ietf-behave-turn-tcp-05.
+ * Support of TCP is detailed in draft-ietf-behave-turn-tcp-05.
*
* @author Sebastien Vincent
* @version 0.1
diff --git a/src/org/ice4j/attribute/XorPeerAddressAttribute.java b/src/org/ice4j/attribute/XorPeerAddressAttribute.java
index 9be3679..bbbb396 100644
--- a/src/org/ice4j/attribute/XorPeerAddressAttribute.java
+++ b/src/org/ice4j/attribute/XorPeerAddressAttribute.java
@@ -6,8 +6,6 @@
*/
package org.ice4j.attribute;
-import org.ice4j.*;
-
/**
* The XOR-PEER-ADDRESS attribute is given by a TURN client to
* indicates the peer destination address of its relayed packet.
diff --git a/src/org/ice4j/attribute/XorRelayedAddressAttribute.java b/src/org/ice4j/attribute/XorRelayedAddressAttribute.java
index 681f702..e5a6671 100644
--- a/src/org/ice4j/attribute/XorRelayedAddressAttribute.java
+++ b/src/org/ice4j/attribute/XorRelayedAddressAttribute.java
@@ -6,8 +6,6 @@
*/
package org.ice4j.attribute;
-import org.ice4j.*;
-
/**
* The XOR-RELAYED-ADDRESS attribute is given by a TURN server to
* indicates the client its relayed address.
diff --git a/src/org/ice4j/ice/Agent.java b/src/org/ice4j/ice/Agent.java
index 872c553..de84982 100644
--- a/src/org/ice4j/ice/Agent.java
+++ b/src/org/ice4j/ice/Agent.java
@@ -32,7 +32,7 @@ public class Agent
/**
* Our class logger.
*/
- private final Logger logger
+ private static final Logger logger
= Logger.getLogger(Agent.class.getName());
/**
diff --git a/src/org/ice4j/ice/harvest/StunCandidateHarvester.java b/src/org/ice4j/ice/harvest/StunCandidateHarvester.java
index 86a083a..0be733a 100644
--- a/src/org/ice4j/ice/harvest/StunCandidateHarvester.java
+++ b/src/org/ice4j/ice/harvest/StunCandidateHarvester.java
@@ -17,11 +17,9 @@ import org.ice4j.ice.*;
import org.ice4j.message.*;
import org.ice4j.stack.*;
-import com.sun.org.apache.bcel.internal.generic.*;
-
/**
* A StunCandidateHarvester gathers STUN Candidates for a
- * specified {@link org.ice4j.ice.Component}.
+ * specified {@link Component}.
*
* @author Emil Ivov
*/
@@ -133,21 +131,28 @@ public class StunCandidateHarvester
}
/**
- * Blocks the current thread until all resolutions in this harverster
+ * Blocks the current thread until all resolutions in this harvester
* have terminated one way or another.
*/
private void waitForResolutionEnd()
{
synchronized(resolveMap)
{
- if(resolveMap.isEmpty())
- return;
+ boolean interrupted = false;
- try
- {
- resolveMap.wait();
- }
- catch (InterruptedException e){}
+ // Handle spurious wakeups.
+ while (!resolveMap.isEmpty())
+ try
+ {
+ resolveMap.wait();
+ }
+ catch (InterruptedException iex)
+ {
+ interrupted = true;
+ }
+ // Restore the interrupted status.
+ if (interrupted)
+ Thread.currentThread().interrupt();
}
}
@@ -179,7 +184,6 @@ public class StunCandidateHarvester
logger.finest("received a message tranid=" + tranID);
logger.finest("localCand=" + localCand);
}
-
}
/**
@@ -201,7 +205,7 @@ public class StunCandidateHarvester
* because of the oddities of the BSD and Java socket implementations, which
* is why we currently ignore this method.
*
- * @param event the StunFailureEvent
+ * @param event the StunFailureEvent containg the
* PortUnreachableException which signaled that the destination of
* the request was found to be unreachable.
*/
@@ -250,8 +254,7 @@ public class StunCandidateHarvester
Attribute attribute
= response.getAttribute(Attribute.XOR_MAPPED_ADDRESS);
- if(attribute == null
- || !(attribute instanceof XorMappedAddressAttribute))
+ if(!(attribute instanceof XorMappedAddressAttribute))
return;
TransportAddress addr = ((XorMappedAddressAttribute)attribute)
diff --git a/src/org/ice4j/message/Message.java b/src/org/ice4j/message/Message.java
index 134d4eb..b21a18a 100644
--- a/src/org/ice4j/message/Message.java
+++ b/src/org/ice4j/message/Message.java
@@ -522,10 +522,9 @@ public abstract class Message
while (iter.hasNext())
{
- Attribute attribute
- = ((Map.Entry)iter.next()).getValue();
-
+ Attribute attribute = iter.next().getValue();
byte[] attBinValue = attribute.encode();
+
System.arraycopy(attBinValue, 0, binMsg, offset, attBinValue.length);
offset += attBinValue.length;
}
diff --git a/src/org/ice4j/stack/StunClientTransaction.java b/src/org/ice4j/stack/StunClientTransaction.java
index 28d4b36..fca4543 100644
--- a/src/org/ice4j/stack/StunClientTransaction.java
+++ b/src/org/ice4j/stack/StunClientTransaction.java
@@ -7,7 +7,6 @@
package org.ice4j.stack;
import java.io.*;
-import java.net.*;
import java.util.logging.*;
import org.ice4j.*;
@@ -33,7 +32,6 @@ import org.ice4j.message.*;
* @author Emil Ivov.
* @author Pascal Mogeri (contributed configuration of client transactions).
*/
-
class StunClientTransaction
implements Runnable
{
diff --git a/src/org/ice4j/stunclient/BlockingRequestSender.java b/src/org/ice4j/stunclient/BlockingRequestSender.java
index f5a1234..fc1c567 100644
--- a/src/org/ice4j/stunclient/BlockingRequestSender.java
+++ b/src/org/ice4j/stunclient/BlockingRequestSender.java
@@ -7,7 +7,6 @@
package org.ice4j.stunclient;
import java.io.*;
-import java.net.*;
import java.util.logging.*;
import org.ice4j.*;
diff --git a/test/org/ice4j/MsgFixture.java b/test/org/ice4j/MsgFixture.java
index 5567110..9e65a0a 100644
--- a/test/org/ice4j/MsgFixture.java
+++ b/test/org/ice4j/MsgFixture.java
@@ -6,9 +6,6 @@
*/
package org.ice4j;
-import org.ice4j.attribute.*;
-import org.ice4j.message.*;
-
public class MsgFixture
{
//---------------------- Attributes ---------------------------------------
diff --git a/test/org/ice4j/message/MessageFactoryTest.java b/test/org/ice4j/message/MessageFactoryTest.java
index 6530e8f..f486dbd 100644
--- a/test/org/ice4j/message/MessageFactoryTest.java
+++ b/test/org/ice4j/message/MessageFactoryTest.java
@@ -48,7 +48,6 @@ public class MessageFactoryTest extends TestCase {
Message actualReturn
= messageFactory.createBindingErrorResponse(errorCode);
assertEquals("return value", expectedReturn, actualReturn);
-
}
public void testCreateBindingErrorResponse1() throws StunException {
@@ -66,7 +65,6 @@ public class MessageFactoryTest extends TestCase {
.createBindingErrorResponse(errorCode, reasonPhrase);
assertEquals("Failed to create an error code attribute.",
expectedReturn, actualReturn);
-
}
public void testCreateBindingErrorResponseUnknownAttributes()
@@ -98,7 +96,6 @@ public class MessageFactoryTest extends TestCase {
.createBindingErrorResponseUnknownAttributes(unknownAttributes);
//compare
assertEquals("return value", expectedReturn, actualReturn);
-
}
public void testCreateBindingErrorResponseUnknownAttributes1()
diff --git a/test/org/ice4j/message/MessageTest.java b/test/org/ice4j/message/MessageTest.java
index 7109ac6..5528f7e 100644
--- a/test/org/ice4j/message/MessageTest.java
+++ b/test/org/ice4j/message/MessageTest.java
@@ -29,8 +29,6 @@ public class MessageTest extends TestCase {
private MsgFixture msgFixture;
-
-
protected void setUp() throws Exception {
super.setUp();
msgFixture = new MsgFixture();
@@ -72,8 +70,6 @@ public class MessageTest extends TestCase {
bindingResponse.addAttribute(changedAddress);
bindingResponse.setTransactionID(msgFixture.TRANSACTION_ID);
-
-
}
protected void tearDown() throws Exception
@@ -127,9 +123,6 @@ public class MessageTest extends TestCase {
assertEquals("The second attribute could not be extracted.",
sourceAddress,
getResult);
-
-
-
}
/**
@@ -155,8 +148,6 @@ public class MessageTest extends TestCase {
assertTrue("A binding response was not properly encoded",
Arrays.equals( expectedReturn, actualReturn ) );
-
-
}
/**
@@ -187,12 +178,8 @@ public class MessageTest extends TestCase {
assertEquals("A binding response was not properly decoded",
expectedReturn, actualReturn );
-
-
-
}
-
/**
* Tests the equals method against a null, a different and an identical
* object.
@@ -235,9 +222,6 @@ public class MessageTest extends TestCase {
binResTarget.addAttribute(changedAddress);
actualReturn = bindingResponse.equals(binResTarget);
assertEquals("Equals failed against a different target", expectedReturn, actualReturn);
-
-
-
}
/**
@@ -252,7 +236,6 @@ public class MessageTest extends TestCase {
actualReturn = bindingResponse.getAttributeCount();
assertEquals("getAttributeCount failed for a bindingRequest",
expectedReturn, actualReturn);
-
}
/**
@@ -270,8 +253,5 @@ public class MessageTest extends TestCase {
int actualReturn = bindingRequest.getAttributeCount();
assertEquals("Attribute count did not change after removing an attribute",
expectedReturn, actualReturn);
-
-
}
-
}
diff --git a/test/org/ice4j/stunclient/StunAddressDiscovererTest_v4v6.java b/test/org/ice4j/stunclient/StunAddressDiscovererTest_v4v6.java
index 409b39c..ac36c5c 100644
--- a/test/org/ice4j/stunclient/StunAddressDiscovererTest_v4v6.java
+++ b/test/org/ice4j/stunclient/StunAddressDiscovererTest_v4v6.java
@@ -98,7 +98,7 @@ public class StunAddressDiscovererTest_v4v6 extends TestCase {
stunAddressDiscoverer_v4 = null;
//give the sockets the time to clear out
- Thread.currentThread().sleep(1000);
+ Thread.sleep(1000);
super.tearDown();
}