JBoss hornetq SVN: r11971 - branches/Branch_2_2_EAP/src/main/org/hornetq/core/server/impl.
by do-not-reply@jboss.org
Author: clebert.suconic(a)jboss.com
Date: 2012-01-05 08:12:52 -0500 (Thu, 05 Jan 2012)
New Revision: 11971
Modified:
branches/Branch_2_2_EAP/src/main/org/hornetq/core/server/impl/ServerSessionImpl.java
Log:
JBPAPP-7829 fixing NPE on NettyBridgeTest
Modified: branches/Branch_2_2_EAP/src/main/org/hornetq/core/server/impl/ServerSessionImpl.java
===================================================================
--- branches/Branch_2_2_EAP/src/main/org/hornetq/core/server/impl/ServerSessionImpl.java 2012-01-05 12:06:33 UTC (rev 11970)
+++ branches/Branch_2_2_EAP/src/main/org/hornetq/core/server/impl/ServerSessionImpl.java 2012-01-05 13:12:52 UTC (rev 11971)
@@ -1136,6 +1136,12 @@
log.trace("send(message=" + message + ", direct=" + direct + ") being called");
}
+ if (message.getAddress() == null)
+ {
+ // This could happen with some tests that are ignoring messages
+ throw new HornetQException(HornetQException.ILLEGAL_STATE, "You don't have an address at the Server's Session");
+ }
+
if (message.getAddress().equals(managementAddress))
{
// It's a management message
12 years, 11 months
JBoss hornetq SVN: r11970 - branches/Branch_2_2_EAP/src/main/org/hornetq/core/server/impl.
by do-not-reply@jboss.org
Author: clebert.suconic(a)jboss.com
Date: 2012-01-05 07:06:33 -0500 (Thu, 05 Jan 2012)
New Revision: 11970
Modified:
branches/Branch_2_2_EAP/src/main/org/hornetq/core/server/impl/ServerSessionImpl.java
Log:
JBPAPP-7829 removing typo from my last commit
Modified: branches/Branch_2_2_EAP/src/main/org/hornetq/core/server/impl/ServerSessionImpl.java
===================================================================
--- branches/Branch_2_2_EAP/src/main/org/hornetq/core/server/impl/ServerSessionImpl.java 2012-01-05 11:32:36 UTC (rev 11969)
+++ branches/Branch_2_2_EAP/src/main/org/hornetq/core/server/impl/ServerSessionImpl.java 2012-01-05 12:06:33 UTC (rev 11970)
@@ -1136,7 +1136,6 @@
log.trace("send(message=" + message + ", direct=" + direct + ") being called");
}
- log.info("message " + message + " managementAddress = " + managementAddress);
if (message.getAddress().equals(managementAddress))
{
// It's a management message
12 years, 11 months
JBoss hornetq SVN: r11969 - trunk/hornetq-jms/src/main/java/org/hornetq/jms/client.
by do-not-reply@jboss.org
Author: borges
Date: 2012-01-05 06:32:36 -0500 (Thu, 05 Jan 2012)
New Revision: 11969
Modified:
trunk/hornetq-jms/src/main/java/org/hornetq/jms/client/HornetQConnectionFactory.java
Log:
FIX *throw* the instantiated exception.
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 11:28:33 UTC (rev 11968)
+++ trunk/hornetq-jms/src/main/java/org/hornetq/jms/client/HornetQConnectionFactory.java 2012-01-05 11:32:36 UTC (rev 11969)
@@ -32,7 +32,6 @@
import org.hornetq.api.core.client.HornetQClient;
import org.hornetq.api.core.client.ServerLocator;
import org.hornetq.api.jms.JMSFactoryType;
-import org.hornetq.core.logging.Logger;
import org.hornetq.jms.referenceable.ConnectionFactoryObjectFactory;
import org.hornetq.jms.referenceable.SerializableObjectRefAddr;
@@ -45,16 +44,8 @@
*/
public class HornetQConnectionFactory implements Serializable, Referenceable
{
- // Constants ------------------------------------------------------------------------------------
-
private final static long serialVersionUID = -2810634789345348326L;
- private static final Logger log = Logger.getLogger(HornetQConnectionFactory.class);
-
- // Static ---------------------------------------------------------------------------------------
-
- // Attributes -----------------------------------------------------------------------------------
-
private final ServerLocator serverLocator;
private String clientID;
@@ -65,8 +56,6 @@
private boolean readOnly;
- // Constructors ---------------------------------------------------------------------------------
-
public HornetQConnectionFactory()
{
serverLocator = null;
@@ -681,7 +670,7 @@
if (connection == null)
{
- new JMSException("Failed to create connection: invalid type " + type);
+ throw new JMSException("Failed to create connection: invalid type " + type);
}
connection.setReference(this);
12 years, 11 months
JBoss hornetq SVN: r11968 - in trunk: hornetq-core/src/test/java/org/hornetq/tests/util and 1 other directories.
by do-not-reply@jboss.org
Author: borges
Date: 2012-01-05 06:28:33 -0500 (Thu, 05 Jan 2012)
New Revision: 11968
Added:
trunk/hornetq-core/src/test/java/org/hornetq/tests/util/SimpleStringTest.java
Removed:
trunk/tests/unit-tests/src/test/java/org/hornetq/tests/unit/util/SimpleStringTest.java
Modified:
trunk/hornetq-commons/src/main/java/org/hornetq/api/core/SimpleString.java
Log:
HORNETQ-822 Avoid unnecessary call to contains(char) within split(char)
Also move SimpleStringTest into hornetq-core.
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 02:01:37 UTC (rev 11967)
+++ trunk/hornetq-commons/src/main/java/org/hornetq/api/core/SimpleString.java 2012-01-05 11:28:33 UTC (rev 11968)
@@ -17,7 +17,6 @@
import java.util.ArrayList;
import java.util.List;
-import org.hornetq.core.logging.Logger;
import org.hornetq.utils.DataConstants;
/**
@@ -34,8 +33,6 @@
{
private static final long serialVersionUID = 4204223851422244307L;
- private static final Logger log = Logger.getLogger(SimpleString.class);
-
// Attributes
// ------------------------------------------------------------------------
private final byte[] data;
@@ -264,12 +261,6 @@
*/
public SimpleString[] split(final char delim)
{
- if (!contains(delim))
- {
- return new SimpleString[] { this };
- }
- else
- {
List<SimpleString> all = new ArrayList<SimpleString>();
byte low = (byte)(delim & 0xFF); // low byte
@@ -286,12 +277,16 @@
all.add(new SimpleString(bytes));
}
}
+
+ if (all.isEmpty())
+ {
+ return new SimpleString[] { this };
+ }
byte[] bytes = new byte[data.length - lasPos];
System.arraycopy(data, lasPos, bytes, 0, bytes.length);
all.add(new SimpleString(bytes));
SimpleString[] parts = new SimpleString[all.size()];
return all.toArray(parts);
- }
}
/**
Copied: trunk/hornetq-core/src/test/java/org/hornetq/tests/util/SimpleStringTest.java (from rev 11965, trunk/tests/unit-tests/src/test/java/org/hornetq/tests/unit/util/SimpleStringTest.java)
===================================================================
--- trunk/hornetq-core/src/test/java/org/hornetq/tests/util/SimpleStringTest.java (rev 0)
+++ trunk/hornetq-core/src/test/java/org/hornetq/tests/util/SimpleStringTest.java 2012-01-05 11:28:33 UTC (rev 11968)
@@ -0,0 +1,439 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package org.hornetq.tests.util;
+
+import java.util.concurrent.CountDownLatch;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.hornetq.api.core.SimpleString;
+import org.hornetq.utils.DataConstants;
+
+/**
+ *
+ * A SimpleStringTest
+ *
+ * @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
+ *
+ */
+public class SimpleStringTest extends TestCase
+{
+ /**
+ * Converting back and forth between char and byte requires care as char is unsigned.
+ * @see SimpleString#getChars(int, int, char[], int)
+ * @see SimpleString#charAt(int)
+ * @see SimpleString#split(char)
+ * @see SimpleString#concat(char)
+ */
+ public void testGetChar()
+ {
+ SimpleString p1 = new SimpleString("foo");
+ SimpleString p2 = new SimpleString("bar");
+ for (int i = 0; i < 1 << 16; i++)
+ {
+ String msg = "expecting " + i;
+ char c = (char)i;
+ SimpleString s = new SimpleString(String.valueOf(c));
+
+ // test getChars(...)
+ char[] c1 = new char[1];
+ s.getChars(0, 1, c1, 0);
+ assertEquals(msg, c, c1[0]);
+
+ // test charAt(int)
+ assertEquals(msg, c, s.charAt(0));
+
+ // test concat(char)
+ SimpleString s2 = s.concat(c);
+ assertEquals(msg, c, s2.charAt(1));
+
+ // test splitting with chars
+ SimpleString sSplit = new SimpleString("foo" + String.valueOf(c) + "bar");
+ SimpleString[] chunks = sSplit.split(c);
+ SimpleString[] split1 = p1.split(c);
+ SimpleString[] split2 = p2.split(c);
+ assertEquals(split1.length + split2.length, chunks.length);
+
+ int j = 0;
+ for (SimpleString iS : split1)
+ {
+ assertEquals(iS.toString(), iS, chunks[j++]);
+ }
+ for (SimpleString iS : split2)
+ {
+ assertEquals(iS.toString(), iS, chunks[j++]);
+ }
+ }
+ }
+
+ public void testString() throws Exception
+ {
+ final String str = "hello123ABC__524`16254`6125!%^$!%$!%$!%$!%!$%!$$!\uA324";
+
+ SimpleString s = new SimpleString(str);
+
+ Assert.assertEquals(str, s.toString());
+
+ Assert.assertEquals(2 * str.length(), s.getData().length);
+
+ byte[] data = s.getData();
+
+ SimpleString s2 = new SimpleString(data);
+
+ Assert.assertEquals(str, s2.toString());
+ }
+
+ public void testStartsWith() throws Exception
+ {
+ SimpleString s1 = new SimpleString("abcdefghi");
+
+ Assert.assertTrue(s1.startsWith(new SimpleString("abc")));
+
+ Assert.assertTrue(s1.startsWith(new SimpleString("abcdef")));
+
+ Assert.assertTrue(s1.startsWith(new SimpleString("abcdefghi")));
+
+ Assert.assertFalse(s1.startsWith(new SimpleString("abcdefghijklmn")));
+
+ Assert.assertFalse(s1.startsWith(new SimpleString("aardvark")));
+
+ Assert.assertFalse(s1.startsWith(new SimpleString("z")));
+ }
+
+ public void testCharSequence() throws Exception
+ {
+ String s = "abcdefghijkl";
+ SimpleString s1 = new SimpleString(s);
+
+ Assert.assertEquals('a', s1.charAt(0));
+ Assert.assertEquals('b', s1.charAt(1));
+ Assert.assertEquals('c', s1.charAt(2));
+ Assert.assertEquals('k', s1.charAt(10));
+ Assert.assertEquals('l', s1.charAt(11));
+
+ try
+ {
+ s1.charAt(-1);
+ Assert.fail("Should throw exception");
+ }
+ catch (IndexOutOfBoundsException e)
+ {
+ // OK
+ }
+
+ try
+ {
+ s1.charAt(-2);
+ Assert.fail("Should throw exception");
+ }
+ catch (IndexOutOfBoundsException e)
+ {
+ // OK
+ }
+
+ try
+ {
+ s1.charAt(s.length());
+ Assert.fail("Should throw exception");
+ }
+ catch (IndexOutOfBoundsException e)
+ {
+ // OK
+ }
+
+ try
+ {
+ s1.charAt(s.length() + 1);
+ Assert.fail("Should throw exception");
+ }
+ catch (IndexOutOfBoundsException e)
+ {
+ // OK
+ }
+
+ Assert.assertEquals(s.length(), s1.length());
+
+ CharSequence ss = s1.subSequence(0, s1.length());
+
+ Assert.assertEquals(ss, s1);
+
+ ss = s1.subSequence(1, 4);
+ Assert.assertEquals(ss, new SimpleString("bcd"));
+
+ ss = s1.subSequence(5, 10);
+ Assert.assertEquals(ss, new SimpleString("fghij"));
+
+ ss = s1.subSequence(5, 12);
+ Assert.assertEquals(ss, new SimpleString("fghijkl"));
+
+ try
+ {
+ s1.subSequence(-1, 2);
+ Assert.fail("Should throw exception");
+ }
+ catch (IndexOutOfBoundsException e)
+ {
+ // OK
+ }
+
+ try
+ {
+ s1.subSequence(-4, -2);
+ Assert.fail("Should throw exception");
+ }
+ catch (IndexOutOfBoundsException e)
+ {
+ // OK
+ }
+
+ try
+ {
+ s1.subSequence(0, s1.length() + 1);
+ Assert.fail("Should throw exception");
+ }
+ catch (IndexOutOfBoundsException e)
+ {
+ // OK
+ }
+
+ try
+ {
+ s1.subSequence(0, s1.length() + 2);
+ Assert.fail("Should throw exception");
+ }
+ catch (IndexOutOfBoundsException e)
+ {
+ // OK
+ }
+
+ try
+ {
+ s1.subSequence(5, 1);
+ Assert.fail("Should throw exception");
+ }
+ catch (IndexOutOfBoundsException e)
+ {
+ // OK
+ }
+ }
+
+ public void testEquals() throws Exception
+ {
+ Assert.assertFalse(new SimpleString("abcdef").equals(new Object()));
+
+ Assert.assertEquals(new SimpleString("abcdef"), new SimpleString("abcdef"));
+
+ Assert.assertFalse(new SimpleString("abcdef").equals(new SimpleString("abggcdef")));
+ Assert.assertFalse(new SimpleString("abcdef").equals(new SimpleString("ghijkl")));
+ }
+
+ public void testHashcode() throws Exception
+ {
+ SimpleString str = new SimpleString("abcdef");
+ SimpleString sameStr = new SimpleString("abcdef");
+ SimpleString differentStr = new SimpleString("ghijk");
+
+ Assert.assertTrue(str.hashCode() == sameStr.hashCode());
+ Assert.assertFalse(str.hashCode() == differentStr.hashCode());
+ }
+
+ public void testUnicode() throws Exception
+ {
+ String myString = "abcdef&^*&!^ghijkl\uB5E2\uCAC7\uB2BB\uB7DD\uB7C7\uB3A3\uBCE4\uB5A5";
+
+ SimpleString s = new SimpleString(myString);
+ byte[] data = s.getData();
+ s = new SimpleString(data);
+
+ Assert.assertEquals(myString, s.toString());
+ }
+
+ public void testUnicodeWithSurrogates() throws Exception
+ {
+ String myString = "abcdef&^*&!^ghijkl\uD900\uDD00";
+
+ SimpleString s = new SimpleString(myString);
+ byte[] data = s.getData();
+ s = new SimpleString(data);
+
+ Assert.assertEquals(myString, s.toString());
+ }
+
+ public void testSizeofString() throws Exception
+ {
+ Assert.assertEquals(DataConstants.SIZE_INT, SimpleString.sizeofString(new SimpleString("")));
+
+ SimpleString str = new SimpleString(RandomUtil.randomString());
+ Assert.assertEquals(DataConstants.SIZE_INT + str.getData().length, SimpleString.sizeofString(str));
+ }
+
+ public void testSizeofNullableString() throws Exception
+ {
+ Assert.assertEquals(1, SimpleString.sizeofNullableString(null));
+
+ Assert.assertEquals(1 + DataConstants.SIZE_INT, SimpleString.sizeofNullableString(new SimpleString("")));
+
+ SimpleString str = new SimpleString(RandomUtil.randomString());
+ Assert.assertEquals(1 + DataConstants.SIZE_INT + str.getData().length, SimpleString.sizeofNullableString(str));
+ }
+
+ public void testSplitNoDelimeter() throws Exception
+ {
+ SimpleString s = new SimpleString("abcdefghi");
+ SimpleString[] strings = s.split('.');
+ Assert.assertNotNull(strings);
+ Assert.assertEquals(strings.length, 1);
+ Assert.assertEquals(strings[0], s);
+ }
+
+ public void testSplit1Delimeter() throws Exception
+ {
+ SimpleString s = new SimpleString("abcd.efghi");
+ SimpleString[] strings = s.split('.');
+ Assert.assertNotNull(strings);
+ Assert.assertEquals(strings.length, 2);
+ Assert.assertEquals(strings[0], new SimpleString("abcd"));
+ Assert.assertEquals(strings[1], new SimpleString("efghi"));
+ }
+
+ public void testSplitmanyDelimeters() throws Exception
+ {
+ SimpleString s = new SimpleString("abcd.efghi.jklmn.opqrs.tuvw.xyz");
+ SimpleString[] strings = s.split('.');
+ Assert.assertNotNull(strings);
+ Assert.assertEquals(strings.length, 6);
+ Assert.assertEquals(strings[0], new SimpleString("abcd"));
+ Assert.assertEquals(strings[1], new SimpleString("efghi"));
+ Assert.assertEquals(strings[2], new SimpleString("jklmn"));
+ Assert.assertEquals(strings[3], new SimpleString("opqrs"));
+ Assert.assertEquals(strings[4], new SimpleString("tuvw"));
+ Assert.assertEquals(strings[5], new SimpleString("xyz"));
+ }
+
+ public void testContains()
+ {
+ SimpleString simpleString = new SimpleString("abcdefghijklmnopqrst");
+ Assert.assertFalse(simpleString.contains('.'));
+ Assert.assertFalse(simpleString.contains('%'));
+ Assert.assertFalse(simpleString.contains('8'));
+ Assert.assertFalse(simpleString.contains('.'));
+ Assert.assertTrue(simpleString.contains('a'));
+ Assert.assertTrue(simpleString.contains('b'));
+ Assert.assertTrue(simpleString.contains('c'));
+ Assert.assertTrue(simpleString.contains('d'));
+ Assert.assertTrue(simpleString.contains('e'));
+ Assert.assertTrue(simpleString.contains('f'));
+ Assert.assertTrue(simpleString.contains('g'));
+ Assert.assertTrue(simpleString.contains('h'));
+ Assert.assertTrue(simpleString.contains('i'));
+ Assert.assertTrue(simpleString.contains('j'));
+ Assert.assertTrue(simpleString.contains('k'));
+ Assert.assertTrue(simpleString.contains('l'));
+ Assert.assertTrue(simpleString.contains('m'));
+ Assert.assertTrue(simpleString.contains('n'));
+ Assert.assertTrue(simpleString.contains('o'));
+ Assert.assertTrue(simpleString.contains('p'));
+ Assert.assertTrue(simpleString.contains('q'));
+ Assert.assertTrue(simpleString.contains('r'));
+ Assert.assertTrue(simpleString.contains('s'));
+ Assert.assertTrue(simpleString.contains('t'));
+ }
+
+ public void testConcat()
+ {
+ SimpleString start = new SimpleString("abcdefg");
+ SimpleString middle = new SimpleString("hijklmnop");
+ SimpleString end = new SimpleString("qrstuvwxyz");
+ Assert.assertEquals(start.concat(middle).concat(end), new SimpleString("abcdefghijklmnopqrstuvwxyz"));
+ Assert.assertEquals(start.concat('.').concat(end), new SimpleString("abcdefg.qrstuvwxyz"));
+ // Testing concat of SimpleString with String
+ for (int i = 0; i < 10; i++)
+ {
+ Assert.assertEquals(new SimpleString("abcdefg-" + i), start.concat("-" + Integer.toString(i)));
+
+ }
+ }
+
+ public void testMultithreadHashCode() throws Exception
+ {
+ for (int repeat = 0; repeat < 10; repeat++)
+ {
+
+ StringBuffer buffer = new StringBuffer();
+
+ for (int i = 0; i < 100; i++)
+ {
+ buffer.append("Some Big String " + i);
+ }
+ String strvalue = buffer.toString();
+
+ final int initialhash = new SimpleString(strvalue).hashCode();
+
+ final SimpleString value = new SimpleString(strvalue);
+
+ int nThreads = 100;
+ final CountDownLatch latch = new CountDownLatch(nThreads);
+ final CountDownLatch start = new CountDownLatch(1);
+
+ class T extends Thread
+ {
+ boolean failed = false;
+
+ @Override
+ public void run()
+ {
+ try
+ {
+ latch.countDown();
+ start.await();
+
+ int newhash = value.hashCode();
+
+ if (newhash != initialhash)
+ {
+ failed = true;
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ failed = true;
+ }
+ }
+ }
+
+ T x[] = new T[nThreads];
+ for (int i = 0; i < nThreads; i++)
+ {
+ x[i] = new T();
+ x[i].start();
+ }
+
+ latch.await();
+ start.countDown();
+
+ for (T t : x)
+ {
+ t.join();
+ }
+
+ for (T t : x)
+ {
+ Assert.assertFalse(t.failed);
+ }
+ }
+ }
+
+}
Deleted: trunk/tests/unit-tests/src/test/java/org/hornetq/tests/unit/util/SimpleStringTest.java
===================================================================
--- trunk/tests/unit-tests/src/test/java/org/hornetq/tests/unit/util/SimpleStringTest.java 2012-01-05 02:01:37 UTC (rev 11967)
+++ trunk/tests/unit-tests/src/test/java/org/hornetq/tests/unit/util/SimpleStringTest.java 2012-01-05 11:28:33 UTC (rev 11968)
@@ -1,434 +0,0 @@
-/*
- * Copyright 2009 Red Hat, Inc.
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-package org.hornetq.tests.unit.util;
-
-import java.util.concurrent.CountDownLatch;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
-
-import org.hornetq.api.core.SimpleString;
-import org.hornetq.tests.util.RandomUtil;
-import org.hornetq.utils.DataConstants;
-
-/**
- *
- * A SimpleStringTest
- *
- * @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
- *
- */
-public class SimpleStringTest extends TestCase
-{
- /**
- * Converting back and forth between char and byte requires care as char is unsigned.
- * @see SimpleString#getChars(int, int, char[], int)
- * @see SimpleString#charAt(int)
- * @see SimpleString#split(char)
- */
- public void testGetChar()
- {
- SimpleString p1 = new SimpleString("foo");
- SimpleString p2 = new SimpleString("bar");
- for (int i = 0; i < 1 << 16; i++)
- {
- String msg = "expecting " + i;
- char c = (char)i;
- SimpleString s = new SimpleString(String.valueOf(c));
-
- char[] c1 = new char[1];
- s.getChars(0, 1, c1, 0);
- assertEquals(msg, c, c1[0]);
- assertEquals(msg, c, s.charAt(0));
- SimpleString s2 = s.concat(c);
- assertEquals(msg, c, s2.charAt(1));
-
- // test splitting with chars
- SimpleString sSplit = new SimpleString("foo" + String.valueOf(c) + "bar");
- SimpleString[] chunks = sSplit.split(c);
- SimpleString[] split1 = p1.split(c);
- SimpleString[] split2 = p2.split(c);
- assertEquals(split1.length + split2.length, chunks.length);
- int j = 0;
-
- for (SimpleString iS : split1)
- {
- assertEquals(iS.toString(), iS, chunks[j++]);
- }
- for (SimpleString iS : split2)
- {
- assertEquals(iS.toString(), iS, chunks[j++]);
- }
- }
- }
-
- public void testString() throws Exception
- {
- final String str = "hello123ABC__524`16254`6125!%^$!%$!%$!%$!%!$%!$$!\uA324";
-
- SimpleString s = new SimpleString(str);
-
- Assert.assertEquals(str, s.toString());
-
- Assert.assertEquals(2 * str.length(), s.getData().length);
-
- byte[] data = s.getData();
-
- SimpleString s2 = new SimpleString(data);
-
- Assert.assertEquals(str, s2.toString());
- }
-
- public void testStartsWith() throws Exception
- {
- SimpleString s1 = new SimpleString("abcdefghi");
-
- Assert.assertTrue(s1.startsWith(new SimpleString("abc")));
-
- Assert.assertTrue(s1.startsWith(new SimpleString("abcdef")));
-
- Assert.assertTrue(s1.startsWith(new SimpleString("abcdefghi")));
-
- Assert.assertFalse(s1.startsWith(new SimpleString("abcdefghijklmn")));
-
- Assert.assertFalse(s1.startsWith(new SimpleString("aardvark")));
-
- Assert.assertFalse(s1.startsWith(new SimpleString("z")));
- }
-
- public void testCharSequence() throws Exception
- {
- String s = "abcdefghijkl";
- SimpleString s1 = new SimpleString(s);
-
- Assert.assertEquals('a', s1.charAt(0));
- Assert.assertEquals('b', s1.charAt(1));
- Assert.assertEquals('c', s1.charAt(2));
- Assert.assertEquals('k', s1.charAt(10));
- Assert.assertEquals('l', s1.charAt(11));
-
- try
- {
- s1.charAt(-1);
- Assert.fail("Should throw exception");
- }
- catch (IndexOutOfBoundsException e)
- {
- // OK
- }
-
- try
- {
- s1.charAt(-2);
- Assert.fail("Should throw exception");
- }
- catch (IndexOutOfBoundsException e)
- {
- // OK
- }
-
- try
- {
- s1.charAt(s.length());
- Assert.fail("Should throw exception");
- }
- catch (IndexOutOfBoundsException e)
- {
- // OK
- }
-
- try
- {
- s1.charAt(s.length() + 1);
- Assert.fail("Should throw exception");
- }
- catch (IndexOutOfBoundsException e)
- {
- // OK
- }
-
- Assert.assertEquals(s.length(), s1.length());
-
- CharSequence ss = s1.subSequence(0, s1.length());
-
- Assert.assertEquals(ss, s1);
-
- ss = s1.subSequence(1, 4);
- Assert.assertEquals(ss, new SimpleString("bcd"));
-
- ss = s1.subSequence(5, 10);
- Assert.assertEquals(ss, new SimpleString("fghij"));
-
- ss = s1.subSequence(5, 12);
- Assert.assertEquals(ss, new SimpleString("fghijkl"));
-
- try
- {
- s1.subSequence(-1, 2);
- Assert.fail("Should throw exception");
- }
- catch (IndexOutOfBoundsException e)
- {
- // OK
- }
-
- try
- {
- s1.subSequence(-4, -2);
- Assert.fail("Should throw exception");
- }
- catch (IndexOutOfBoundsException e)
- {
- // OK
- }
-
- try
- {
- s1.subSequence(0, s1.length() + 1);
- Assert.fail("Should throw exception");
- }
- catch (IndexOutOfBoundsException e)
- {
- // OK
- }
-
- try
- {
- s1.subSequence(0, s1.length() + 2);
- Assert.fail("Should throw exception");
- }
- catch (IndexOutOfBoundsException e)
- {
- // OK
- }
-
- try
- {
- s1.subSequence(5, 1);
- Assert.fail("Should throw exception");
- }
- catch (IndexOutOfBoundsException e)
- {
- // OK
- }
- }
-
- public void testEquals() throws Exception
- {
- Assert.assertFalse(new SimpleString("abcdef").equals(new Object()));
-
- Assert.assertEquals(new SimpleString("abcdef"), new SimpleString("abcdef"));
-
- Assert.assertFalse(new SimpleString("abcdef").equals(new SimpleString("abggcdef")));
- Assert.assertFalse(new SimpleString("abcdef").equals(new SimpleString("ghijkl")));
- }
-
- public void testHashcode() throws Exception
- {
- SimpleString str = new SimpleString("abcdef");
- SimpleString sameStr = new SimpleString("abcdef");
- SimpleString differentStr = new SimpleString("ghijk");
-
- Assert.assertTrue(str.hashCode() == sameStr.hashCode());
- Assert.assertFalse(str.hashCode() == differentStr.hashCode());
- }
-
- public void testUnicode() throws Exception
- {
- String myString = "abcdef&^*&!^ghijkl\uB5E2\uCAC7\uB2BB\uB7DD\uB7C7\uB3A3\uBCE4\uB5A5";
-
- SimpleString s = new SimpleString(myString);
- byte[] data = s.getData();
- s = new SimpleString(data);
-
- Assert.assertEquals(myString, s.toString());
- }
-
- public void testUnicodeWithSurrogates() throws Exception
- {
- String myString = "abcdef&^*&!^ghijkl\uD900\uDD00";
-
- SimpleString s = new SimpleString(myString);
- byte[] data = s.getData();
- s = new SimpleString(data);
-
- Assert.assertEquals(myString, s.toString());
- }
-
- public void testSizeofString() throws Exception
- {
- Assert.assertEquals(DataConstants.SIZE_INT, SimpleString.sizeofString(new SimpleString("")));
-
- SimpleString str = new SimpleString(RandomUtil.randomString());
- Assert.assertEquals(DataConstants.SIZE_INT + str.getData().length, SimpleString.sizeofString(str));
- }
-
- public void testSizeofNullableString() throws Exception
- {
- Assert.assertEquals(1, SimpleString.sizeofNullableString(null));
-
- Assert.assertEquals(1 + DataConstants.SIZE_INT, SimpleString.sizeofNullableString(new SimpleString("")));
-
- SimpleString str = new SimpleString(RandomUtil.randomString());
- Assert.assertEquals(1 + DataConstants.SIZE_INT + str.getData().length, SimpleString.sizeofNullableString(str));
- }
-
- public void testSplitNoDelimeter() throws Exception
- {
- SimpleString s = new SimpleString("abcdefghi");
- SimpleString[] strings = s.split('.');
- Assert.assertNotNull(strings);
- Assert.assertEquals(strings.length, 1);
- Assert.assertEquals(strings[0], s);
- }
-
- public void testSplit1Delimeter() throws Exception
- {
- SimpleString s = new SimpleString("abcd.efghi");
- SimpleString[] strings = s.split('.');
- Assert.assertNotNull(strings);
- Assert.assertEquals(strings.length, 2);
- Assert.assertEquals(strings[0], new SimpleString("abcd"));
- Assert.assertEquals(strings[1], new SimpleString("efghi"));
- }
-
- public void testSplitmanyDelimeters() throws Exception
- {
- SimpleString s = new SimpleString("abcd.efghi.jklmn.opqrs.tuvw.xyz");
- SimpleString[] strings = s.split('.');
- Assert.assertNotNull(strings);
- Assert.assertEquals(strings.length, 6);
- Assert.assertEquals(strings[0], new SimpleString("abcd"));
- Assert.assertEquals(strings[1], new SimpleString("efghi"));
- Assert.assertEquals(strings[2], new SimpleString("jklmn"));
- Assert.assertEquals(strings[3], new SimpleString("opqrs"));
- Assert.assertEquals(strings[4], new SimpleString("tuvw"));
- Assert.assertEquals(strings[5], new SimpleString("xyz"));
- }
-
- public void testContains()
- {
- SimpleString simpleString = new SimpleString("abcdefghijklmnopqrst");
- Assert.assertFalse(simpleString.contains('.'));
- Assert.assertFalse(simpleString.contains('%'));
- Assert.assertFalse(simpleString.contains('8'));
- Assert.assertFalse(simpleString.contains('.'));
- Assert.assertTrue(simpleString.contains('a'));
- Assert.assertTrue(simpleString.contains('b'));
- Assert.assertTrue(simpleString.contains('c'));
- Assert.assertTrue(simpleString.contains('d'));
- Assert.assertTrue(simpleString.contains('e'));
- Assert.assertTrue(simpleString.contains('f'));
- Assert.assertTrue(simpleString.contains('g'));
- Assert.assertTrue(simpleString.contains('h'));
- Assert.assertTrue(simpleString.contains('i'));
- Assert.assertTrue(simpleString.contains('j'));
- Assert.assertTrue(simpleString.contains('k'));
- Assert.assertTrue(simpleString.contains('l'));
- Assert.assertTrue(simpleString.contains('m'));
- Assert.assertTrue(simpleString.contains('n'));
- Assert.assertTrue(simpleString.contains('o'));
- Assert.assertTrue(simpleString.contains('p'));
- Assert.assertTrue(simpleString.contains('q'));
- Assert.assertTrue(simpleString.contains('r'));
- Assert.assertTrue(simpleString.contains('s'));
- Assert.assertTrue(simpleString.contains('t'));
- }
-
- public void testConcat()
- {
- SimpleString start = new SimpleString("abcdefg");
- SimpleString middle = new SimpleString("hijklmnop");
- SimpleString end = new SimpleString("qrstuvwxyz");
- Assert.assertEquals(start.concat(middle).concat(end), new SimpleString("abcdefghijklmnopqrstuvwxyz"));
- Assert.assertEquals(start.concat('.').concat(end), new SimpleString("abcdefg.qrstuvwxyz"));
- // Testing concat of SimpleString with String
- for (int i = 0; i < 10; i++)
- {
- Assert.assertEquals(new SimpleString("abcdefg-" + i), start.concat("-" + Integer.toString(i)));
-
- }
- }
-
- public void testMultithreadHashCode() throws Exception
- {
- for (int repeat = 0; repeat < 10; repeat++)
- {
-
- StringBuffer buffer = new StringBuffer();
-
- for (int i = 0; i < 100; i++)
- {
- buffer.append("Some Big String " + i);
- }
- String strvalue = buffer.toString();
-
- final int initialhash = new SimpleString(strvalue).hashCode();
-
- final SimpleString value = new SimpleString(strvalue);
-
- int nThreads = 100;
- final CountDownLatch latch = new CountDownLatch(nThreads);
- final CountDownLatch start = new CountDownLatch(1);
-
- class T extends Thread
- {
- boolean failed = false;
-
- @Override
- public void run()
- {
- try
- {
- latch.countDown();
- start.await();
-
- int newhash = value.hashCode();
-
- if (newhash != initialhash)
- {
- failed = true;
- }
- }
- catch (Exception e)
- {
- e.printStackTrace();
- failed = true;
- }
- }
- }
-
- T x[] = new T[nThreads];
- for (int i = 0; i < nThreads; i++)
- {
- x[i] = new T();
- x[i].start();
- }
-
- latch.await();
- start.countDown();
-
- for (T t : x)
- {
- t.join();
- }
-
- for (T t : x)
- {
- Assert.assertFalse(t.failed);
- }
- }
- }
-
-}
12 years, 11 months
JBoss hornetq SVN: r11967 - branches/Branch_2_2_EAP/src/main/org/hornetq/core/server/impl.
by do-not-reply@jboss.org
Author: clebert.suconic(a)jboss.com
Date: 2012-01-04 21:01:37 -0500 (Wed, 04 Jan 2012)
New Revision: 11967
Modified:
branches/Branch_2_2_EAP/src/main/org/hornetq/core/server/impl/ServerSessionImpl.java
Log:
JBPAPP-7829 fixing NPE on Security Test
Modified: branches/Branch_2_2_EAP/src/main/org/hornetq/core/server/impl/ServerSessionImpl.java
===================================================================
--- branches/Branch_2_2_EAP/src/main/org/hornetq/core/server/impl/ServerSessionImpl.java 2012-01-04 19:28:55 UTC (rev 11966)
+++ branches/Branch_2_2_EAP/src/main/org/hornetq/core/server/impl/ServerSessionImpl.java 2012-01-05 02:01:37 UTC (rev 11967)
@@ -1105,12 +1105,17 @@
public void send(final ServerMessage message, final boolean direct) throws Exception
{
long id = storageManager.generateUniqueID();
-
+
SimpleString address = message.getAddress();
message.setMessageID(id);
message.encodeMessageIDToBuffer();
+ if (defaultAddress == null && address != null)
+ {
+ defaultAddress = address;
+ }
+
if (address == null)
{
if (message.isDurable())
@@ -1131,6 +1136,7 @@
log.trace("send(message=" + message + ", direct=" + direct + ") being called");
}
+ log.info("message " + message + " managementAddress = " + managementAddress);
if (message.getAddress().equals(managementAddress))
{
// It's a management message
@@ -1141,11 +1147,6 @@
{
doSend(message, direct);
}
-
- if (defaultAddress == null)
- {
- defaultAddress = address;
- }
}
public void sendContinuations(final int packetSize,
12 years, 11 months
JBoss hornetq SVN: r11966 - in branches/Branch_2_2_EAP: tests/src/org/hornetq/tests/unit/util and 1 other directory.
by do-not-reply@jboss.org
Author: clebert.suconic(a)jboss.com
Date: 2012-01-04 14:28:55 -0500 (Wed, 04 Jan 2012)
New Revision: 11966
Modified:
branches/Branch_2_2_EAP/src/main/org/hornetq/api/core/SimpleString.java
branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/unit/util/SimpleStringTest.java
Log:
Back porting fixes on SimpleString & char (HORNETQ-822)
Modified: branches/Branch_2_2_EAP/src/main/org/hornetq/api/core/SimpleString.java
===================================================================
--- branches/Branch_2_2_EAP/src/main/org/hornetq/api/core/SimpleString.java 2012-01-04 16:42:54 UTC (rev 11965)
+++ branches/Branch_2_2_EAP/src/main/org/hornetq/api/core/SimpleString.java 2012-01-04 19:28:55 UTC (rev 11966)
@@ -25,7 +25,7 @@
* this minimises expensive copying between String objects.
*
* This object is used heavily throughout HornetQ for performance reasons.
- *
+ *
* @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
*
*/
@@ -116,7 +116,7 @@
}
pos <<= 1;
- return (char)(data[pos] | data[pos + 1] << 8);
+ return (char)((data[pos] & 0xFF) | (data[pos + 1] << 8) & 0xFF00);
}
public CharSequence subSequence(final int start, final int end)
@@ -215,7 +215,7 @@
{
return true;
}
-
+
if (other instanceof SimpleString)
{
SimpleString s = (SimpleString)other;
@@ -258,9 +258,8 @@
}
/**
- * splits this SimpleString into an array of SimpleString using the char param as the delimeter.
- *
- * i.e. "a.b" would return "a" and "b" if . was the delimeter
+ * Splits this SimpleString into an array of SimpleString using the char param as the delimiter.
+ * i.e. "a.b" would return "a" and "b" if . was the delimiter
* @param delim
*/
public SimpleString[] split(final char delim)
@@ -272,11 +271,13 @@
else
{
List<SimpleString> all = new ArrayList<SimpleString>();
+
+ byte low = (byte)(delim & 0xFF); // low byte
+ byte high = (byte)(delim >> 8 & 0xFF); // high byte
+
int lasPos = 0;
for (int i = 0; i < data.length; i += 2)
{
- byte low = (byte)(delim & 0xFF); // low byte
- byte high = (byte)(delim >> 8 & 0xFF); // high byte
if (data[i] == low && data[i + 1] == high)
{
byte[] bytes = new byte[i - lasPos];
@@ -301,10 +302,11 @@
*/
public boolean contains(final char c)
{
+ final byte low = (byte)(c & 0xFF); // low byte
+ final byte high = (byte)(c >> 8 & 0xFF); // high byte
+
for (int i = 0; i < data.length; i += 2)
{
- byte low = (byte)(c & 0xFF); // low byte
- byte high = (byte)(c >> 8 & 0xFF); // high byte
if (data[i] == low && data[i + 1] == high)
{
return true;
@@ -314,10 +316,9 @@
}
/**
- * concatanates a SimpleString and a String
- *
- * @param toAdd the String to concate with.
- * @return the concatanated SimpleString
+ * Concatenates a SimpleString and a String
+ * @param toAdd the String to concatenate with.
+ * @return the concatenated SimpleString
*/
public SimpleString concat(final String toAdd)
{
@@ -325,10 +326,9 @@
}
/**
- * concatanates 2 SimpleString's
- *
- * @param toAdd the SimpleString to concate with.
- * @return the concatanated SimpleString
+ * Concatenates 2 SimpleString's
+ * @param toAdd the SimpleString to concatenate with.
+ * @return the concatenated SimpleString
*/
public SimpleString concat(final SimpleString toAdd)
{
@@ -339,10 +339,9 @@
}
/**
- * concatanates a SimpleString and a char
- *
+ * Concatenates a SimpleString and a char
* @param c the char to concate with.
- * @return the concatanated SimpleString
+ * @return the concatenated SimpleString
*/
public SimpleString concat(final char c)
{
@@ -390,7 +389,7 @@
}
/**
- *
+ *
* @param srcBegin
* @param srcEnd
* @param dst
Modified: branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/unit/util/SimpleStringTest.java
===================================================================
--- branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/unit/util/SimpleStringTest.java 2012-01-04 16:42:54 UTC (rev 11965)
+++ branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/unit/util/SimpleStringTest.java 2012-01-04 19:28:55 UTC (rev 11966)
@@ -23,14 +23,56 @@
import org.hornetq.utils.DataConstants;
/**
- *
+ *
* A SimpleStringTest
- *
+ *
* @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
*
*/
public class SimpleStringTest extends UnitTestCase
{
+ /**
+ * Converting back and forth between char and byte requires care as char is unsigned.
+ * @see SimpleString#getChars(int, int, char[], int)
+ * @see SimpleString#charAt(int)
+ * @see SimpleString#split(char)
+ */
+ public void testGetChar()
+ {
+ SimpleString p1 = new SimpleString("foo");
+ SimpleString p2 = new SimpleString("bar");
+ for (int i = 0; i < 1 << 16; i++)
+ {
+ String msg = "expecting " + i;
+ char c = (char)i;
+ SimpleString s = new SimpleString(String.valueOf(c));
+
+ char[] c1 = new char[1];
+ s.getChars(0, 1, c1, 0);
+ assertEquals(msg, c, c1[0]);
+ assertEquals(msg, c, s.charAt(0));
+ SimpleString s2 = s.concat(c);
+ assertEquals(msg, c, s2.charAt(1));
+
+ // test splitting with chars
+ SimpleString sSplit = new SimpleString("foo" + String.valueOf(c) + "bar");
+ SimpleString[] chunks = sSplit.split(c);
+ SimpleString[] split1 = p1.split(c);
+ SimpleString[] split2 = p2.split(c);
+ assertEquals(split1.length + split2.length, chunks.length);
+ int j = 0;
+
+ for (SimpleString iS : split1)
+ {
+ assertEquals(iS.toString(), iS, chunks[j++]);
+ }
+ for (SimpleString iS : split2)
+ {
+ assertEquals(iS.toString(), iS, chunks[j++]);
+ }
+ }
+ }
+
public void testString() throws Exception
{
final String str = "hello123ABC__524`16254`6125!%^$!%$!%$!%$!%!$%!$$!\uA324";
12 years, 11 months
JBoss hornetq SVN: r11965 - trunk/hornetq-core/src/main/java/org/hornetq/core/filter/impl.
by do-not-reply@jboss.org
Author: borges
Date: 2012-01-04 11:42:54 -0500 (Wed, 04 Jan 2012)
New Revision: 11965
Modified:
trunk/hornetq-core/src/main/java/org/hornetq/core/filter/impl/Operator.java
Log:
Avoid inefficient Number instance creation.
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-04 16:42:34 UTC (rev 11964)
+++ trunk/hornetq-core/src/main/java/org/hornetq/core/filter/impl/Operator.java 2012-01-04 16:42:54 UTC (rev 11965)
@@ -370,13 +370,13 @@
/**
* Operation 3
- *
+ *
* | OR | T | F | U
* +------+-------+-------+--------
* | T | T | T | T
* | F | T | F | U
* | U | T | U | U
- * +------+-------+-------+-------
+ * +------+-------+-------+-------
*/
Object or() throws Exception
{
@@ -697,9 +697,9 @@
switch (class2)
{
case DOUBLE:
- return new Double(((Number)arg1).doubleValue() + ((Number)arg2).doubleValue());
+ return Double.valueOf(((Number)arg1).doubleValue() + ((Number)arg2).doubleValue());
case LONG:
- return new Double(((Number)arg1).doubleValue() + ((Number)arg2).doubleValue());
+ return Double.valueOf(((Number)arg1).doubleValue() + ((Number)arg2).doubleValue());
default:
throwBadObjectException(class2);
}
@@ -707,9 +707,9 @@
switch (class2)
{
case DOUBLE:
- return new Double(((Number)arg1).doubleValue() + ((Number)arg2).doubleValue());
+ return Double.valueOf(((Number)arg1).doubleValue() + ((Number)arg2).doubleValue());
case LONG:
- return new Long(((Number)arg1).longValue() + ((Number)arg2).longValue());
+ return Long.valueOf(((Number)arg1).longValue() + ((Number)arg2).longValue());
default:
throwBadObjectException(class2);
}
@@ -735,9 +735,9 @@
switch (class2)
{
case DOUBLE:
- return new Double(((Number)arg1).doubleValue() - ((Number)arg2).doubleValue());
+ return Double.valueOf(((Number)arg1).doubleValue() - ((Number)arg2).doubleValue());
case LONG:
- return new Double(((Number)arg1).doubleValue() - ((Number)arg2).doubleValue());
+ return Double.valueOf(((Number)arg1).doubleValue() - ((Number)arg2).doubleValue());
default:
throwBadObjectException(class2);
}
@@ -745,9 +745,9 @@
switch (class2)
{
case DOUBLE:
- return new Double(((Number)arg1).doubleValue() - ((Number)arg2).doubleValue());
+ return Double.valueOf(((Number)arg1).doubleValue() - ((Number)arg2).doubleValue());
case LONG:
- return new Long(((Number)arg1).longValue() - ((Number)arg2).longValue());
+ return Long.valueOf(((Number)arg1).longValue() - ((Number)arg2).longValue());
default:
throwBadObjectException(class2);
}
@@ -768,9 +768,9 @@
switch (class1)
{
case DOUBLE:
- return new Double(-((Number)arg1).doubleValue());
+ return Double.valueOf(-((Number)arg1).doubleValue());
case LONG:
- return new Long(-((Number)arg1).longValue());
+ return Long.valueOf(-((Number)arg1).longValue());
default:
throwBadObjectException(class1);
}
@@ -792,9 +792,9 @@
switch (class2)
{
case DOUBLE:
- return new Double(((Number)arg1).doubleValue() * ((Number)arg2).doubleValue());
+ return Double.valueOf(((Number)arg1).doubleValue() * ((Number)arg2).doubleValue());
case LONG:
- return new Double(((Number)arg1).doubleValue() * ((Number)arg2).doubleValue());
+ return Double.valueOf(((Number)arg1).doubleValue() * ((Number)arg2).doubleValue());
default:
throwBadObjectException(class2);
}
@@ -802,9 +802,9 @@
switch (class2)
{
case DOUBLE:
- return new Double(((Number)arg1).doubleValue() * ((Number)arg2).doubleValue());
+ return Double.valueOf(((Number)arg1).doubleValue() * ((Number)arg2).doubleValue());
case LONG:
- return new Long(((Number)arg1).longValue() * ((Number)arg2).longValue());
+ return Long.valueOf(((Number)arg1).longValue() * ((Number)arg2).longValue());
default:
throwBadObjectException(class2);
}
@@ -830,9 +830,9 @@
switch (class2)
{
case DOUBLE:
- return new Double(((Number)arg1).doubleValue() / ((Number)arg2).doubleValue());
+ return Double.valueOf(((Number)arg1).doubleValue() / ((Number)arg2).doubleValue());
case LONG:
- return new Double(((Number)arg1).doubleValue() / ((Number)arg2).doubleValue());
+ return Double.valueOf(((Number)arg1).doubleValue() / ((Number)arg2).doubleValue());
default:
throwBadObjectException(class2);
}
@@ -840,9 +840,9 @@
switch (class2)
{
case DOUBLE:
- return new Double(((Number)arg1).doubleValue() / ((Number)arg2).doubleValue());
+ return Double.valueOf(((Number)arg1).doubleValue() / ((Number)arg2).doubleValue());
case LONG:
- return new Long(((Number)arg1).longValue() / ((Number)arg2).longValue());
+ return Long.valueOf(((Number)arg1).longValue() / ((Number)arg2).longValue());
default:
throwBadObjectException(class2);
}
@@ -1063,22 +1063,22 @@
else if (className == Integer.class)
{
class1 = Operator.LONG;
- arg1 = new Long(((Integer)arg1).longValue());
+ arg1 = Long.valueOf(((Integer)arg1).longValue());
}
else if (className == Short.class)
{
class1 = Operator.LONG;
- arg1 = new Long(((Short)arg1).longValue());
+ arg1 = Long.valueOf(((Short)arg1).longValue());
}
else if (className == Byte.class)
{
class1 = Operator.LONG;
- arg1 = new Long(((Byte)arg1).longValue());
+ arg1 = Long.valueOf(((Byte)arg1).longValue());
}
else if (className == Float.class)
{
class1 = Operator.DOUBLE;
- arg1 = new Double(((Float)arg1).doubleValue());
+ arg1 = Double.valueOf(((Float)arg1).doubleValue());
}
else if (className == Boolean.class)
{
@@ -1136,22 +1136,22 @@
else if (className == Integer.class)
{
class2 = Operator.LONG;
- arg2 = new Long(((Integer)arg2).longValue());
+ arg2 = Long.valueOf(((Integer)arg2).longValue());
}
else if (className == Short.class)
{
class2 = Operator.LONG;
- arg2 = new Long(((Short)arg2).longValue());
+ arg2 = Long.valueOf(((Short)arg2).longValue());
}
else if (className == Byte.class)
{
class2 = Operator.LONG;
- arg2 = new Long(((Byte)arg2).longValue());
+ arg2 = Long.valueOf(((Byte)arg2).longValue());
}
else if (className == Float.class)
{
class2 = Operator.DOUBLE;
- arg2 = new Double(((Float)arg2).doubleValue());
+ arg2 = Double.valueOf(((Float)arg2).doubleValue());
}
else if (className == Boolean.class)
{
@@ -1209,22 +1209,22 @@
else if (className == Integer.class)
{
class3 = Operator.LONG;
- arg3 = new Long(((Integer)arg3).longValue());
+ arg3 = Long.valueOf(((Integer)arg3).longValue());
}
else if (className == Short.class)
{
class3 = Operator.LONG;
- arg3 = new Long(((Short)arg3).longValue());
+ arg3 = Long.valueOf(((Short)arg3).longValue());
}
else if (className == Byte.class)
{
class3 = Operator.LONG;
- arg3 = new Long(((Byte)arg3).longValue());
+ arg3 = Long.valueOf(((Byte)arg3).longValue());
}
else if (className == Float.class)
{
class3 = Operator.DOUBLE;
- arg3 = new Double(((Float)arg3).doubleValue());
+ arg3 = Double.valueOf(((Float)arg3).doubleValue());
}
else if (className == Boolean.class)
{
12 years, 11 months
JBoss hornetq SVN: r11964 - in trunk/hornetq-core/src/main/java/org/hornetq/core: deployers/impl and 3 other directories.
by do-not-reply@jboss.org
Author: borges
Date: 2012-01-04 11:42:34 -0500 (Wed, 04 Jan 2012)
New Revision: 11964
Modified:
trunk/hornetq-core/src/main/java/org/hornetq/core/client/impl/ClientLargeMessageImpl.java
trunk/hornetq-core/src/main/java/org/hornetq/core/client/impl/Topology.java
trunk/hornetq-core/src/main/java/org/hornetq/core/deployers/impl/FileDeploymentManager.java
trunk/hornetq-core/src/main/java/org/hornetq/core/paging/impl/PagingStoreImpl.java
trunk/hornetq-core/src/main/java/org/hornetq/core/postoffice/impl/PostOfficeImpl.java
trunk/hornetq-core/src/main/java/org/hornetq/core/protocol/core/impl/ChannelImpl.java
Log:
Fix findbugs warnings
Modified: trunk/hornetq-core/src/main/java/org/hornetq/core/client/impl/ClientLargeMessageImpl.java
===================================================================
--- trunk/hornetq-core/src/main/java/org/hornetq/core/client/impl/ClientLargeMessageImpl.java 2012-01-04 14:58:55 UTC (rev 11963)
+++ trunk/hornetq-core/src/main/java/org/hornetq/core/client/impl/ClientLargeMessageImpl.java 2012-01-04 16:42:34 UTC (rev 11964)
@@ -210,7 +210,7 @@
// Inner classes -------------------------------------------------
- protected class HornetQOutputStream extends OutputStream
+ protected static class HornetQOutputStream extends OutputStream
{
HornetQBuffer bufferOut;
@@ -219,9 +219,6 @@
this.bufferOut = out;
}
- /* (non-Javadoc)
- * @see java.io.OutputStream#write(int)
- */
@Override
public void write(int b) throws IOException
{
Modified: trunk/hornetq-core/src/main/java/org/hornetq/core/client/impl/Topology.java
===================================================================
--- trunk/hornetq-core/src/main/java/org/hornetq/core/client/impl/Topology.java 2012-01-04 14:58:55 UTC (rev 11963)
+++ trunk/hornetq-core/src/main/java/org/hornetq/core/client/impl/Topology.java 2012-01-04 16:42:34 UTC (rev 11964)
@@ -44,11 +44,11 @@
private Executor executor = null;
/** Used to debug operations.
- *
+ *
* Someone may argue this is not needed. But it's impossible to debg anything related to topology without knowing what node
* or what object missed a Topology update.
- *
- * Hence I added some information to locate debugging here.
+ *
+ * Hence I added some information to locate debugging here.
* */
private volatile Object owner;
@@ -148,9 +148,9 @@
}
/**
- *
+ *
* @param <p>uniqueIdentifier an unique identifier for when the change was made
- * We will use current time millis for starts, and a ++ of that number for shutdown. </p>
+ * We will use current time millis for starts, and a ++ of that number for shutdown. </p>
* @param nodeId
* @param memberInput
* @return
@@ -207,7 +207,7 @@
if (log.isDebugEnabled())
{
log.debug(this + "::updated currentMember=nodeID=" +
- nodeId +
+ nodeId +
", currentMember=" +
currentMember +
", memberInput=" +
@@ -262,7 +262,7 @@
" connector = " +
memberToSend.getConnector());
}
-
+
try
{
listener.nodeUP(uniqueEventID, nodeId, memberToSend.getConnector(), false);
@@ -481,18 +481,17 @@
public synchronized String describe(final String text)
{
-
- String desc = text + "topology on " + this + ":\n";
+ StringBuilder desc = new StringBuilder(text + "topology on " + this + ":\n");
for (Entry<String, TopologyMember> entry : new HashMap<String, TopologyMember>(mapTopology).entrySet())
{
- desc += "\t" + entry.getKey() + " => " + entry.getValue() + "\n";
+ desc.append("\t" + entry.getKey() + " => " + entry.getValue() + "\n");
}
- desc += "\t" + "nodes=" + nodes() + "\t" + "members=" + members();
+ desc.append("\t" + "nodes=" + nodes() + "\t" + "members=" + members());
if (mapTopology.isEmpty())
{
- desc += "\tEmpty";
+ desc.append("\tEmpty");
}
- return desc;
+ return desc.toString();
}
public int members()
Modified: trunk/hornetq-core/src/main/java/org/hornetq/core/deployers/impl/FileDeploymentManager.java
===================================================================
--- trunk/hornetq-core/src/main/java/org/hornetq/core/deployers/impl/FileDeploymentManager.java 2012-01-04 14:58:55 UTC (rev 11963)
+++ trunk/hornetq-core/src/main/java/org/hornetq/core/deployers/impl/FileDeploymentManager.java 2012-01-04 16:42:34 UTC (rev 11964)
@@ -14,6 +14,7 @@
package org.hornetq.core.deployers.impl;
import java.io.File;
+import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URL;
import java.net.URLDecoder;
@@ -251,7 +252,7 @@
deployed.remove(pair);
}
}
- catch (Exception e)
+ catch (IOException e)
{
FileDeploymentManager.log.warn("error scanning for URL's " + e);
}
@@ -271,7 +272,7 @@
/**
* Checks if the URL is among the current thread context class loader's resources.
- *
+ *
* We do not check that the corresponding file exists using File.exists() directly as it would fail
* in the case the resource is loaded from inside an EAR file (see https://jira.jboss.org/jira/browse/HORNETQ-122)
*/
@@ -291,7 +292,7 @@
}
}
}
- catch (Exception e)
+ catch (IOException e)
{
return false;
}
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-04 14:58:55 UTC (rev 11963)
+++ trunk/hornetq-core/src/main/java/org/hornetq/core/paging/impl/PagingStoreImpl.java 2012-01-04 16:42:34 UTC (rev 11964)
@@ -507,8 +507,14 @@
public void stopPaging()
{
lock.writeLock().lock();
- paging = false;
- lock.writeLock().unlock();
+ try
+ {
+ paging = false;
+ }
+ finally
+ {
+ lock.writeLock().unlock();
+ }
}
public boolean startPaging()
@@ -715,7 +721,7 @@
private final Runnable memoryFreedRunnablesExecutor = new MemoryFreedRunnablesExecutor();
- class OurRunnable implements Runnable
+ static final class OurRunnable implements Runnable
{
boolean ran;
Modified: trunk/hornetq-core/src/main/java/org/hornetq/core/postoffice/impl/PostOfficeImpl.java
===================================================================
--- trunk/hornetq-core/src/main/java/org/hornetq/core/postoffice/impl/PostOfficeImpl.java 2012-01-04 14:58:55 UTC (rev 11963)
+++ trunk/hornetq-core/src/main/java/org/hornetq/core/postoffice/impl/PostOfficeImpl.java 2012-01-04 16:42:34 UTC (rev 11964)
@@ -79,7 +79,7 @@
public class PostOfficeImpl implements PostOffice, NotificationListener, BindingsFactory
{
private static final Logger log = Logger.getLogger(PostOfficeImpl.class);
-
+
private static final boolean isTrace = log.isTraceEnabled();
public static final SimpleString HDR_RESET_QUEUE_DATA = new SimpleString("_HQ_RESET_QUEUE_DATA");
@@ -472,7 +472,7 @@
}
String uid = UUIDGenerator.getInstance().generateStringUUID();
-
+
if (isTrace)
{
log.trace("Sending notification for addBinding " + binding + " from server " + server);
@@ -596,7 +596,7 @@
return;
}
-
+
if (message.hasInternalProperties())
{
// We need to perform some cleanup on internal properties,
@@ -692,7 +692,7 @@
// arrived the target node
// as described on https://issues.jboss.org/browse/JBPAPP-6130
ServerMessage copyRedistribute = message.copy(storageManager.generateUniqueID());
-
+
Bindings bindings = addressManager.getBindingsForRoutingAddress(message.getAddress());
boolean res = false;
@@ -754,7 +754,7 @@
{
throw new IllegalStateException("Cannot find queue " + queueName);
}
-
+
if (log.isDebugEnabled())
{
log.debug("PostOffice.sendQueueInfoToQueue on server=" + this.server + ", queueName=" + queueName + " and address=" + address);
@@ -799,7 +799,7 @@
message = createQueueInfoMessage(NotificationType.CONSUMER_CREATED, queueName);
message.putStringProperty(ManagementHelper.HDR_ADDRESS, info.getAddress());
- message.putStringProperty(ManagementHelper.HDR_CLUSTER_NAME, info.getClusterName());
+ message.putStringProperty(ManagementHelper.HDR_CLUSTER_NAME, info.getClusterName());
message.putStringProperty(ManagementHelper.HDR_ROUTING_NAME, info.getRoutingName());
message.putIntProperty(ManagementHelper.HDR_DISTANCE, info.getDistance());
@@ -890,7 +890,7 @@
}
}
- private class PageDelivery extends TransactionOperationAbstract
+ private static class PageDelivery extends TransactionOperationAbstract
{
private final Set<Queue> queues = new HashSet<Queue>();
@@ -1065,7 +1065,7 @@
}
else
{
-
+
storageManager.confirmPendingLargeMessageTX(tx,
largeServerMessage.getMessageID(),
largeServerMessage.getPendingRecordID());
@@ -1145,7 +1145,7 @@
warnMessage.append("Duplicate message detected through the bridge - message will not be routed. Message information:\n");
warnMessage.append(message.toString());
PostOfficeImpl.log.warn(warnMessage.toString());
-
+
if (context.getTransaction() != null)
{
context.getTransaction().markAsRollbackOnly(new HornetQException(HornetQException.DUPLICATE_ID_REJECTED, warnMessage.toString()));
@@ -1327,7 +1327,7 @@
}
}
- private class AddOperation implements TransactionOperation
+ private static class AddOperation implements TransactionOperation
{
private final List<MessageReference> refs;
Modified: trunk/hornetq-core/src/main/java/org/hornetq/core/protocol/core/impl/ChannelImpl.java
===================================================================
--- trunk/hornetq-core/src/main/java/org/hornetq/core/protocol/core/impl/ChannelImpl.java 2012-01-04 14:58:55 UTC (rev 11963)
+++ trunk/hornetq-core/src/main/java/org/hornetq/core/protocol/core/impl/ChannelImpl.java 2012-01-04 16:42:34 UTC (rev 11964)
@@ -524,10 +524,9 @@
lock.lock();
- response = packet;
-
try
{
+ response = packet;
sendCondition.signal();
}
finally
12 years, 11 months
JBoss hornetq SVN: r11963 - trunk/hornetq-journal/src/main/java/org/hornetq/core/journal/impl.
by do-not-reply@jboss.org
Author: borges
Date: 2012-01-04 09:58:55 -0500 (Wed, 04 Jan 2012)
New Revision: 11963
Modified:
trunk/hornetq-journal/src/main/java/org/hornetq/core/journal/impl/SimpleWaitIOCallback.java
Log:
HORNETQ-820 Try to fix hang on SimpleWaitIOCallback assuming it is a lost wake-up
Modified: trunk/hornetq-journal/src/main/java/org/hornetq/core/journal/impl/SimpleWaitIOCallback.java
===================================================================
--- trunk/hornetq-journal/src/main/java/org/hornetq/core/journal/impl/SimpleWaitIOCallback.java 2012-01-04 14:23:01 UTC (rev 11962)
+++ trunk/hornetq-journal/src/main/java/org/hornetq/core/journal/impl/SimpleWaitIOCallback.java 2012-01-04 14:58:55 UTC (rev 11963)
@@ -35,7 +35,8 @@
private volatile String errorMessage;
private volatile int errorCode = 0;
-
+
+ @Override
public String toString()
{
return "simpleWaitIOCallback";
@@ -60,7 +61,11 @@
@Override
public void waitCompletion() throws Exception
{
- latch.await();
+ while (true)
+ {
+ if (latch.await(2, TimeUnit.SECONDS))
+ break;
+ }
if (errorMessage != null)
{
12 years, 11 months
JBoss hornetq SVN: r11962 - in branches/Branch_2_2_EAP: tests/src/org/hornetq/tests/integration/client and 1 other directory.
by do-not-reply@jboss.org
Author: clebert.suconic(a)jboss.com
Date: 2012-01-04 09:23:01 -0500 (Wed, 04 Jan 2012)
New Revision: 11962
Modified:
branches/Branch_2_2_EAP/src/main/org/hornetq/core/server/impl/QueueImpl.java
branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/client/ExpiryLargeMessageTest.java
Log:
https://issues.jboss.org/browse/JBPAPP-7846
Modified: branches/Branch_2_2_EAP/src/main/org/hornetq/core/server/impl/QueueImpl.java
===================================================================
--- branches/Branch_2_2_EAP/src/main/org/hornetq/core/server/impl/QueueImpl.java 2012-01-04 14:11:58 UTC (rev 11961)
+++ branches/Branch_2_2_EAP/src/main/org/hornetq/core/server/impl/QueueImpl.java 2012-01-04 14:23:01 UTC (rev 11962)
@@ -1222,6 +1222,7 @@
try
{
+ boolean expired = false;
while (iter.hasNext())
{
MessageReference ref = iter.next();
@@ -1230,6 +1231,7 @@
if (ref.getMessage().isExpired())
{
deliveringCount.incrementAndGet();
+ expired = true;
expire(ref);
iter.remove();
refRemoved(ref);
@@ -1240,6 +1242,11 @@
log.warn("Error expiring reference " + ref, e);
}
}
+
+ if (expired && pageIterator != null && pageIterator.hasNext())
+ {
+ scheduleDepage();
+ }
}
finally
{
Modified: branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/client/ExpiryLargeMessageTest.java
===================================================================
--- branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/client/ExpiryLargeMessageTest.java 2012-01-04 14:11:58 UTC (rev 11961)
+++ branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/client/ExpiryLargeMessageTest.java 2012-01-04 14:23:01 UTC (rev 11962)
@@ -23,7 +23,9 @@
import org.hornetq.api.core.client.ClientSession;
import org.hornetq.api.core.client.ClientSessionFactory;
import org.hornetq.api.core.client.ServerLocator;
+import org.hornetq.core.logging.Logger;
import org.hornetq.core.server.HornetQServer;
+import org.hornetq.core.server.Queue;
import org.hornetq.core.settings.impl.AddressFullMessagePolicy;
import org.hornetq.core.settings.impl.AddressSettings;
import org.hornetq.tests.util.ServiceTestBase;
@@ -38,6 +40,8 @@
public class ExpiryLargeMessageTest extends ServiceTestBase
{
+ private static final Logger log = Logger.getLogger(ExpiryLargeMessageTest.class);
+
// Constants -----------------------------------------------------
final SimpleString EXPIRY = new SimpleString("my-expiry");
@@ -129,25 +133,32 @@
producer.send(message);
}
+
+ session.close();
server.stop();
server.start();
+
+ Queue queueExpiry = server.locateQueue(EXPIRY);
+ Queue myQueue = server.locateQueue(MY_QUEUE);
sf = locator.createSessionFactory();
-
- session = sf.createSession(true, true, 0);
-
+
Thread.sleep(1500);
- // just to try expiring
- ClientConsumer cons = session.createConsumer(MY_QUEUE);
- assertNull(cons.receive(1000));
+ long timeout = System.currentTimeMillis() + 5000;
+ while (timeout > System.currentTimeMillis() && queueExpiry.getMessageCount() != numberOfMessages)
+ {
+ // What the Expiry Scan would be doing
+ myQueue.expireReferences();
+ Thread.sleep(50);
+ }
+
+ assertEquals(50, queueExpiry.getMessageCount());
- session.close();
-
session = sf.createSession(false, false);
- cons = session.createConsumer(EXPIRY);
+ ClientConsumer cons = session.createConsumer(EXPIRY);
session.start();
// Consume half of the messages to make sure all the messages are paging (on the second try)
@@ -167,7 +178,7 @@
cons = session.createConsumer(EXPIRY);
session.start();
- System.out.println("Trying " + rep);
+ log.info("Trying " + rep);
for (int i = 0; i < numberOfMessages / 2; i++)
{
ClientMessage message = cons.receive(5000);
12 years, 11 months