JBoss hornetq SVN: r12001 - in trunk/hornetq-core/src/main/java/org/hornetq/core: protocol/core/impl/wireformat and 1 other directories.
by do-not-reply@jboss.org
Author: borges
Date: 2012-01-09 06:18:03 -0500 (Mon, 09 Jan 2012)
New Revision: 12001
Modified:
trunk/hornetq-core/src/main/java/org/hornetq/core/protocol/core/impl/PacketImpl.java
trunk/hornetq-core/src/main/java/org/hornetq/core/protocol/core/impl/wireformat/BackupRegistrationFailedMessage.java
trunk/hornetq-core/src/main/java/org/hornetq/core/protocol/core/impl/wireformat/BackupRegistrationMessage.java
trunk/hornetq-core/src/main/java/org/hornetq/core/protocol/core/impl/wireformat/DisconnectMessage.java
trunk/hornetq-core/src/main/java/org/hornetq/core/protocol/core/impl/wireformat/HornetQExceptionMessage.java
trunk/hornetq-core/src/main/java/org/hornetq/core/protocol/core/impl/wireformat/PacketsConfirmedMessage.java
trunk/hornetq-core/src/main/java/org/hornetq/core/protocol/core/impl/wireformat/Ping.java
trunk/hornetq-core/src/main/java/org/hornetq/core/version/impl/VersionImpl.java
Log:
Override equals and hashCode consistently.
Modified: trunk/hornetq-core/src/main/java/org/hornetq/core/protocol/core/impl/PacketImpl.java
===================================================================
--- trunk/hornetq-core/src/main/java/org/hornetq/core/protocol/core/impl/PacketImpl.java 2012-01-09 11:17:36 UTC (rev 12000)
+++ trunk/hornetq-core/src/main/java/org/hornetq/core/protocol/core/impl/PacketImpl.java 2012-01-09 11:18:03 UTC (rev 12001)
@@ -14,7 +14,6 @@
package org.hornetq.core.protocol.core.impl;
import org.hornetq.api.core.HornetQBuffer;
-import org.hornetq.core.logging.Logger;
import org.hornetq.core.protocol.core.Packet;
import org.hornetq.spi.core.protocol.RemotingConnection;
import org.hornetq.utils.DataConstants;
@@ -28,9 +27,8 @@
{
// Constants -------------------------------------------------------------------------
- private static final Logger log = Logger.getLogger(PacketImpl.class);
-
- // The minimal size for all the packets, Common data for all the packets (look at PacketImpl.encode)
+ // The minimal size for all the packets, Common data for all the packets (look at
+ // PacketImpl.encode)
public static final int PACKET_HEADERS_SIZE = DataConstants.SIZE_INT + DataConstants.SIZE_BYTE +
DataConstants.SIZE_LONG;
@@ -302,20 +300,31 @@
}
@Override
- public boolean equals(final Object other)
+ public int hashCode()
{
- if (other instanceof PacketImpl == false)
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + (int)(channelID ^ (channelID >>> 32));
+ result = prime * result + size;
+ result = prime * result + type;
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (this == obj)
{
+ return true;
+ }
+ if (!(obj instanceof PacketImpl))
+ {
return false;
}
-
- PacketImpl r = (PacketImpl)other;
-
- return r.type == type && r.channelID == channelID;
+ PacketImpl other = (PacketImpl)obj;
+ return (channelID == other.channelID) && (size == other.size) && (type != other.type);
}
- // Package protected ---------------------------------------------
-
protected String getParentString()
{
return "PACKET(" + this.getClass().getSimpleName() + ")[type=" + type + ", channelID=" + channelID + ", packetObject=" + this.getClass().getSimpleName();
Modified: trunk/hornetq-core/src/main/java/org/hornetq/core/protocol/core/impl/wireformat/BackupRegistrationFailedMessage.java
===================================================================
--- trunk/hornetq-core/src/main/java/org/hornetq/core/protocol/core/impl/wireformat/BackupRegistrationFailedMessage.java 2012-01-09 11:17:36 UTC (rev 12000)
+++ trunk/hornetq-core/src/main/java/org/hornetq/core/protocol/core/impl/wireformat/BackupRegistrationFailedMessage.java 2012-01-09 11:18:03 UTC (rev 12001)
@@ -79,4 +79,41 @@
errorCode = buffer.readInt();
}
}
+
+ @Override
+ public int hashCode()
+ {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + errorCode;
+ result = prime * result + ((problem == null) ? 0 : problem.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (this == obj)
+ {
+ return true;
+ }
+ if (!super.equals(obj))
+ {
+ return false;
+ }
+ if (!(obj instanceof BackupRegistrationFailedMessage))
+ {
+ return false;
+ }
+ BackupRegistrationFailedMessage other = (BackupRegistrationFailedMessage)obj;
+ if (errorCode != other.errorCode)
+ {
+ return false;
+ }
+ if (problem != other.problem)
+ {
+ return false;
+ }
+ return true;
+ }
}
Modified: trunk/hornetq-core/src/main/java/org/hornetq/core/protocol/core/impl/wireformat/BackupRegistrationMessage.java
===================================================================
--- trunk/hornetq-core/src/main/java/org/hornetq/core/protocol/core/impl/wireformat/BackupRegistrationMessage.java 2012-01-09 11:17:36 UTC (rev 12000)
+++ trunk/hornetq-core/src/main/java/org/hornetq/core/protocol/core/impl/wireformat/BackupRegistrationMessage.java 2012-01-09 11:18:03 UTC (rev 12001)
@@ -83,4 +83,79 @@
return clusterPassword;
}
+ @Override
+ public int hashCode()
+ {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((clusterPassword == null) ? 0 : clusterPassword.hashCode());
+ result = prime * result + ((clusterUser == null) ? 0 : clusterUser.hashCode());
+ result = prime * result + ((connector == null) ? 0 : connector.hashCode());
+ result = prime * result + ((nodeID == null) ? 0 : nodeID.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (this == obj)
+ {
+ return true;
+ }
+ if (!super.equals(obj))
+ {
+ return false;
+ }
+ if (!(obj instanceof BackupRegistrationMessage))
+ {
+ return false;
+ }
+ BackupRegistrationMessage other = (BackupRegistrationMessage)obj;
+ if (clusterPassword == null)
+ {
+ if (other.clusterPassword != null)
+ {
+ return false;
+ }
+ }
+ else if (!clusterPassword.equals(other.clusterPassword))
+ {
+ return false;
+ }
+ if (clusterUser == null)
+ {
+ if (other.clusterUser != null)
+ {
+ return false;
+ }
+ }
+ else if (!clusterUser.equals(other.clusterUser))
+ {
+ return false;
+ }
+ if (connector == null)
+ {
+ if (other.connector != null)
+ {
+ return false;
+ }
+ }
+ else if (!connector.equals(other.connector))
+ {
+ return false;
+ }
+ if (nodeID == null)
+ {
+ if (other.nodeID != null)
+ {
+ return false;
+ }
+ }
+ else if (!nodeID.equals(other.nodeID))
+ {
+ return false;
+ }
+ return true;
+ }
+
}
Modified: trunk/hornetq-core/src/main/java/org/hornetq/core/protocol/core/impl/wireformat/DisconnectMessage.java
===================================================================
--- trunk/hornetq-core/src/main/java/org/hornetq/core/protocol/core/impl/wireformat/DisconnectMessage.java 2012-01-09 11:17:36 UTC (rev 12000)
+++ trunk/hornetq-core/src/main/java/org/hornetq/core/protocol/core/impl/wireformat/DisconnectMessage.java 2012-01-09 11:18:03 UTC (rev 12001)
@@ -17,13 +17,6 @@
import org.hornetq.api.core.SimpleString;
import org.hornetq.core.protocol.core.impl.PacketImpl;
-/**
- *
- * A Ping
- *
- * @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
- *
- */
public class DisconnectMessage extends PacketImpl
{
// Constants -----------------------------------------------------
@@ -31,7 +24,7 @@
// Attributes ----------------------------------------------------
private SimpleString nodeID;
-
+
// Static --------------------------------------------------------
// Constructors --------------------------------------------------
@@ -77,29 +70,47 @@
}
@Override
- public boolean equals(final Object other)
+ public final boolean isRequiresConfirmations()
{
- if (other instanceof DisconnectMessage == false)
- {
- return false;
- }
+ return false;
+ }
- DisconnectMessage r = (DisconnectMessage)other;
-
- return super.equals(other) && nodeID.equals(r.nodeID);
+ @Override
+ public int hashCode()
+ {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + ((nodeID == null) ? 0 : nodeID.hashCode());
+ return result;
}
@Override
- public final boolean isRequiresConfirmations()
+ public boolean equals(Object obj)
{
- return false;
+ if (this == obj)
+ {
+ return true;
+ }
+ if (!super.equals(obj))
+ {
+ return false;
+ }
+ if (!(obj instanceof DisconnectMessage))
+ {
+ return false;
+ }
+ DisconnectMessage other = (DisconnectMessage)obj;
+ if (nodeID == null)
+ {
+ if (other.nodeID != null)
+ {
+ return false;
+ }
+ }
+ else if (!nodeID.equals(other.nodeID))
+ {
+ return false;
+ }
+ return true;
}
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
}
Modified: trunk/hornetq-core/src/main/java/org/hornetq/core/protocol/core/impl/wireformat/HornetQExceptionMessage.java
===================================================================
--- trunk/hornetq-core/src/main/java/org/hornetq/core/protocol/core/impl/wireformat/HornetQExceptionMessage.java 2012-01-09 11:17:36 UTC (rev 12000)
+++ trunk/hornetq-core/src/main/java/org/hornetq/core/protocol/core/impl/wireformat/HornetQExceptionMessage.java 2012-01-09 11:18:03 UTC (rev 12001)
@@ -15,24 +15,15 @@
import org.hornetq.api.core.HornetQBuffer;
import org.hornetq.api.core.HornetQException;
-import org.hornetq.core.logging.Logger;
import org.hornetq.core.protocol.core.impl.PacketImpl;
/**
* @author <a href="mailto:jmesnil@redhat.com">Jeff Mesnil</a>
* @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
- *
- * @version <tt>$Revision$</tt>
- *
*/
public class HornetQExceptionMessage extends PacketImpl
{
- // Constants -----------------------------------------------------
- private static final Logger log = Logger.getLogger(HornetQExceptionMessage.class);
-
- // Attributes ----------------------------------------------------
-
private HornetQException exception;
// Static --------------------------------------------------------
@@ -87,23 +78,41 @@
}
@Override
- public boolean equals(final Object other)
+ public int hashCode()
{
- if (other instanceof HornetQExceptionMessage == false)
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + ((exception == null) ? 0 : exception.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (this == obj)
{
+ return true;
+ }
+ if (!super.equals(obj))
+ {
return false;
}
-
- HornetQExceptionMessage r = (HornetQExceptionMessage)other;
-
- return super.equals(other) && exception.equals(r.exception);
+ if (!(obj instanceof HornetQExceptionMessage))
+ {
+ return false;
+ }
+ HornetQExceptionMessage other = (HornetQExceptionMessage)obj;
+ if (exception == null)
+ {
+ if (other.exception != null)
+ {
+ return false;
+ }
+ }
+ else if (!exception.equals(other.exception))
+ {
+ return false;
+ }
+ return true;
}
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
}
Modified: trunk/hornetq-core/src/main/java/org/hornetq/core/protocol/core/impl/wireformat/PacketsConfirmedMessage.java
===================================================================
--- trunk/hornetq-core/src/main/java/org/hornetq/core/protocol/core/impl/wireformat/PacketsConfirmedMessage.java 2012-01-09 11:17:36 UTC (rev 12000)
+++ trunk/hornetq-core/src/main/java/org/hornetq/core/protocol/core/impl/wireformat/PacketsConfirmedMessage.java 2012-01-09 11:18:03 UTC (rev 12001)
@@ -17,9 +17,9 @@
import org.hornetq.core.protocol.core.impl.PacketImpl;
/**
- *
+ *
* A PacketsConfirmedMessage
- *
+ *
* @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
*
*/
@@ -66,36 +66,48 @@
commandID = buffer.readInt();
}
+
@Override
+ public final boolean isRequiresConfirmations()
+ {
+ return false;
+ }
+
+ @Override
public String toString()
{
return getParentString() + ", commandID=" + commandID + "]";
}
@Override
- public boolean equals(final Object other)
+ public int hashCode()
{
- if (other instanceof PacketsConfirmedMessage == false)
- {
- return false;
- }
-
- PacketsConfirmedMessage r = (PacketsConfirmedMessage)other;
-
- return super.equals(other) && commandID == r.commandID;
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + commandID;
+ return result;
}
@Override
- public final boolean isRequiresConfirmations()
+ public boolean equals(Object obj)
{
- return false;
+ if (this == obj)
+ {
+ return true;
+ }
+ if (!super.equals(obj))
+ {
+ return false;
+ }
+ if (!(obj instanceof PacketsConfirmedMessage))
+ {
+ return false;
+ }
+ PacketsConfirmedMessage other = (PacketsConfirmedMessage)obj;
+ if (commandID != other.commandID)
+ {
+ return false;
+ }
+ return true;
}
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
}
Modified: trunk/hornetq-core/src/main/java/org/hornetq/core/protocol/core/impl/wireformat/Ping.java
===================================================================
--- trunk/hornetq-core/src/main/java/org/hornetq/core/protocol/core/impl/wireformat/Ping.java 2012-01-09 11:17:36 UTC (rev 12000)
+++ trunk/hornetq-core/src/main/java/org/hornetq/core/protocol/core/impl/wireformat/Ping.java 2012-01-09 11:18:03 UTC (rev 12001)
@@ -20,12 +20,12 @@
import org.hornetq.spi.core.protocol.RemotingConnection;
/**
- *
+ *
* Ping is sent on the client side at {@link ClientSessionFactoryImpl}
* At the server's side is treated at {@link RemotingServiceImpl}
- *
+ *
* @See {@link RemotingConnection#checkDataReceived()}
- *
+ *
* @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
*
*/
@@ -73,6 +73,12 @@
}
@Override
+ public final boolean isRequiresConfirmations()
+ {
+ return false;
+ }
+
+ @Override
public String toString()
{
StringBuffer buf = new StringBuffer(getParentString());
@@ -82,29 +88,34 @@
}
@Override
- public boolean equals(final Object other)
+ public int hashCode()
{
- if (other instanceof Ping == false)
- {
- return false;
- }
-
- Ping r = (Ping)other;
-
- return super.equals(other) && connectionTTL == r.connectionTTL;
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + (int)(connectionTTL ^ (connectionTTL >>> 32));
+ return result;
}
@Override
- public final boolean isRequiresConfirmations()
+ public boolean equals(Object obj)
{
- return false;
+ if (this == obj)
+ {
+ return true;
+ }
+ if (!super.equals(obj))
+ {
+ return false;
+ }
+ if (!(obj instanceof Ping))
+ {
+ return false;
+ }
+ Ping other = (Ping)obj;
+ if (connectionTTL != other.connectionTTL)
+ {
+ return false;
+ }
+ return true;
}
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
}
Modified: trunk/hornetq-core/src/main/java/org/hornetq/core/version/impl/VersionImpl.java
===================================================================
--- trunk/hornetq-core/src/main/java/org/hornetq/core/version/impl/VersionImpl.java 2012-01-09 11:17:36 UTC (rev 12000)
+++ trunk/hornetq-core/src/main/java/org/hornetq/core/version/impl/VersionImpl.java 2012-01-09 11:18:03 UTC (rev 12001)
@@ -14,8 +14,8 @@
package org.hornetq.core.version.impl;
import java.io.Serializable;
+import java.util.Arrays;
-import org.hornetq.core.logging.Logger;
import org.hornetq.core.version.Version;
/**
@@ -25,16 +25,8 @@
*/
public class VersionImpl implements Version, Serializable
{
- // Constants -----------------------------------------------------
-
private static final long serialVersionUID = -5271227256591080403L;
- private static final Logger log = Logger.getLogger(VersionImpl.class);
-
- // Static --------------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
private final String versionName;
private final int majorVersion;
@@ -46,7 +38,7 @@
private final int incrementingVersion;
private final String versionSuffix;
-
+
private final String nettyVersion;
private final int[] compatibleVersionList;
@@ -75,7 +67,7 @@
this.versionSuffix = versionSuffix;
this.nettyVersion = nettyVersion;
-
+
this.compatibleVersionList = compatibleVersionList;
}
@@ -136,33 +128,91 @@
return compatibleVersionList;
}
- // Public -------------------------------------------------------
+ @Override
+ public int hashCode()
+ {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + Arrays.hashCode(compatibleVersionList);
+ result = prime * result + incrementingVersion;
+ result = prime * result + majorVersion;
+ result = prime * result + microVersion;
+ result = prime * result + minorVersion;
+ result = prime * result + ((nettyVersion == null) ? 0 : nettyVersion.hashCode());
+ result = prime * result + ((versionName == null) ? 0 : versionName.hashCode());
+ result = prime * result + ((versionSuffix == null) ? 0 : versionSuffix.hashCode());
+ return result;
+ }
@Override
- public boolean equals(final Object other)
+ public boolean equals(Object obj)
{
- if (other == this)
+ if (this == obj)
{
return true;
}
- if (other instanceof Version == false)
+ if (obj == null)
{
return false;
}
- Version v = (Version)other;
-
- return versionName.equals(v.getVersionName()) && majorVersion == v.getMajorVersion() &&
- minorVersion == v.getMinorVersion() &&
- microVersion == v.getMicroVersion() &&
- versionSuffix.equals(v.getVersionSuffix()) &&
- incrementingVersion == v.getIncrementingVersion();
+ if (!(obj instanceof VersionImpl))
+ {
+ return false;
+ }
+ VersionImpl other = (VersionImpl)obj;
+ if (!Arrays.equals(compatibleVersionList, other.compatibleVersionList))
+ {
+ return false;
+ }
+ if (incrementingVersion != other.incrementingVersion)
+ {
+ return false;
+ }
+ if (majorVersion != other.majorVersion)
+ {
+ return false;
+ }
+ if (microVersion != other.microVersion)
+ {
+ return false;
+ }
+ if (minorVersion != other.minorVersion)
+ {
+ return false;
+ }
+ if (nettyVersion == null)
+ {
+ if (other.nettyVersion != null)
+ {
+ return false;
+ }
+ }
+ else if (!nettyVersion.equals(other.nettyVersion))
+ {
+ return false;
+ }
+ if (versionName == null)
+ {
+ if (other.versionName != null)
+ {
+ return false;
+ }
+ }
+ else if (!versionName.equals(other.versionName))
+ {
+ return false;
+ }
+ if (versionSuffix == null)
+ {
+ if (other.versionSuffix != null)
+ {
+ return false;
+ }
+ }
+ else if (!versionSuffix.equals(other.versionSuffix))
+ {
+ return false;
+ }
+ return true;
}
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
}
12 years, 5 months
JBoss hornetq SVN: r12000 - trunk/hornetq-core/src/main/java/org/hornetq/core/paging/cursor/impl.
by do-not-reply@jboss.org
Author: borges
Date: 2012-01-09 06:17:36 -0500 (Mon, 09 Jan 2012)
New Revision: 12000
Modified:
trunk/hornetq-core/src/main/java/org/hornetq/core/paging/cursor/impl/LivePageCacheImpl.java
Log:
Make synchronization of 'messages' array consistent (does not really affect running code).
Modified: trunk/hornetq-core/src/main/java/org/hornetq/core/paging/cursor/impl/LivePageCacheImpl.java
===================================================================
--- trunk/hornetq-core/src/main/java/org/hornetq/core/paging/cursor/impl/LivePageCacheImpl.java 2012-01-09 11:17:17 UTC (rev 11999)
+++ trunk/hornetq-core/src/main/java/org/hornetq/core/paging/cursor/impl/LivePageCacheImpl.java 2012-01-09 11:17:36 UTC (rev 12000)
@@ -33,22 +33,24 @@
// Constants -----------------------------------------------------
// Attributes ----------------------------------------------------
-
+
private final List<PagedMessage> messages = new LinkedList<PagedMessage>();
-
+
private final Page page;
-
+
private boolean isLive = true;
-
+
+ @Override
public String toString()
{
- return "LivePacheCacheImpl::page=" + page.getPageId() + " number of messages=" + messages.size() + " isLive = " + isLive;
+ return "LivePacheCacheImpl::page=" + page.getPageId() + ", number of messages=" + messages.size() +
+ ", isLive = " + isLive;
}
// Static --------------------------------------------------------
// Constructors --------------------------------------------------
-
+
public LivePageCacheImpl(final Page page)
{
this.page = page;
@@ -63,7 +65,7 @@
{
return page;
}
-
+
public long getPageId()
{
return page.getPageId();
@@ -151,7 +153,7 @@
/* (non-Javadoc)
* @see org.hornetq.core.paging.cursor.PageCache#getMessages()
*/
- public PagedMessage[] getMessages()
+ public synchronized PagedMessage[] getMessages()
{
return messages.toArray(new PagedMessage[messages.size()]);
}
12 years, 5 months
JBoss hornetq SVN: r11999 - in trunk/hornetq-core/src/main/java/org/hornetq: utils/json and 1 other directory.
by do-not-reply@jboss.org
Author: borges
Date: 2012-01-09 06:17:17 -0500 (Mon, 09 Jan 2012)
New Revision: 11999
Modified:
trunk/hornetq-core/src/main/java/org/hornetq/core/filter/impl/Operator.java
trunk/hornetq-core/src/main/java/org/hornetq/utils/json/JSONObject.java
Log:
Fix findbugs warnings
Modified: trunk/hornetq-core/src/main/java/org/hornetq/core/filter/impl/Operator.java
===================================================================
--- trunk/hornetq-core/src/main/java/org/hornetq/core/filter/impl/Operator.java 2012-01-09 11:16:50 UTC (rev 11998)
+++ trunk/hornetq-core/src/main/java/org/hornetq/core/filter/impl/Operator.java 2012-01-09 11:17:17 UTC (rev 11999)
@@ -25,7 +25,6 @@
import java.util.HashSet;
import org.hornetq.api.core.SimpleString;
-import org.hornetq.core.logging.Logger;
/**
* Implementations of the operators used in HornetQ filter expressions
@@ -39,8 +38,6 @@
*/
public class Operator
{
- private static final Logger log = Logger.getLogger(Operator.class);
-
int operation;
Object oper1;
@@ -703,6 +700,7 @@
default:
throwBadObjectException(class2);
}
+ break;
case LONG:
switch (class2)
{
@@ -713,6 +711,7 @@
default:
throwBadObjectException(class2);
}
+ break;
default:
throwBadObjectException(class1);
}
@@ -741,6 +740,7 @@
default:
throwBadObjectException(class2);
}
+ break;
case LONG:
switch (class2)
{
@@ -751,6 +751,7 @@
default:
throwBadObjectException(class2);
}
+ break;
default:
throwBadObjectException(class1);
}
@@ -798,6 +799,7 @@
default:
throwBadObjectException(class2);
}
+ break;
case LONG:
switch (class2)
{
@@ -808,6 +810,7 @@
default:
throwBadObjectException(class2);
}
+ break;
default:
throwBadObjectException(class1);
}
@@ -836,6 +839,7 @@
default:
throwBadObjectException(class2);
}
+ break;
case LONG:
switch (class2)
{
@@ -846,6 +850,7 @@
default:
throwBadObjectException(class2);
}
+ break;
default:
throwBadObjectException(class1);
}
@@ -949,7 +954,7 @@
throw new Exception("LIKE ESCAPE: Bad escape character " + escapeString.toString());
}
- escapeChar = new Character(escapeString.charAt(0));
+ escapeChar = Character.valueOf(escapeString.charAt(0));
}
if (re == null)
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-09 11:16:50 UTC (rev 11998)
+++ trunk/hornetq-core/src/main/java/org/hornetq/utils/json/JSONObject.java 2012-01-09 11:17:17 UTC (rev 11999)
@@ -1453,7 +1453,7 @@
sb.append('}');
return sb.toString();
}
- catch (Exception e)
+ catch (JSONException e)
{
return null;
}
12 years, 5 months
JBoss hornetq SVN: r11998 - trunk/hornetq-commons/src/main/java/org/hornetq/utils.
by do-not-reply@jboss.org
Author: borges
Date: 2012-01-09 06:16:50 -0500 (Mon, 09 Jan 2012)
New Revision: 11998
Modified:
trunk/hornetq-commons/src/main/java/org/hornetq/utils/UUIDGenerator.java
Log:
Inefficient String append --> StringBuilder()
Modified: trunk/hornetq-commons/src/main/java/org/hornetq/utils/UUIDGenerator.java
===================================================================
--- trunk/hornetq-commons/src/main/java/org/hornetq/utils/UUIDGenerator.java 2012-01-09 09:04:19 UTC (rev 11997)
+++ trunk/hornetq-commons/src/main/java/org/hornetq/utils/UUIDGenerator.java 2012-01-09 11:16:50 UTC (rev 11998)
@@ -282,12 +282,13 @@
return null;
}
- String s = "";
+ StringBuilder s = new StringBuilder();
for (int i = 0; i < bytes.length - 1; i++)
{
- s += Integer.toHexString(bytes[i]) + ":";
+ s.append(Integer.toHexString(bytes[i]));
+ s.append(":");
}
- s += bytes[bytes.length - 1];
- return s;
+ s.append(bytes[bytes.length - 1]);
+ return s.toString();
}
}
\ No newline at end of file
12 years, 5 months
JBoss hornetq SVN: r11997 - trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/jms/server.
by do-not-reply@jboss.org
Author: borges
Date: 2012-01-09 04:04:19 -0500 (Mon, 09 Jan 2012)
New Revision: 11997
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/jms/server/JMSServerStartStopTest.java
Log:
Fix failing test by doing clean-up of previous one.
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/jms/server/JMSServerStartStopTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/jms/server/JMSServerStartStopTest.java 2012-01-06 20:58:23 UTC (rev 11996)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/jms/server/JMSServerStartStopTest.java 2012-01-09 09:04:19 UTC (rev 11997)
@@ -27,7 +27,6 @@
import org.hornetq.api.jms.JMSFactoryType;
import org.hornetq.core.config.impl.FileConfiguration;
import org.hornetq.core.logging.Logger;
-import org.hornetq.core.remoting.impl.netty.NettyConnectorFactory;
import org.hornetq.core.server.HornetQServer;
import org.hornetq.core.server.impl.HornetQServerImpl;
import org.hornetq.jms.client.HornetQConnectionFactory;
@@ -35,16 +34,13 @@
import org.hornetq.jms.server.impl.JMSServerManagerImpl;
import org.hornetq.spi.core.security.HornetQSecurityManager;
import org.hornetq.spi.core.security.HornetQSecurityManagerImpl;
-import org.hornetq.tests.util.ServiceTestBase;
import org.hornetq.tests.util.UnitTestCase;
/**
- *
+ *
* A JMSServerStartStopTest
*
* @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
- *
- *
*/
public class JMSServerStartStopTest extends UnitTestCase
{
@@ -56,6 +52,10 @@
private JMSServerManager liveJMSServer;
+ private Connection conn;
+
+ private HornetQConnectionFactory jbcf;
+
// Static --------------------------------------------------------
// Constructors --------------------------------------------------
@@ -72,13 +72,14 @@
start();
- HornetQConnectionFactory jbcf = (HornetQConnectionFactory) HornetQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.CF, new TransportConfiguration(NettyConnectorFactory.class.getCanonicalName()));
+ HornetQConnectionFactory jbcf = createConnectionFactory();
jbcf.setBlockOnDurableSend(true);
jbcf.setBlockOnNonDurableSend(true);
Connection conn = jbcf.createConnection();
-
+ try
+ {
Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
Queue queue = sess.createQueue("myJMSQueue");
@@ -88,23 +89,25 @@
TextMessage tm = sess.createTextMessage("message" + j);
producer.send(tm);
-
+ }
+ finally
+ {
conn.close();
jbcf.close();
stop();
-
+ }
}
start();
- HornetQConnectionFactory jbcf = (HornetQConnectionFactory) HornetQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.CF, new TransportConfiguration(NettyConnectorFactory.class.getCanonicalName()));
+ jbcf = createConnectionFactory();
jbcf.setBlockOnDurableSend(true);
jbcf.setBlockOnNonDurableSend(true);
- Connection conn = jbcf.createConnection();
+ conn = jbcf.createConnection();
Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
@@ -118,7 +121,7 @@
{
TextMessage tm = (TextMessage)consumer.receive(10000);
- Assert.assertNotNull(tm);
+ Assert.assertNotNull("not null", tm);
Assert.assertEquals("message" + i, tm.getText());
}
@@ -129,39 +132,42 @@
stop();
}
-
+
// https://jira.jboss.org/jira/browse/HORNETQ-315
public void testCloseConnectionAfterServerIsShutdown() throws Exception
{
start();
-
- HornetQConnectionFactory jbcf = (HornetQConnectionFactory) HornetQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.CF, new TransportConfiguration(NettyConnectorFactory.class.getCanonicalName()));
+ jbcf = createConnectionFactory();
+
jbcf.setBlockOnDurableSend(true);
jbcf.setBlockOnNonDurableSend(true);
jbcf.setReconnectAttempts(-1);
-
- Connection conn = jbcf.createConnection();
-
+
+ conn = jbcf.createConnection();
+
stop();
-
conn.close();
}
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- @Override
- protected void setUp() throws Exception
+ /**
+ * @return
+ */
+ private HornetQConnectionFactory createConnectionFactory()
{
- super.setUp();
+ return HornetQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.CF,
+ new TransportConfiguration(NETTY_CONNECTOR_FACTORY));
}
@Override
protected void tearDown() throws Exception
{
- liveJMSServer.stop();
+ if (conn != null)
+ conn.close();
+ if (jbcf != null)
+ jbcf.close();
+ if (liveJMSServer != null)
+ liveJMSServer.stop();
liveJMSServer = null;
super.tearDown();
}
@@ -180,7 +186,7 @@
fc.setConfigurationUrl("server-start-stop-config1.xml");
fc.start();
-
+
fc.setJournalDirectory(getJournalDir());
fc.setBindingsDirectory(getBindingsDir());
fc.setLargeMessagesDirectory(getLargeMessagesDir());
12 years, 5 months
JBoss hornetq SVN: r11996 - branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/client.
by do-not-reply@jboss.org
Author: clebert.suconic(a)jboss.com
Date: 2012-01-06 15:58:23 -0500 (Fri, 06 Jan 2012)
New Revision: 11996
Modified:
branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/client/PagingTest.java
Log:
duh.. fix on test
Modified: branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/client/PagingTest.java
===================================================================
--- branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/client/PagingTest.java 2012-01-06 19:21:21 UTC (rev 11995)
+++ branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/client/PagingTest.java 2012-01-06 20:58:23 UTC (rev 11996)
@@ -4380,7 +4380,7 @@
PagingStore store = server.getPagingManager().getPageStore(ADDRESS);
// It's async, so need to wait a bit for it happening
- while (timeout < System.currentTimeMillis() && store.isPaging())
+ while (timeout > System.currentTimeMillis() && store.isPaging())
{
Thread.sleep(100);
}
12 years, 5 months
JBoss hornetq SVN: r11995 - trunk/hornetq-core/src/main/java/org/hornetq/utils/json.
by do-not-reply@jboss.org
Author: borges
Date: 2012-01-06 14:21:21 -0500 (Fri, 06 Jan 2012)
New Revision: 11995
Modified:
trunk/hornetq-core/src/main/java/org/hornetq/utils/json/JSONObject.java
Log:
Fix warnings, and clarify code.
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-06 19:21:02 UTC (rev 11994)
+++ trunk/hornetq-core/src/main/java/org/hornetq/utils/json/JSONObject.java 2012-01-06 19:21:21 UTC (rev 11995)
@@ -57,11 +57,11 @@
* do type checking and type coercion for you.
* <p>
* The <code>put</code> methods adds values to an object. For example,
- *
+ *
* <pre>
* myString = new JSONObject().put("JSON", "Hello, World!").toString();
* </pre>
- *
+ *
* produces the string <code>{"JSON": "Hello, World"}</code>.
* <p>
* The texts produced by the <code>toString</code> methods strictly conform to the JSON syntax
@@ -1571,20 +1571,18 @@
}
if (value instanceof JSONString)
{
- Object o;
+ String o;
try
{
o = ((JSONString)value).toJSONString();
}
- catch (Exception e)
+ catch (RuntimeException e)
{
throw new JSONException(e);
}
- if (o instanceof String)
- {
- return (String)o;
- }
- throw new JSONException("Bad value from toJSONString: " + o);
+ if (o == null)
+ throw new JSONException("Bad value from toJSONString: " + o);
+ return o;
}
if (value instanceof Number)
{
@@ -1633,14 +1631,12 @@
{
if (value instanceof JSONString)
{
- Object o = ((JSONString)value).toJSONString();
- if (o instanceof String)
- {
- return (String)o;
- }
+ String o = ((JSONString)value).toJSONString();
+ if (o != null)
+ return o;
}
}
- catch (Exception e)
+ catch (RuntimeException e)
{
/* forget about it */
}
12 years, 5 months
JBoss hornetq SVN: r11994 - trunk/hornetq-commons/src/main/java/org/hornetq/utils.
by do-not-reply@jboss.org
Author: borges
Date: 2012-01-06 14:21:02 -0500 (Fri, 06 Jan 2012)
New Revision: 11994
Modified:
trunk/hornetq-commons/src/main/java/org/hornetq/utils/Base64.java
Log:
Remove unused variable.
Modified: trunk/hornetq-commons/src/main/java/org/hornetq/utils/Base64.java
===================================================================
--- trunk/hornetq-commons/src/main/java/org/hornetq/utils/Base64.java 2012-01-06 16:24:44 UTC (rev 11993)
+++ trunk/hornetq-commons/src/main/java/org/hornetq/utils/Base64.java 2012-01-06 19:21:02 UTC (rev 11994)
@@ -1000,7 +1000,6 @@
// Isolate options
int gzip = options & Base64.GZIP;
- int dontBreakLines = options & Base64.DONT_BREAK_LINES;
try
{
12 years, 5 months