Author: borges
Date: 2012-01-05 09:06:17 -0500 (Thu, 05 Jan 2012)
New Revision: 11975
Modified:
trunk/hornetq-core/src/main/java/org/hornetq/core/server/impl/RoutingContextImpl.java
trunk/hornetq-core/src/main/java/org/hornetq/core/settings/impl/Match.java
trunk/hornetq-core/src/main/java/org/hornetq/utils/json/JSONObject.java
trunk/hornetq-jms/src/main/java/org/hornetq/jms/client/HornetQConnectionFactory.java
trunk/hornetq-journal/src/main/java/org/hornetq/core/journal/impl/AbstractSequentialFile.java
trunk/hornetq-journal/src/main/java/org/hornetq/core/journal/impl/JournalImpl.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/FailBackManualTest.java
trunk/tests/unit-tests/src/test/java/org/hornetq/tests/unit/core/asyncio/MultiThreadAsynchronousFileTest.java
Log:
Fix more findbugs warnings.
Modified:
trunk/hornetq-core/src/main/java/org/hornetq/core/server/impl/RoutingContextImpl.java
===================================================================
---
trunk/hornetq-core/src/main/java/org/hornetq/core/server/impl/RoutingContextImpl.java 2012-01-05
14:05:22 UTC (rev 11974)
+++
trunk/hornetq-core/src/main/java/org/hornetq/core/server/impl/RoutingContextImpl.java 2012-01-05
14:06:17 UTC (rev 11975)
@@ -33,7 +33,7 @@
*/
public class RoutingContextImpl implements RoutingContext
{
-
+
// The pair here is Durable and NonDurable
private final Map<SimpleString, RouteContextList> map = new
HashMap<SimpleString, RouteContextList>();
@@ -45,13 +45,13 @@
{
this.transaction = transaction;
}
-
+
public void clear()
{
transaction = null;
map.clear();
-
+
queueCount = 0;
}
@@ -59,7 +59,7 @@
{
RouteContextList listing = getContextListing(address);
-
+
if (queue.isDurable())
{
listing.getDurableQueues().add(queue);
@@ -71,7 +71,7 @@
queueCount++;
}
-
+
public RouteContextList getContextListing(SimpleString address)
{
RouteContextList listing = map.get(address);
@@ -115,35 +115,31 @@
{
return this.map;
}
-
-
- private class ContextListing implements RouteContextList
+
+
+ private static class ContextListing implements RouteContextList
{
private final List<Queue> durableQueue = new ArrayList<Queue>(1);
-
+
private final List<Queue> nonDurableQueue = new ArrayList<Queue>(1);
-
+
public int getNumberOfDurableQueues()
{
return durableQueue.size();
}
-
+
public int getNumberOfNonDurableQueues()
{
return nonDurableQueue.size();
}
- /* (non-Javadoc)
- * @see org.hornetq.core.server.RouteContextList#getDurableQueues()
- */
+ @Override
public List<Queue> getDurableQueues()
{
return durableQueue;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.server.RouteContextList#getNonDurableQueues()
- */
+ @Override
public List<Queue> getNonDurableQueues()
{
return nonDurableQueue;
Modified: trunk/hornetq-core/src/main/java/org/hornetq/core/settings/impl/Match.java
===================================================================
--- trunk/hornetq-core/src/main/java/org/hornetq/core/settings/impl/Match.java 2012-01-05
14:05:22 UTC (rev 11974)
+++ trunk/hornetq-core/src/main/java/org/hornetq/core/settings/impl/Match.java 2012-01-05
14:06:17 UTC (rev 11975)
@@ -20,13 +20,13 @@
*/
public class Match<T>
{
- public static String WORD_WILDCARD = "*";
+ public static final String WORD_WILDCARD = "*";
- private static String WORD_WILDCARD_REPLACEMENT = "[^.]+";
+ private static final String WORD_WILDCARD_REPLACEMENT = "[^.]+";
- public static String WILDCARD = "#";
+ public static final String WILDCARD = "#";
- private static String WILDCARD_REPLACEMENT = ".+";
+ private static final String WILDCARD_REPLACEMENT = ".+";
private static final String DOT = ".";
Modified: trunk/hornetq-core/src/main/java/org/hornetq/utils/json/JSONObject.java
===================================================================
--- trunk/hornetq-core/src/main/java/org/hornetq/utils/json/JSONObject.java 2012-01-05
14:05:22 UTC (rev 11974)
+++ trunk/hornetq-core/src/main/java/org/hornetq/utils/json/JSONObject.java 2012-01-05
14:06:17 UTC (rev 11975)
@@ -1090,7 +1090,7 @@
*/
public JSONObject put(final String key, final int value) throws JSONException
{
- put(key, new Integer(value));
+ put(key, Integer.valueOf(value));
return this;
}
@@ -1104,7 +1104,7 @@
*/
public JSONObject put(final String key, final long value) throws JSONException
{
- put(key, new Long(value));
+ put(key, Long.valueOf(value));
return this;
}
@@ -1328,7 +1328,7 @@
{
try
{
- return new Integer(Integer.parseInt(s.substring(2), 16));
+ return Integer.valueOf(Integer.parseInt(s.substring(2), 16));
}
catch (Exception e)
{
@@ -1339,7 +1339,7 @@
{
try
{
- return new Integer(Integer.parseInt(s, 8));
+ return Integer.valueOf(Integer.parseInt(s, 8));
}
catch (Exception e)
{
@@ -1355,10 +1355,10 @@
}
else
{
- Long myLong = new Long(s);
+ Long myLong = Long.valueOf(s);
if (myLong.longValue() == myLong.intValue())
{
- return new Integer(myLong.intValue());
+ return Integer.valueOf(myLong.intValue());
}
else
{
@@ -1440,7 +1440,7 @@
try
{
Iterator keys = keys();
- StringBuffer sb = new StringBuffer("{");
+ StringBuilder sb = new StringBuilder("{");
while (keys.hasNext())
{
Modified:
trunk/hornetq-jms/src/main/java/org/hornetq/jms/client/HornetQConnectionFactory.java
===================================================================
---
trunk/hornetq-jms/src/main/java/org/hornetq/jms/client/HornetQConnectionFactory.java 2012-01-05
14:05:22 UTC (rev 11974)
+++
trunk/hornetq-jms/src/main/java/org/hornetq/jms/client/HornetQConnectionFactory.java 2012-01-05
14:06:17 UTC (rev 11975)
@@ -704,7 +704,7 @@
}
@Override
- public void finalize() throws Throwable
+ protected void finalize() throws Throwable
{
try
{
Modified:
trunk/hornetq-journal/src/main/java/org/hornetq/core/journal/impl/AbstractSequentialFile.java
===================================================================
---
trunk/hornetq-journal/src/main/java/org/hornetq/core/journal/impl/AbstractSequentialFile.java 2012-01-05
14:05:22 UTC (rev 11974)
+++
trunk/hornetq-journal/src/main/java/org/hornetq/core/journal/impl/AbstractSequentialFile.java 2012-01-05
14:06:17 UTC (rev 11975)
@@ -23,6 +23,7 @@
import org.hornetq.api.core.HornetQBuffer;
import org.hornetq.api.core.HornetQBuffers;
+import org.hornetq.api.core.HornetQException;
import org.hornetq.core.journal.EncodingSupport;
import org.hornetq.core.journal.IOAsyncTask;
import org.hornetq.core.journal.SequentialFile;
@@ -145,7 +146,11 @@
if (!file.equals(newFile))
{
- file.renameTo(newFile);
+ if (!file.renameTo(newFile))
+ {
+ throw new HornetQException(HornetQException.IO_ERROR, "failed to rename
file " + file.getName() + " to " +
+ newFileName);
+ }
file = newFile;
}
}
Modified:
trunk/hornetq-journal/src/main/java/org/hornetq/core/journal/impl/JournalImpl.java
===================================================================
---
trunk/hornetq-journal/src/main/java/org/hornetq/core/journal/impl/JournalImpl.java 2012-01-05
14:05:22 UTC (rev 11974)
+++
trunk/hornetq-journal/src/main/java/org/hornetq/core/journal/impl/JournalImpl.java 2012-01-05
14:06:17 UTC (rev 11975)
@@ -1178,10 +1178,10 @@
journalLock.readLock().lock();
- JournalTransaction tx = transactions.remove(txID);
-
try
{
+ JournalTransaction tx = transactions.remove(txID);
+
if (tx == null)
{
throw new IllegalStateException("Cannot find tx with id " + txID);
@@ -2963,7 +2963,7 @@
}
}
- private class PerfBlast extends Thread
+ private final class PerfBlast extends Thread
{
private final int pages;
@@ -2977,9 +2977,9 @@
@Override
public void run()
{
+ lockAppend.lock();
try
{
- lockAppend.lock();
final ByteArrayEncoding byteEncoder = new ByteArrayEncoding(new byte[128 *
1024]);
@@ -3002,13 +3002,15 @@
{
appendRecord(blastRecord, false, false, null, null);
}
-
- lockAppend.unlock();
}
catch (Exception e)
{
JournalImpl.log.error("Failed to perf blast", e);
}
+ finally
+ {
+ lockAppend.unlock();
+ }
}
}
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/FailBackManualTest.java
===================================================================
---
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/FailBackManualTest.java 2012-01-05
14:05:22 UTC (rev 11974)
+++
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/FailBackManualTest.java 2012-01-05
14:06:17 UTC (rev 11975)
@@ -229,7 +229,7 @@
message.getBodyBuffer().writeString("message" + i);
}
- class ServerStarter implements Runnable
+ static class ServerStarter implements Runnable
{
private final TestableServer server;
Modified:
trunk/tests/unit-tests/src/test/java/org/hornetq/tests/unit/core/asyncio/MultiThreadAsynchronousFileTest.java
===================================================================
---
trunk/tests/unit-tests/src/test/java/org/hornetq/tests/unit/core/asyncio/MultiThreadAsynchronousFileTest.java 2012-01-05
14:05:22 UTC (rev 11974)
+++
trunk/tests/unit-tests/src/test/java/org/hornetq/tests/unit/core/asyncio/MultiThreadAsynchronousFileTest.java 2012-01-05
14:06:17 UTC (rev 11975)
@@ -31,13 +31,13 @@
import org.hornetq.utils.HornetQThreadFactory;
/**
- *
+ *
* you need to define -Djava.library.path=${project-root}/native/src/.libs when calling
the JVM
* If you are running this test in eclipse you should do:
* I - Run->Open Run Dialog
- * II - Find the class on the list (you will find it if you already tried running this
testcase before)
+ * II - Find the class on the list (you will find it if you already tried running this
testcase before)
* III - Add -Djava.library.path=<your project place>/native/src/.libs
- *
+ *
* @author <a href="mailto:clebert.suconic@jboss.com">Clebert
Suconic</a>.
* */
public class MultiThreadAsynchronousFileTest extends AIOTestBase
@@ -193,7 +193,7 @@
try
{
- // I'm aways reusing the same buffer, as I don't want any noise from
+ // I'm always reusing the same buffer, as I don't want any noise
from
// malloc on the measurement
// Encoding buffer
MultiThreadAsynchronousFileTest.addString("Thread name=" +
Thread.currentThread().getName() + ";" + "\n",
@@ -207,8 +207,6 @@
latchStart.countDown();
latchStart.await();
- long startTime = System.currentTimeMillis();
-
CountDownLatch latchFinishThread = null;
if (!sync)