Author: borges
Date: 2012-01-06 06:35:50 -0500 (Fri, 06 Jan 2012)
New Revision: 11982
Added:
trunk/etc/findbugs-exclude.xml
Modified:
trunk/etc/checkstyle.xml
trunk/hornetq-commons/src/main/java/org/hornetq/api/core/SimpleString.java
trunk/hornetq-core/src/main/java/org/hornetq/core/client/impl/ClientSessionFactoryImpl.java
trunk/hornetq-core/src/main/java/org/hornetq/core/client/impl/ServerLocatorImpl.java
trunk/hornetq-core/src/main/java/org/hornetq/core/filter/impl/FilterImpl.java
trunk/hornetq-core/src/main/java/org/hornetq/core/messagecounter/MessageCounter.java
trunk/hornetq-core/src/main/java/org/hornetq/core/messagecounter/impl/MessageCounterHelper.java
trunk/hornetq-core/src/main/java/org/hornetq/core/paging/impl/PagingStoreImpl.java
trunk/hornetq-core/src/main/java/org/hornetq/core/persistence/impl/journal/JournalStorageManager.java
trunk/hornetq-core/src/main/java/org/hornetq/core/postoffice/impl/DuplicateIDCacheImpl.java
trunk/hornetq-core/src/main/java/org/hornetq/core/protocol/stomp/HornetQStompException.java
trunk/hornetq-core/src/main/java/org/hornetq/core/protocol/stomp/StompDecoder.java
trunk/hornetq-core/src/main/java/org/hornetq/core/protocol/stomp/StompFrame.java
trunk/hornetq-core/src/main/java/org/hornetq/core/remoting/impl/netty/HttpAcceptorHandler.java
trunk/hornetq-core/src/main/java/org/hornetq/core/remoting/impl/netty/NettyConnector.java
trunk/hornetq-core/src/main/java/org/hornetq/core/server/impl/ServerInfo.java
trunk/hornetq-core/src/main/java/org/hornetq/core/transaction/impl/ResourceManagerImpl.java
trunk/hornetq-core/src/main/java/org/hornetq/utils/json/JSONArray.java
trunk/hornetq-jms/src/main/java/org/hornetq/api/jms/HornetQJMSClient.java
trunk/pom.xml
trunk/tests/concurrent-tests/src/test/java/org/hornetq/tests/concurrent/stomp/ConcurrentStompTest.java
Log:
Address several Findbugs reports, and add an excludes filter-file
Modified: trunk/etc/checkstyle.xml
===================================================================
--- trunk/etc/checkstyle.xml 2012-01-05 18:24:11 UTC (rev 11981)
+++ trunk/etc/checkstyle.xml 2012-01-06 11:35:50 UTC (rev 11982)
@@ -26,7 +26,9 @@
<module name="RedundantModifier"/>
<!-- Checks for blocks. You know, those {}'s -->
- <!-- <module name="LeftCurly"/> -->
+ <module name="LeftCurly">
+ <property name="option" value="nl"/>>
+ </module>
<!-- Checks for common coding problems -->
<!-- Disabled until
http://sourceforge.net/tracker/?func=detail&aid=2843447&group_id=...
is fixed-->
Added: trunk/etc/findbugs-exclude.xml
===================================================================
--- trunk/etc/findbugs-exclude.xml (rev 0)
+++ trunk/etc/findbugs-exclude.xml 2012-01-06 11:35:50 UTC (rev 11982)
@@ -0,0 +1,35 @@
+<FindBugsFilter>
+
+ <Match>
+ <!-- Having str restored to null is fine for our purposes -->
+ <Class name="org.hornetq.api.core.SimpleString"/>
+ <Field name="str"/>
+ <Bug pattern="SE_TRANSIENT_FIELD_NOT_RESTORED"/>
+ </Match>
+
+ <Match>
+ <!-- The whole point of SimpleString is to expose this data without any
performance penalty -->
+ <Class name="org.hornetq.api.core.SimpleString"/>
+ <method name="getData"/>
+ <Bug pattern="EI_EXPOSE_REP"/>
+ </Match>
+
+ <Match>
+ <!-- As per Java Messaging Specification 3.5.4:
+
+ "
+ Attempting to read a null value as a Java primitive type must be treated
+ as calling the primitive’s corresponding valueOf(String) conversion method
+ with a null value.
+ "
+
+ so methods are passed null arguments to trigger the exact same exceptions.
+ -->
+ <Class name="org.hornetq.utils.TypedProperties"/>
+ <Or>
+ <Method name="getFloatProperty"/>
+ <Method name="getDoubleProperty"/>
+ </Or>
+ <Bug pattern="NP_NULL_PARAM_DEREF_NONVIRTUAL"/>
+</Match>
+</FindBugsFilter>
Modified: trunk/hornetq-commons/src/main/java/org/hornetq/api/core/SimpleString.java
===================================================================
--- trunk/hornetq-commons/src/main/java/org/hornetq/api/core/SimpleString.java 2012-01-05
18:24:11 UTC (rev 11981)
+++ trunk/hornetq-commons/src/main/java/org/hornetq/api/core/SimpleString.java 2012-01-06
11:35:50 UTC (rev 11982)
@@ -29,7 +29,7 @@
*
*/
-public class SimpleString implements CharSequence, Serializable,
Comparable<SimpleString>
+public final class SimpleString implements CharSequence, Serializable,
Comparable<SimpleString>
{
private static final long serialVersionUID = 4204223851422244307L;
Modified:
trunk/hornetq-core/src/main/java/org/hornetq/core/client/impl/ClientSessionFactoryImpl.java
===================================================================
---
trunk/hornetq-core/src/main/java/org/hornetq/core/client/impl/ClientSessionFactoryImpl.java 2012-01-05
18:24:11 UTC (rev 11981)
+++
trunk/hornetq-core/src/main/java/org/hornetq/core/client/impl/ClientSessionFactoryImpl.java 2012-01-06
11:35:50 UTC (rev 11982)
@@ -1316,7 +1316,7 @@
}
@Override
- public void finalize() throws Throwable
+ protected void finalize() throws Throwable
{
if (!closed && finalizeCheck)
{
Modified:
trunk/hornetq-core/src/main/java/org/hornetq/core/client/impl/ServerLocatorImpl.java
===================================================================
---
trunk/hornetq-core/src/main/java/org/hornetq/core/client/impl/ServerLocatorImpl.java 2012-01-05
18:24:11 UTC (rev 11981)
+++
trunk/hornetq-core/src/main/java/org/hornetq/core/client/impl/ServerLocatorImpl.java 2012-01-06
11:35:50 UTC (rev 11982)
@@ -1667,7 +1667,7 @@
}
@Override
- public void finalize() throws Throwable
+ protected void finalize() throws Throwable
{
if (state != STATE.CLOSED && finalizeCheck)
{
Modified: trunk/hornetq-core/src/main/java/org/hornetq/core/filter/impl/FilterImpl.java
===================================================================
---
trunk/hornetq-core/src/main/java/org/hornetq/core/filter/impl/FilterImpl.java 2012-01-05
18:24:11 UTC (rev 11981)
+++
trunk/hornetq-core/src/main/java/org/hornetq/core/filter/impl/FilterImpl.java 2012-01-06
11:35:50 UTC (rev 11982)
@@ -25,14 +25,14 @@
/**
* This class implements a HornetQ filter
-*
+*
* @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
* @author <a href="jmesnil(a)redhat.com">Jeff Mesnil</a>
-*
+*
* HornetQ filters have the same syntax as JMS 1.1 selectors, but the identifiers are
different.
-*
+*
* Valid identifiers that can be used are:
-*
+*
* HQPriority - the priority of the message
* HQTimestamp - the timestamp of the message
* HQDurable - "DURABLE" or "NON_DURABLE"
@@ -40,16 +40,16 @@
* HQSize - the encoded size of the full message in bytes
* HQUserID - the user specified ID string (if any)
* Any other identifers that appear in a filter expression represent header values for the
message
-*
+*
* String values must be set as <code>SimpleString</code>, not
<code>java.lang.String</code> (see JBMESSAGING-1307).
* Derived from JBoss MQ version by
-*
+*
* @author <a href="mailto:Norbert.Lataille@m4x.org">Norbert
Lataille</a>
* @author <a href="mailto:jplindfo@helsinki.fi">Juha Lindfors</a>
* @author <a href="mailto:jason@planet57.com">Jason Dillon</a>
* @author <a href="mailto:Scott.Stark@jboss.org">Scott Stark</a>
* @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
-*
+*
* @version $Revision: 3569 $
*
* $Id: Selector.java 3569 2008-01-15 21:14:04Z timfox $
@@ -174,9 +174,6 @@
}
}
- /* (non-Javadoc)
- * @see java.lang.Object#hashCode()
- */
@Override
public int hashCode()
{
@@ -186,9 +183,6 @@
return result;
}
- /* (non-Javadoc)
- * @see java.lang.Object#equals(java.lang.Object)
- */
@Override
public boolean equals(Object obj)
{
@@ -209,9 +203,6 @@
return true;
}
- /* (non-Javadoc)
- * @see java.lang.Object#toString()
- */
@Override
public String toString()
{
@@ -229,7 +220,7 @@
}
else if (FilterConstants.HORNETQ_PRIORITY.equals(fieldName))
{
- return new Integer(msg.getPriority());
+ return Integer.valueOf(msg.getPriority());
}
else if (FilterConstants.HORNETQ_TIMESTAMP.equals(fieldName))
{
Modified:
trunk/hornetq-core/src/main/java/org/hornetq/core/messagecounter/MessageCounter.java
===================================================================
---
trunk/hornetq-core/src/main/java/org/hornetq/core/messagecounter/MessageCounter.java 2012-01-05
18:24:11 UTC (rev 11981)
+++
trunk/hornetq-core/src/main/java/org/hornetq/core/messagecounter/MessageCounter.java 2012-01-06
11:35:50 UTC (rev 11982)
@@ -31,9 +31,9 @@
/**
* This class stores message count informations for a given queue
- *
+ *
* At intervals this class samples the queue for message count data
- *
+ *
* Note that the underlying queue *does not* update statistics every time a message
* is added since that would reall slow things down, instead we *sample* the queues at
* regular intervals - this means we are less intrusive on the queue
@@ -114,8 +114,8 @@
setHistoryLimit(daycountmax);
}
-
- private Runnable onTimeExecutor = new Runnable()
+
+ private final Runnable onTimeExecutor = new Runnable()
{
public void run()
{
@@ -124,7 +124,7 @@
long newMessagesAdded = latestMessagesAdded - lastMessagesAdded;
countTotal += newMessagesAdded;
-
+
lastMessagesAdded = latestMessagesAdded;
if (newMessagesAdded > 0)
@@ -137,7 +137,7 @@
// update message history
updateHistory(newMessagesAdded);
-
+
}
};
@@ -150,7 +150,7 @@
{
// Actor approach here: Instead of having the Counter locking the queue, we will
use the Queue's executor
// instead of possibly making an lock on the queue.
- // This way the scheduled Threads will be free to keep doing their pings in case
the server is busy with paging or
+ // This way the scheduled Threads will be free to keep doing their pings in case
the server is busy with paging or
// any other deliveries
serverQueue.getExecutor().execute(onTimeExecutor);
}
@@ -301,8 +301,8 @@
/**
* Get message counter history data as string in format
- *
- * "day count\n
+ *
+ * "day count\n
* Date 1, hour counter 0, hour counter 1, ..., hour counter 23\n
* Date 2, hour counter 0, hour counter 1, ..., hour counter 23\n
* .....
@@ -313,7 +313,7 @@
*/
public String getHistoryAsString()
{
- String ret = "";
+ StringBuilder ret = new StringBuilder();
// ensure history counters are up to date
updateHistory(0);
@@ -322,18 +322,18 @@
synchronized (dayCounters)
{
// first line: history day count
- ret += dayCounters.size() + "\n";
+ ret.append(dayCounters.size() + "\n");
// following lines: day counter data
for (int i = 0; i < dayCounters.size(); i++)
{
DayCounter counter = dayCounters.get(i);
- ret += counter.getDayCounterAsString() + "\n";
+ ret.append(counter.getDayCounterAsString() + "\n");
}
}
- return ret;
+ return ret.toString();
}
@Override
@@ -359,7 +359,7 @@
/**
* Update message counter history
- *
+ *
* @param newMessages number of new messages to add to the latest day counter
*/
private void updateHistory(final long newMessages)
@@ -437,7 +437,7 @@
/**
* Internal day counter class for one day hour based counter history
*/
- public static class DayCounter
+ public static final class DayCounter
{
static final int HOURS = 24;
@@ -500,7 +500,7 @@
}
/**
- * Update day counter hour array elements
+ * Update day counter hour array elements
*
* @param newMessages number of new messages since the counter was last updated.
*/
@@ -539,7 +539,7 @@
}
/**
- * Finalize day counter hour array elements
+ * Finalize day counter hour array elements
*/
void finalizeDayCounter()
{
@@ -568,25 +568,24 @@
}
/**
- * Return day counter data as string with format
- * "Date, hour counter 0, hour counter 1, ..., hour counter 23"
- *
- * @return String day counter data
+ * Return day counter data as string with format<br/>
+ * "Date, hour counter 0, hour counter 1, ..., hour counter 23".
+ * @return String day counter data
*/
String getDayCounterAsString()
{
// first element day counter date
DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.SHORT);
- String strData = dateFormat.format(date.getTime());
+ StringBuilder strData = new StringBuilder(dateFormat.format(date.getTime()));
// append 24 comma separated hour counter values
for (int i = 0; i < DayCounter.HOURS; i++)
{
- strData += "," + counters[i];
+ strData.append("," + counters[i]);
}
- return strData;
+ return strData.toString();
}
}
}
Modified:
trunk/hornetq-core/src/main/java/org/hornetq/core/messagecounter/impl/MessageCounterHelper.java
===================================================================
---
trunk/hornetq-core/src/main/java/org/hornetq/core/messagecounter/impl/MessageCounterHelper.java 2012-01-05
18:24:11 UTC (rev 11981)
+++
trunk/hornetq-core/src/main/java/org/hornetq/core/messagecounter/impl/MessageCounterHelper.java 2012-01-06
11:35:50 UTC (rev 11982)
@@ -61,7 +61,8 @@
return null;
}
- String ret = "<table
class=\"hornetq-message-counter\">\n" + "<tr>"
+ String ret0 =
+ "<table class=\"hornetq-message-counter\">\n" +
"<tr>"
+ "<th>Type</th>"
+ "<th>Name</th>"
+ "<th>Subscription</th>"
@@ -72,8 +73,8 @@
+ "<th>DepthDelta</th>"
+ "<th>Last Add</th>"
+ "<th>Last Update</th>"
- + "</tr>\n";
-
+ + "</tr>\n";
+ StringBuilder ret = new StringBuilder(ret0);
for (int i = 0; i < counters.length; i++)
{
MessageCounter counter = counters[i];
@@ -88,25 +89,25 @@
{
durableStr = Boolean.toString(counter.isDestinationDurable());
}
- ret += "<tr bgcolor=\"#" + (i % 2 == 0 ? "FFFFFF" :
"F0F0F0") + "\">";
+ ret.append("<tr bgcolor=\"#" + (i % 2 == 0 ?
"FFFFFF" : "F0F0F0") + "\">");
- ret += "<td>" + type + "</td>";
- ret += "<td>" + counter.getDestinationName() +
"</td>";
- ret += "<td>" + subscription + "</td>";
- ret += "<td>" + durableStr + "</td>";
- ret += "<td>" + counter.getCount() + "</td>";
- ret += "<td>" +
MessageCounterHelper.prettify(counter.getCountDelta()) + "</td>";
- ret += "<td>" +
MessageCounterHelper.prettify(counter.getMessageCount()) + "</td>";
- ret += "<td>" +
MessageCounterHelper.prettify(counter.getMessageCountDelta()) + "</td>";
- ret += "<td>" +
MessageCounterHelper.asDate(counter.getLastAddedMessageTime()) + "</td>";
- ret += "<td>" +
MessageCounterHelper.asDate(counter.getLastUpdate()) + "</td>";
+ ret.append("<td>" + type + "</td>");
+ ret.append("<td>" + counter.getDestinationName() +
"</td>");
+ ret.append("<td>" + subscription + "</td>");
+ ret.append("<td>" + durableStr + "</td>");
+ ret.append("<td>" + counter.getCount() +
"</td>");
+ ret.append("<td>" +
MessageCounterHelper.prettify(counter.getCountDelta()) + "</td>");
+ ret.append("<td>" +
MessageCounterHelper.prettify(counter.getMessageCount()) + "</td>");
+ ret.append("<td>" +
MessageCounterHelper.prettify(counter.getMessageCountDelta()) + "</td>");
+ ret.append("<td>" +
MessageCounterHelper.asDate(counter.getLastAddedMessageTime()) +
"</td>");
+ ret.append("<td>" +
MessageCounterHelper.asDate(counter.getLastUpdate()) + "</td>");
- ret += "</tr>\n";
+ ret.append("</tr>\n");
}
- ret += "</table>\n";
+ ret.append("</table>\n");
- return ret;
+ return ret.toString();
}
public static String listMessageCounterHistoryAsHTML(final MessageCounter[] counters)
@@ -116,36 +117,36 @@
return null;
}
- String ret = "<ul>\n";
+ StringBuilder ret = new StringBuilder("<ul>\n");
for (MessageCounter counter : counters)
{
- ret += "<li>\n";
- ret += " <ul>\n";
+ ret.append("<li>\n");
+ ret.append(" <ul>\n");
- ret += " <li>";
+ ret.append(" <li>");
// destination name
- ret += (counter.isDestinationTopic() ? "Topic '" : "Queue
'") + counter.getDestinationName() + "'";
- ret += "</li>\n";
+ ret.append((counter.isDestinationTopic() ? "Topic '" : "Queue
'") + counter.getDestinationName() + "'");
+ ret.append("</li>\n");
if (counter.getDestinationSubscription() != null)
{
- ret += " <li>";
- ret += "Subscription '" + counter.getDestinationSubscription()
+ "'";
- ret += "</li>\n";
+ ret.append(" <li>");
+ ret.append("Subscription '" +
counter.getDestinationSubscription() + "'");
+ ret.append("</li>\n");
}
- ret += " <li>";
+ ret.append(" <li>");
// table header
- ret += "<table
class=\"hornetq-message-counter-history\">\n";
- ret += "<tr><th>Date</th>";
+ ret.append("<table
class=\"hornetq-message-counter-history\">\n");
+ ret.append("<tr><th>Date</th>");
for (int j = 0; j < 24; j++)
{
- ret += "<th>" + j + "</th>";
+ ret.append("<th>" + j + "</th>");
}
- ret += "<th>Total</th></tr>\n";
+ ret.append("<th>Total</th></tr>\n");
// get history data as CSV string
StringTokenizer tokens = new StringTokenizer(counter.getHistoryAsString(),
",\n");
@@ -156,10 +157,10 @@
for (int j = 0; j < days; j++)
{
// next day counter row
- ret += "<tr bgcolor=\"#" + (j % 2 == 0 ? "FFFFFF"
: "F0F0F0") + "\">";
+ ret.append("<tr bgcolor=\"#" + (j % 2 == 0 ?
"FFFFFF" : "F0F0F0") + "\">");
// date
- ret += "<td>" + tokens.nextToken() +
"</td>";
+ ret.append("<td>" + tokens.nextToken() +
"</td>");
// 24 hour counters
int total = 0;
@@ -170,27 +171,27 @@
if (value == -1)
{
- ret += "<td></td>";
+ ret.append("<td></td>");
}
else
{
- ret += "<td>" + value + "</td>";
+ ret.append("<td>" + value + "</td>");
total += value;
}
}
- ret += "<td>" + total +
"</td></tr>\n";
+ ret.append("<td>" + total +
"</td></tr>\n");
}
- ret += "</table></li>\n";
- ret += " </ul>\n";
- ret += "</li>\n";
+ ret.append("</table></li>\n");
+ ret.append(" </ul>\n");
+ ret.append("</li>\n");
}
- ret += "</ul>\n";
+ ret.append("</ul>\n");
- return ret;
+ return ret.toString();
}
private static String prettify(final long value)
Modified:
trunk/hornetq-core/src/main/java/org/hornetq/core/paging/impl/PagingStoreImpl.java
===================================================================
---
trunk/hornetq-core/src/main/java/org/hornetq/core/paging/impl/PagingStoreImpl.java 2012-01-05
18:24:11 UTC (rev 11981)
+++
trunk/hornetq-core/src/main/java/org/hornetq/core/paging/impl/PagingStoreImpl.java 2012-01-06
11:35:50 UTC (rev 11982)
@@ -918,8 +918,7 @@
installPageTransaction(tx, listCtx);
tx.setWaitBeforeCommit(true);
}
- else
- if (sync && tx == null)
+ else if (sync)
{
sync();
}
Modified:
trunk/hornetq-core/src/main/java/org/hornetq/core/persistence/impl/journal/JournalStorageManager.java
===================================================================
---
trunk/hornetq-core/src/main/java/org/hornetq/core/persistence/impl/journal/JournalStorageManager.java 2012-01-05
18:24:11 UTC (rev 11981)
+++
trunk/hornetq-core/src/main/java/org/hornetq/core/persistence/impl/journal/JournalStorageManager.java 2012-01-06
11:35:50 UTC (rev 11982)
@@ -3258,7 +3258,7 @@
}
- private class FinishPageMessageOperation implements TransactionOperation
+ private static class FinishPageMessageOperation implements TransactionOperation
{
public void afterCommit(final Transaction tx)
@@ -3332,27 +3332,21 @@
long value;
- /* (non-Javadoc)
- * @see org.hornetq.core.journal.EncodingSupport#getEncodeSize()
- */
+ @Override
public int getEncodeSize()
{
return DataConstants.SIZE_LONG * 2;
}
- /* (non-Javadoc)
- * @see
org.hornetq.core.journal.EncodingSupport#encode(org.hornetq.api.core.HornetQBuffer)
- */
+ @Override
public void encode(HornetQBuffer buffer)
{
buffer.writeLong(queueID);
buffer.writeLong(value);
}
- /* (non-Javadoc)
- * @see
org.hornetq.core.journal.EncodingSupport#decode(org.hornetq.api.core.HornetQBuffer)
- */
- public void decode(HornetQBuffer buffer)
+ @Override
+ public void decode(HornetQBuffer buffer)
{
queueID = buffer.readLong();
value = buffer.readLong();
Modified:
trunk/hornetq-core/src/main/java/org/hornetq/core/postoffice/impl/DuplicateIDCacheImpl.java
===================================================================
---
trunk/hornetq-core/src/main/java/org/hornetq/core/postoffice/impl/DuplicateIDCacheImpl.java 2012-01-05
18:24:11 UTC (rev 11981)
+++
trunk/hornetq-core/src/main/java/org/hornetq/core/postoffice/impl/DuplicateIDCacheImpl.java 2012-01-06
11:35:50 UTC (rev 11982)
@@ -228,16 +228,12 @@
// The recordID could be negative if the duplicateCache is configured to not
persist,
// -1 would mean null on this case
id.setB(recordID >= 0 ? recordID : null);
-
- holder.pos = pos;
}
else
{
id = new Pair<ByteArrayHolder, Long>(holder, recordID >= 0 ? recordID :
null);
ids.add(id);
-
- holder.pos = pos;
}
if (pos++ == cacheSize - 1)
@@ -314,8 +310,6 @@
int hash;
- int pos;
-
@Override
public boolean equals(final Object other)
{
Modified:
trunk/hornetq-core/src/main/java/org/hornetq/core/protocol/stomp/HornetQStompException.java
===================================================================
---
trunk/hornetq-core/src/main/java/org/hornetq/core/protocol/stomp/HornetQStompException.java 2012-01-05
18:24:11 UTC (rev 11981)
+++
trunk/hornetq-core/src/main/java/org/hornetq/core/protocol/stomp/HornetQStompException.java 2012-01-06
11:35:50 UTC (rev 11982)
@@ -17,18 +17,18 @@
import java.util.List;
/**
- *
+ *
* @author <a href="mailto:hgao@redhat.com">Howard Gao</a>
*/
public class HornetQStompException extends Exception {
private static final long serialVersionUID = -274452327574950068L;
-
- private List<Header> headers = new ArrayList<Header>(10);
+
+ private final List<Header> headers = new ArrayList<Header>(10);
private String body;
private VersionedStompFrameHandler handler;
private boolean disconnect;
-
+
public HornetQStompException(StompConnection connection, String msg)
{
super(msg);
@@ -38,13 +38,13 @@
{
super(msg);
}
-
+
public HornetQStompException(String msg, Throwable t)
{
super(msg, t);
this.body = t.getMessage();
}
-
+
public HornetQStompException(Throwable t)
{
super(t);
@@ -54,7 +54,7 @@
{
headers.add(new Header(header, value));
}
-
+
public void setBody(String body)
{
this.body = body;
@@ -91,11 +91,11 @@
return frame;
}
- private class Header
+ private static final class Header
{
- public String key;
- public String val;
-
+ public final String key;
+ public final String val;
+
public Header(String key, String val)
{
this.key = key;
Modified:
trunk/hornetq-core/src/main/java/org/hornetq/core/protocol/stomp/StompDecoder.java
===================================================================
---
trunk/hornetq-core/src/main/java/org/hornetq/core/protocol/stomp/StompDecoder.java 2012-01-05
18:24:11 UTC (rev 11981)
+++
trunk/hornetq-core/src/main/java/org/hornetq/core/protocol/stomp/StompDecoder.java 2012-01-06
11:35:50 UTC (rev 11982)
@@ -17,7 +17,6 @@
import java.util.Map;
import org.hornetq.api.core.HornetQBuffer;
-import org.hornetq.core.logging.Logger;
/**
* A StompDecoder
@@ -28,8 +27,6 @@
*/
public class StompDecoder
{
- private static final Logger log = Logger.getLogger(StompDecoder.class);
-
public static final boolean TRIM_LEADING_HEADER_VALUE_WHITESPACE = true;
public static final String COMMAND_ABORT = "ABORT";
@@ -80,7 +77,7 @@
public static final String COMMAND_CONNECTED = "CONNECTED";
public static final int COMMAND_CONNECTED_LENGTH = COMMAND_CONNECTED.length();
-
+
public static final String COMMAND_MESSAGE = "MESSAGE";
public static final int COMMAND_MESSAGE_LENGTH = COMMAND_MESSAGE.length();
@@ -109,13 +106,13 @@
public static final byte M = (byte)'M';
public static final byte S = (byte)'S';
-
+
public static final byte R = (byte)'R';
public static final byte U = (byte)'U';
public static final byte N = (byte)'N';
-
+
public static final byte LN = (byte)'n';
public static final byte HEADER_SEPARATOR = (byte)':';
@@ -128,7 +125,7 @@
public static final String CONTENT_TYPE_HEADER_NAME = "content-type";
- public static String CONTENT_LENGTH_HEADER_NAME = "content-length";
+ public static final String CONTENT_LENGTH_HEADER_NAME = "content-length";
public byte[] workingBuffer = new byte[1024];
@@ -153,11 +150,11 @@
public boolean whiteSpaceOnly;
public int contentLength;
-
+
public String contentType;
public int bodyStart;
-
+
public StompConnection connection;
public StompDecoder(StompConnection stompConnection)
@@ -182,7 +179,7 @@
* followed by an empty line
* followed by an optional message body
* terminated with a null character
- *
+ *
* Note: to support both 1.0 and 1.1, we just assemble a
* standard StompFrame and let the versioned handler to do more
* spec specific job (like trimming, escaping etc).
@@ -194,10 +191,10 @@
VersionedStompFrameHandler handler = connection.getFrameHandler();
return handler.decode(this, buffer);
}
-
+
return defaultDecode(buffer);
}
-
+
public StompFrame defaultDecode(final HornetQBuffer buffer) throws
HornetQStompException
{
@@ -291,7 +288,7 @@
command = COMMAND_COMMIT;
}
/**** added by meddy, 27 april 2011, handle header parser for reply to
websocket protocol ****/
- else if (workingBuffer[offset+7]==E)
+ else if (workingBuffer[offset+7]==E)
{
if (!tryIncrement(offset + COMMAND_CONNECTED_LENGTH + 1))
{
@@ -299,7 +296,7 @@
}
// CONNECTED
- command = COMMAND_CONNECTED;
+ command = COMMAND_CONNECTED;
}
/**** end ****/
else
@@ -384,7 +381,7 @@
}
// SEND
- command = COMMAND_STOMP;
+ command = COMMAND_STOMP;
}
else
{
@@ -569,7 +566,7 @@
}
}
}
-
+
if (content != null)
{
if (data > pos)
@@ -594,7 +591,7 @@
else
{
return null;
- }
+ }
}
public void throwInvalid() throws HornetQStompException
@@ -607,7 +604,7 @@
pos = 0;
command = null;
-
+
headers = new HashMap<String, String>();
this.headerBytesCopyStart = -1;
@@ -625,7 +622,7 @@
contentLength = -1;
contentType = null;
-
+
bodyStart = -1;
}
@@ -659,11 +656,11 @@
for (int i = 0; i < data; i++)
{
char b = (char)bytes[i];
-
+
if (b < 33 || b > 136)
{
//Unreadable characters
-
+
str.append(bytes[i]);
}
else
Modified:
trunk/hornetq-core/src/main/java/org/hornetq/core/protocol/stomp/StompFrame.java
===================================================================
---
trunk/hornetq-core/src/main/java/org/hornetq/core/protocol/stomp/StompFrame.java 2012-01-05
18:24:11 UTC (rev 11981)
+++
trunk/hornetq-core/src/main/java/org/hornetq/core/protocol/stomp/StompFrame.java 2012-01-06
11:35:50 UTC (rev 11982)
@@ -18,6 +18,7 @@
package org.hornetq.core.protocol.stomp;
import java.io.UnsupportedEncodingException;
+import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Map.Entry;
@@ -31,7 +32,7 @@
*
* @author <a href="http://hiramchirino.com">chirino</a>
* @author Tim Fox
- *
+ *
*/
public class StompFrame
{
@@ -46,17 +47,17 @@
protected Map<String, String> headers;
protected String body;
-
+
protected byte[] bytesBody;
protected HornetQBuffer buffer = null;
protected int size;
-
+
protected boolean disconnect;
-
+
protected boolean isPing;
-
+
public StompFrame(String command)
{
this(command, false);
@@ -94,31 +95,32 @@
@Override
public String toString()
{
- return "StompFrame[command=" + command + ", headers=" + headers
+ ", content= " + this.body + " bytes " + this.bytesBody;
+ return "StompFrame[command=" + command + ", headers=" + headers
+ ", content= " + this.body + " bytes " +
+ Arrays.toString(bytesBody);
}
public String asString()
{
- String out = command + '\n';
+ StringBuilder out = new StringBuilder(command + '\n');
for (Entry<String, String> header : headers.entrySet())
{
- out += header.getKey() + ": " + header.getValue() + '\n';
+ out.append(header.getKey() + ": " + header.getValue() +
'\n');
}
- out += '\n';
- out += body;
- return out;
+ out.append('\n');
+ out.append(body);
+ return out.toString();
}
-
+
public boolean isPing()
{
return isPing;
}
-
+
public void setPing(boolean ping)
{
isPing = ping;
}
-
+
public HornetQBuffer toHornetQBuffer() throws Exception
{
if (buffer == null)
@@ -173,17 +175,17 @@
{
headers.put(key, val);
}
-
+
public Map<String, String> getHeadersMap()
{
return headers;
}
-
+
public static class Header
{
public String key;
public String val;
-
+
public Header(String key, String val)
{
this.key = key;
@@ -199,11 +201,11 @@
{
return escape(val);
}
-
+
public static String escape(String str)
{
int len = str.length();
-
+
char[] buffer = new char[2*len];
int iBuffer = 0;
for (int i = 0; i < len; i++)
@@ -230,10 +232,10 @@
}
iBuffer++;
}
-
+
char[] total = new char[iBuffer];
System.arraycopy(buffer, 0, total, 0, iBuffer);
-
+
return new String(total);
}
}
@@ -260,7 +262,7 @@
}
return body;
}
-
+
//Since 1.1, there is a content-type header that needs to take care of
public byte[] getBodyAsBytes() throws UnsupportedEncodingException
{
Modified:
trunk/hornetq-core/src/main/java/org/hornetq/core/remoting/impl/netty/HttpAcceptorHandler.java
===================================================================
---
trunk/hornetq-core/src/main/java/org/hornetq/core/remoting/impl/netty/HttpAcceptorHandler.java 2012-01-05
18:24:11 UTC (rev 11981)
+++
trunk/hornetq-core/src/main/java/org/hornetq/core/remoting/impl/netty/HttpAcceptorHandler.java 2012-01-06
11:35:50 UTC (rev 11982)
@@ -131,7 +131,7 @@
/**
* this is prompted to delivery when a response is available in the response queue.
*/
- class ResponseRunner implements Runnable
+ final class ResponseRunner implements Runnable
{
private final ChannelBuffer buffer;
@@ -211,8 +211,8 @@
}
}
-
-
+
+
public void shutdown()
{
executor.shutdown();
@@ -228,7 +228,7 @@
/**
* a holder class so we know what time the request first arrived
*/
- private class ResponseHolder
+ private static final class ResponseHolder
{
final HttpResponse response;
Modified:
trunk/hornetq-core/src/main/java/org/hornetq/core/remoting/impl/netty/NettyConnector.java
===================================================================
---
trunk/hornetq-core/src/main/java/org/hornetq/core/remoting/impl/netty/NettyConnector.java 2012-01-05
18:24:11 UTC (rev 11981)
+++
trunk/hornetq-core/src/main/java/org/hornetq/core/remoting/impl/netty/NettyConnector.java 2012-01-06
11:35:50 UTC (rev 11982)
@@ -524,7 +524,7 @@
// Inner classes -------------------------------------------------
- private final class HornetQClientChannelHandler extends HornetQChannelHandler
+ private static final class HornetQClientChannelHandler extends HornetQChannelHandler
{
HornetQClientChannelHandler(final ChannelGroup group,
final BufferHandler handler,
Modified: trunk/hornetq-core/src/main/java/org/hornetq/core/server/impl/ServerInfo.java
===================================================================
---
trunk/hornetq-core/src/main/java/org/hornetq/core/server/impl/ServerInfo.java 2012-01-05
18:24:11 UTC (rev 11981)
+++
trunk/hornetq-core/src/main/java/org/hornetq/core/server/impl/ServerInfo.java 2012-01-06
11:35:50 UTC (rev 11982)
@@ -61,47 +61,39 @@
double availableMemoryPercent = 100.0 * availableMemory / maxMemory;
ThreadMXBean threadMXBean = ManagementFactory.getThreadMXBean();
- String info = "\n**** Server Dump ****\n";
- info += String.format("date: %s\n", new Date());
- info += String.format("free memory: %s\n",
SizeFormatterUtil.sizeof(freeMemory));
- info += String.format("max memory: %s\n",
SizeFormatterUtil.sizeof(maxMemory));
- info += String.format("total memory: %s\n",
SizeFormatterUtil.sizeof(totalMemory));
- info += String.format("available memory: %.2f%%\n",
availableMemoryPercent);
- info += appendPagingInfos();
- info += String.format("# of thread: %d\n",
threadMXBean.getThreadCount());
- info += String.format("# of conns: %d\n",
server.getConnectionCount());
- info += "********************\n";
- return info;
+ StringBuilder info = new StringBuilder("\n**** Server Dump ****\n");
+ info.append(String.format("date: %s\n", new Date()));
+ info.append(String.format("free memory: %s\n",
SizeFormatterUtil.sizeof(freeMemory)));
+ info.append(String.format("max memory: %s\n",
SizeFormatterUtil.sizeof(maxMemory)));
+ info.append(String.format("total memory: %s\n",
SizeFormatterUtil.sizeof(totalMemory)));
+ info.append(String.format("available memory: %.2f%%\n",
availableMemoryPercent));
+ info.append(appendPagingInfos());
+ info.append(String.format("# of thread: %d\n",
threadMXBean.getThreadCount()));
+ info.append(String.format("# of conns: %d\n",
server.getConnectionCount()));
+ info.append("********************\n");
+ return info.toString();
}
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
private String appendPagingInfos()
{
- String info = "";
-
+ StringBuilder info = new StringBuilder();
+
for (SimpleString storeName : pagingManager.getStoreNames())
{
PagingStore pageStore;
try
{
pageStore = pagingManager.getPageStore(storeName);
- info += String.format("\t%s: %s\n",
+ info.append(String.format("\t%s: %s\n",
storeName,
- SizeFormatterUtil.sizeof(pageStore.getPageSizeBytes() *
pageStore.getNumberOfPages()));
+
SizeFormatterUtil.sizeof(pageStore.getPageSizeBytes() *
+ pageStore.getNumberOfPages())));
}
catch (Exception e)
{
- info += String.format("\t%s: %s\n", storeName, e.getMessage());
+ info.append(String.format("\t%s: %s\n", storeName,
e.getMessage()));
}
}
- return info;
+ return info.toString();
}
-
- // Inner classes -------------------------------------------------
-
}
Modified:
trunk/hornetq-core/src/main/java/org/hornetq/core/transaction/impl/ResourceManagerImpl.java
===================================================================
---
trunk/hornetq-core/src/main/java/org/hornetq/core/transaction/impl/ResourceManagerImpl.java 2012-01-05
18:24:11 UTC (rev 11981)
+++
trunk/hornetq-core/src/main/java/org/hornetq/core/transaction/impl/ResourceManagerImpl.java 2012-01-06
11:35:50 UTC (rev 11982)
@@ -251,7 +251,7 @@
}
- private class HeuristicCompletionHolder
+ private static final class HeuristicCompletionHolder
{
public final boolean isCommit;
Modified: trunk/hornetq-core/src/main/java/org/hornetq/utils/json/JSONArray.java
===================================================================
--- trunk/hornetq-core/src/main/java/org/hornetq/utils/json/JSONArray.java 2012-01-05
18:24:11 UTC (rev 11981)
+++ trunk/hornetq-core/src/main/java/org/hornetq/utils/json/JSONArray.java 2012-01-06
11:35:50 UTC (rev 11982)
@@ -150,7 +150,7 @@
case ')':
if (q != c)
{
- throw x.syntaxError("Expected a '" + new Character(q) +
"'");
+ throw x.syntaxError("Expected a '" + Character.valueOf(q)
+ "'");
}
return;
default:
@@ -183,7 +183,7 @@
/**
* Construct a JSONArray from a collection of beans.
* The collection should have Java Beans.
- *
+ *
* @throws JSONException If not an array.
*/
@@ -236,7 +236,7 @@
/**
* Construct a JSONArray from an array with a bean.
* The array should have Java Beans.
- *
+ *
* @throws JSONException If not an array.
*/
public JSONArray(final Object array, final boolean includeSuperClass) throws
JSONException
@@ -688,7 +688,7 @@
*/
public JSONArray put(final int value)
{
- put(new Integer(value));
+ put(Integer.valueOf(value));
return this;
}
@@ -700,7 +700,7 @@
*/
public JSONArray put(final long value)
{
- put(new Long(value));
+ put(Long.valueOf(value));
return this;
}
@@ -786,7 +786,7 @@
*/
public JSONArray put(final int index, final int value) throws JSONException
{
- put(index, new Integer(value));
+ put(index, Integer.valueOf(value));
return this;
}
@@ -801,7 +801,7 @@
*/
public JSONArray put(final int index, final long value) throws JSONException
{
- put(index, new Long(value));
+ put(index, Long.valueOf(value));
return this;
}
@@ -910,19 +910,17 @@
}
catch (Exception e)
{
- return null;
+ return "";
}
}
/**
- * Make a prettyprinted JSON text of this JSONArray.
- * Warning: This method assumes that the data structure is acyclical.
- * @param indentFactor The number of spaces to add to each level of
- * indentation.
- * @return a printable, displayable, transmittable
- * representation of the object, beginning
- * with <code>[</code> <small>(left bracket)</small>
and ending
- * with <code>]</code> <small>(right
bracket)</small>.
+ * Make a pretty-printed JSON text of this JSONArray. Warning: This method assumes
that the data
+ * structure is acyclical.
+ * @param indentFactor The number of spaces to add to each level of indentation.
+ * @return a printable, displayable, transmittable representation of the object,
beginning with
+ * <code>[</code> <small>(left
bracket)</small> and ending with <code>]</code>
+ * <small>(right bracket)</small>.
* @throws JSONException
*/
public String toString(final int indentFactor) throws JSONException
@@ -931,13 +929,11 @@
}
/**
- * Make a prettyprinted JSON text of this JSONArray.
- * Warning: This method assumes that the data structure is acyclical.
- * @param indentFactor The number of spaces to add to each level of
- * indentation.
+ * Make a pretty-printed JSON text of this JSONArray. Warning: This method assumes
that the data
+ * structure is acyclical.
+ * @param indentFactor The number of spaces to add to each level of indentation.
* @param indent The indention of the top level.
- * @return a printable, displayable, transmittable
- * representation of the array.
+ * @return a printable, displayable, transmittable representation of the array.
* @throws JSONException
*/
String toString(final int indentFactor, final int indent) throws JSONException
Modified: trunk/hornetq-jms/src/main/java/org/hornetq/api/jms/HornetQJMSClient.java
===================================================================
--- trunk/hornetq-jms/src/main/java/org/hornetq/api/jms/HornetQJMSClient.java 2012-01-05
18:24:11 UTC (rev 11981)
+++ trunk/hornetq-jms/src/main/java/org/hornetq/api/jms/HornetQJMSClient.java 2012-01-06
11:35:50 UTC (rev 11982)
@@ -17,7 +17,6 @@
import org.hornetq.api.core.DiscoveryGroupConfiguration;
import org.hornetq.api.core.TransportConfiguration;
-import org.hornetq.core.logging.Logger;
import org.hornetq.jms.client.HornetQConnectionFactory;
import org.hornetq.jms.client.HornetQDestination;
import org.hornetq.jms.client.HornetQJMSConnectionFactory;
@@ -34,14 +33,18 @@
*/
public class HornetQJMSClient
{
- private static final Logger log = Logger.getLogger(HornetQJMSClient.class);
/**
- * Create a HornetQConnectionFactory which will receive cluster topology updates from
the cluster as servers leave or join and new backups are appointed or removed.
- * The discoveryAddress and discoveryPort parameters in this method are used to listen
for UDP broadcasts which contain connection information for members of the cluster.
- * The broadcasted connection information is simply used to make an initial connection
to the cluster, once that connection is made, up to date
- * cluster topology information is downloaded and automatically updated whenever the
cluster topology changes. If the topology includes backup servers
- * that information is also propagated to the client so that it can know which server
to failover onto in case of live server failure.
+ * Creates a HornetQConnectionFactory that receives cluster topology updates from the
cluster as
+ * servers leave or join and new backups are appointed or removed.
+ * <p>
+ * The discoveryAddress and discoveryPort parameters in this method are used to listen
for UDP
+ * broadcasts which contain connection information for members of the cluster. The
broadcasted
+ * connection information is simply used to make an initial connection to the cluster,
once that
+ * connection is made, up to date cluster topology information is downloaded and
automatically
+ * updated whenever the cluster topology changes. If the topology includes backup
servers that
+ * information is also propagated to the client so that it can know which server to
failover onto
+ * in case of live server failure.
* @param discoveryAddress The UDP group address to listen for updates
* @param discoveryPort the UDP port to listen for updates
* @return the HornetQConnectionFactory
@@ -73,15 +76,15 @@
{
factory = new HornetQXATopicConnectionFactory(true, groupConfiguration);
}
-
+
return factory;
}
/**
* Create a HornetQConnectionFactory which creates session factories from a set of
live servers, no HA backup information is propagated to the client
- *
+ *
* The UDP address and port are used to listen for live servers in the cluster
- *
+ *
* @param discoveryAddress The UDP group address to listen for updates
* @param discoveryPort the UDP port to listen for updates
* @return the HornetQConnectionFactory
@@ -113,10 +116,10 @@
{
factory = new HornetQXATopicConnectionFactory(false, groupConfiguration);
}
-
+
return factory;
}
-
+
/**
* Create a HornetQConnectionFactory which will receive cluster topology updates from
the cluster as servers leave or join and new backups are appointed or removed.
* The initial list of servers supplied in this method is simply to make an initial
connection to the cluster, once that connection is made, up to date
@@ -153,14 +156,14 @@
{
factory = new HornetQXATopicConnectionFactory(true, initialServers);
}
-
+
return factory;
}
/**
* Create a HornetQConnectionFactory which creates session factories using a static
list of transportConfigurations, the HornetQConnectionFactory is not updated
automatically
* as the cluster topology changes, and no HA backup information is propagated to the
client
- *
+ *
* @param transportConfigurations
* @return the HornetQConnectionFactory
*/
@@ -191,10 +194,10 @@
{
factory = new HornetQXATopicConnectionFactory(false, transportConfigurations);
}
-
+
return factory;
}
-
+
/**
* Creates a client-side representation of a JMS Topic.
*
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2012-01-05 18:24:11 UTC (rev 11981)
+++ trunk/pom.xml 2012-01-06 11:35:50 UTC (rev 11982)
@@ -562,6 +562,7 @@
<artifactId>findbugs-maven-plugin</artifactId>
<version>2.3.3</version>
<configuration>
+
<excludeFilterFile>${user.dir}/etc/findbugs-exclude.xml</excludeFilterFile>
<findbugsXmlOutput>true</findbugsXmlOutput>
<xmlOutput>true</xmlOutput>
<effort>Max</effort>
@@ -621,6 +622,7 @@
<artifactId>findbugs-maven-plugin</artifactId>
<version>2.3.3</version>
<configuration>
+
<excludeFilterFile>${user.dir}/etc/findbugs-exclude.xml</excludeFilterFile>
<xmlOutput>true</xmlOutput>
<effort>Max</effort>
</configuration>
Modified:
trunk/tests/concurrent-tests/src/test/java/org/hornetq/tests/concurrent/stomp/ConcurrentStompTest.java
===================================================================
---
trunk/tests/concurrent-tests/src/test/java/org/hornetq/tests/concurrent/stomp/ConcurrentStompTest.java 2012-01-05
18:24:11 UTC (rev 11981)
+++
trunk/tests/concurrent-tests/src/test/java/org/hornetq/tests/concurrent/stomp/ConcurrentStompTest.java 2012-01-06
11:35:50 UTC (rev 11982)
@@ -27,7 +27,6 @@
import org.hornetq.api.core.TransportConfiguration;
import org.hornetq.core.config.Configuration;
import org.hornetq.core.config.CoreQueueConfiguration;
-import org.hornetq.core.logging.Logger;
import org.hornetq.core.protocol.stomp.Stomp;
import org.hornetq.core.remoting.impl.invm.InVMAcceptorFactory;
import org.hornetq.core.remoting.impl.netty.NettyAcceptorFactory;
@@ -39,8 +38,6 @@
public class ConcurrentStompTest extends UnitTestCase
{
- private static final transient Logger log =
Logger.getLogger(ConcurrentStompTest.class);
-
private final int port = 61613;
private Socket stompSocket;