JBoss hornetq SVN: r11723 - in branches/Branch_2_2_AS7: tests/src/org/hornetq/tests/integration/ra and 1 other directories.
by do-not-reply@jboss.org
Author: ataylor
Date: 2011-11-19 04:16:22 -0500 (Sat, 19 Nov 2011)
New Revision: 11723
Modified:
branches/Branch_2_2_AS7/src/main/org/hornetq/core/client/impl/ServerLocatorImpl.java
branches/Branch_2_2_AS7/tests/src/org/hornetq/tests/integration/ra/HornetQRATestBase.java
branches/Branch_2_2_AS7/tests/src/org/hornetq/tests/unit/ra/ResourceAdapterTest.java
Log:
revert classloader change and test fix
Modified: branches/Branch_2_2_AS7/src/main/org/hornetq/core/client/impl/ServerLocatorImpl.java
===================================================================
--- branches/Branch_2_2_AS7/src/main/org/hornetq/core/client/impl/ServerLocatorImpl.java 2011-11-18 22:24:28 UTC (rev 11722)
+++ branches/Branch_2_2_AS7/src/main/org/hornetq/core/client/impl/ServerLocatorImpl.java 2011-11-19 09:16:22 UTC (rev 11723)
@@ -47,6 +47,7 @@
import org.hornetq.core.cluster.impl.DiscoveryGroupImpl;
import org.hornetq.core.logging.Logger;
import org.hornetq.core.remoting.FailureListener;
+import org.hornetq.utils.ClassloadingUtil;
import org.hornetq.utils.HornetQThreadFactory;
import org.hornetq.utils.UUIDGenerator;
@@ -310,6 +311,7 @@
}
+
private void instantiateLoadBalancingPolicy()
{
if (connectionLoadBalancingPolicyClassName == null)
@@ -317,25 +319,7 @@
throw new IllegalStateException("Please specify a load balancing policy class name on the session factory");
}
- AccessController.doPrivileged(new PrivilegedAction<Object>()
- {
- public Object run()
- {
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
- try
- {
- Class<?> clazz = loader.loadClass(connectionLoadBalancingPolicyClassName);
- loadBalancingPolicy = (ConnectionLoadBalancingPolicy)clazz.newInstance();
- return null;
- }
- catch (Exception e)
- {
- throw new IllegalArgumentException("Unable to instantiate load balancing policy \"" + connectionLoadBalancingPolicyClassName +
- "\"",
- e);
- }
- }
- });
+ loadBalancingPolicy = (ConnectionLoadBalancingPolicy) ClassloadingUtil.newInstanceFromClassLoader(connectionLoadBalancingPolicyClassName);
}
private synchronized void initialise() throws HornetQException
Modified: branches/Branch_2_2_AS7/tests/src/org/hornetq/tests/integration/ra/HornetQRATestBase.java
===================================================================
--- branches/Branch_2_2_AS7/tests/src/org/hornetq/tests/integration/ra/HornetQRATestBase.java 2011-11-18 22:24:28 UTC (rev 11722)
+++ branches/Branch_2_2_AS7/tests/src/org/hornetq/tests/integration/ra/HornetQRATestBase.java 2011-11-19 09:16:22 UTC (rev 11723)
@@ -225,7 +225,7 @@
}
- private static class DummyServiceContainer implements ServiceContainer
+ public static class DummyServiceContainer implements ServiceContainer
{
public void shutdown()
{
Modified: branches/Branch_2_2_AS7/tests/src/org/hornetq/tests/unit/ra/ResourceAdapterTest.java
===================================================================
--- branches/Branch_2_2_AS7/tests/src/org/hornetq/tests/unit/ra/ResourceAdapterTest.java 2011-11-18 22:24:28 UTC (rev 11722)
+++ branches/Branch_2_2_AS7/tests/src/org/hornetq/tests/unit/ra/ResourceAdapterTest.java 2011-11-19 09:16:22 UTC (rev 11723)
@@ -43,6 +43,7 @@
import org.hornetq.core.remoting.impl.invm.InVMConnector;
import org.hornetq.core.remoting.impl.netty.NettyConnector;
import org.hornetq.core.server.HornetQServer;
+import org.hornetq.integration.jboss.recovery.AS7RecoveryRegistry;
import org.hornetq.jms.client.HornetQConnectionFactory;
import org.hornetq.jms.client.HornetQDestination;
import org.hornetq.ra.ConnectionFactoryProperties;
@@ -50,6 +51,7 @@
import org.hornetq.ra.HornetQResourceAdapter;
import org.hornetq.ra.inflow.HornetQActivation;
import org.hornetq.ra.inflow.HornetQActivationSpec;
+import org.hornetq.tests.integration.ra.HornetQRATestBase;
import org.hornetq.tests.util.ServiceTestBase;
/**
@@ -465,6 +467,7 @@
ra.setConnectorClassName("org.hornetq.core.remoting.impl.invm.InVMConnectorFactory");
ra.setUserName("userGlobal");
ra.setPassword("passwordGlobal");
+ AS7RecoveryRegistry.container = new HornetQRATestBase.DummyServiceContainer();
ra.start(fakeCTX);
Connection conn = ra.getDefaultHornetQConnectionFactory().createConnection();
13 years, 1 month
JBoss hornetq SVN: r11722 - branches/Branch_2_2_EAP.
by do-not-reply@jboss.org
Author: clebert.suconic(a)jboss.com
Date: 2011-11-18 17:24:28 -0500 (Fri, 18 Nov 2011)
New Revision: 11722
Added:
branches/Branch_2_2_EAP/mac-build.sh
Log:
adding mac-build to help with property on mac
Added: branches/Branch_2_2_EAP/mac-build.sh
===================================================================
--- branches/Branch_2_2_EAP/mac-build.sh (rev 0)
+++ branches/Branch_2_2_EAP/mac-build.sh 2011-11-18 22:24:28 UTC (rev 11722)
@@ -0,0 +1,2 @@
+#you need to define this variable on mac
+./build.sh -Djdk5.home=/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/ "$@"
Property changes on: branches/Branch_2_2_EAP/mac-build.sh
___________________________________________________________________
Added: svn:executable
+ *
13 years, 1 month
JBoss hornetq SVN: r11721 - in branches/Branch_2_2_EAP: src/main/org/hornetq/core/postoffice/impl and 3 other directories.
by do-not-reply@jboss.org
Author: clebert.suconic(a)jboss.com
Date: 2011-11-18 17:24:01 -0500 (Fri, 18 Nov 2011)
New Revision: 11721
Modified:
branches/Branch_2_2_EAP/src/main/org/hornetq/core/postoffice/PostOffice.java
branches/Branch_2_2_EAP/src/main/org/hornetq/core/postoffice/impl/PostOfficeImpl.java
branches/Branch_2_2_EAP/src/main/org/hornetq/core/postoffice/impl/SimpleAddressManager.java
branches/Branch_2_2_EAP/src/main/org/hornetq/core/protocol/stomp/StompProtocolManager.java
branches/Branch_2_2_EAP/src/main/org/hornetq/core/protocol/stomp/StompSession.java
branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/stomp/StompTest.java
branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/unit/core/server/impl/fakes/FakePostOffice.java
Log:
Stomp to throw exception on inexistent destination = HORNETQ-799
Modified: branches/Branch_2_2_EAP/src/main/org/hornetq/core/postoffice/PostOffice.java
===================================================================
--- branches/Branch_2_2_EAP/src/main/org/hornetq/core/postoffice/PostOffice.java 2011-11-18 22:15:50 UTC (rev 11720)
+++ branches/Branch_2_2_EAP/src/main/org/hornetq/core/postoffice/PostOffice.java 2011-11-18 22:24:01 UTC (rev 11721)
@@ -42,7 +42,21 @@
void addBinding(Binding binding) throws Exception;
Binding removeBinding(SimpleString uniqueName) throws Exception;
+
+ /**
+ * It will lookup the Binding without creating an item on the Queue if non-existent
+ * @param address
+ * @return
+ * @throws Exception
+ */
+ Bindings lookupBindingsForAddress(SimpleString address) throws Exception;
+ /**
+ * Differently to lookupBindings, this will always create a new element on the Queue if non-existent
+ * @param address
+ * @return
+ * @throws Exception
+ */
Bindings getBindingsForAddress(SimpleString address) throws Exception;
Binding getBinding(SimpleString uniqueName);
Modified: branches/Branch_2_2_EAP/src/main/org/hornetq/core/postoffice/impl/PostOfficeImpl.java
===================================================================
--- branches/Branch_2_2_EAP/src/main/org/hornetq/core/postoffice/impl/PostOfficeImpl.java 2011-11-18 22:15:50 UTC (rev 11720)
+++ branches/Branch_2_2_EAP/src/main/org/hornetq/core/postoffice/impl/PostOfficeImpl.java 2011-11-18 22:24:01 UTC (rev 11721)
@@ -541,6 +541,12 @@
return bindings;
}
+
+ public Bindings lookupBindingsForAddress(final SimpleString address) throws Exception
+ {
+ return addressManager.getBindingsForRoutingAddress(address);
+ }
+
public Binding getBinding(final SimpleString name)
{
return addressManager.getBinding(name);
Modified: branches/Branch_2_2_EAP/src/main/org/hornetq/core/postoffice/impl/SimpleAddressManager.java
===================================================================
--- branches/Branch_2_2_EAP/src/main/org/hornetq/core/postoffice/impl/SimpleAddressManager.java 2011-11-18 22:15:50 UTC (rev 11720)
+++ branches/Branch_2_2_EAP/src/main/org/hornetq/core/postoffice/impl/SimpleAddressManager.java 2011-11-18 22:24:01 UTC (rev 11721)
@@ -35,8 +35,14 @@
{
private static final Logger log = Logger.getLogger(SimpleAddressManager.class);
+ /**
+ * HashMap<Address, Binding>
+ */
private final ConcurrentMap<SimpleString, Bindings> mappings = new ConcurrentHashMap<SimpleString, Bindings>();
+ /**
+ * HashMap<QueueName, Binding>
+ */
private final ConcurrentMap<SimpleString, Binding> nameMap = new ConcurrentHashMap<SimpleString, Binding>();
private final BindingsFactory bindingsFactory;
Modified: branches/Branch_2_2_EAP/src/main/org/hornetq/core/protocol/stomp/StompProtocolManager.java
===================================================================
--- branches/Branch_2_2_EAP/src/main/org/hornetq/core/protocol/stomp/StompProtocolManager.java 2011-11-18 22:15:50 UTC (rev 11720)
+++ branches/Branch_2_2_EAP/src/main/org/hornetq/core/protocol/stomp/StompProtocolManager.java 2011-11-18 22:24:01 UTC (rev 11721)
@@ -32,6 +32,7 @@
import org.hornetq.api.core.client.HornetQClient;
import org.hornetq.core.journal.IOAsyncTask;
import org.hornetq.core.logging.Logger;
+import org.hornetq.core.postoffice.Bindings;
import org.hornetq.core.server.HornetQServer;
import org.hornetq.core.server.ServerSession;
import org.hornetq.core.server.impl.ServerMessageImpl;
@@ -536,10 +537,14 @@
String destination = (String)headers.remove(Stomp.Headers.Send.DESTINATION);
String txID = (String)headers.remove(Stomp.Headers.TRANSACTION);
long timestamp = System.currentTimeMillis();
-
+
+ SimpleString address = SimpleString.toSimpleString(destination);
ServerMessageImpl message = new ServerMessageImpl(server.getStorageManager().generateUniqueID(), 512);
message.setTimestamp(timestamp);
- message.setAddress(SimpleString.toSimpleString(destination));
+ message.setAddress(address);
+
+ validateDestination(address);
+
StompUtils.copyStandardHeadersFromFrameToMessage(frame, message);
if (headers.containsKey(Stomp.Headers.CONTENT_LENGTH))
{
@@ -571,6 +576,20 @@
return null;
}
+ /**
+ * @param address
+ * @throws Exception
+ * @throws HornetQException
+ */
+ private void validateDestination(SimpleString address) throws Exception, HornetQException
+ {
+ Bindings binding = server.getPostOffice().lookupBindingsForAddress(address);
+ if (binding == null || binding.getBindings().size() == 0)
+ {
+ throw new HornetQException(HornetQException.ADDRESS_DOES_NOT_EXIST, "Address " + address + " has not been deployed");
+ }
+ }
+
private StompFrame onConnect(StompFrame frame, final StompConnection connection) throws Exception
{
Map<String, Object> headers = frame.getHeaders();
Modified: branches/Branch_2_2_EAP/src/main/org/hornetq/core/protocol/stomp/StompSession.java
===================================================================
--- branches/Branch_2_2_EAP/src/main/org/hornetq/core/protocol/stomp/StompSession.java 2011-11-18 22:15:50 UTC (rev 11720)
+++ branches/Branch_2_2_EAP/src/main/org/hornetq/core/protocol/stomp/StompSession.java 2011-11-18 22:24:01 UTC (rev 11721)
@@ -23,7 +23,6 @@
import org.hornetq.api.core.Message;
import org.hornetq.api.core.Pair;
import org.hornetq.api.core.SimpleString;
-import org.hornetq.api.core.TransportConfiguration;
import org.hornetq.core.logging.Logger;
import org.hornetq.core.message.impl.MessageImpl;
import org.hornetq.core.persistence.OperationContext;
Modified: branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/stomp/StompTest.java
===================================================================
--- branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/stomp/StompTest.java 2011-11-18 22:15:50 UTC (rev 11720)
+++ branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/stomp/StompTest.java 2011-11-18 22:24:01 UTC (rev 11721)
@@ -74,6 +74,23 @@
assertTrue(latch.await(60, TimeUnit.SECONDS));
}
+ public void testSendInvalidDestination() throws Exception
+ {
+ String frame = "CONNECT\n" + "login: brianm\n" + "passcode: wombats\n\n" + Stomp.NULL;
+ sendFrame(frame);
+ frame = receiveFrame(10000);
+
+ Assert.assertTrue(frame.startsWith("CONNECTED"));
+
+ frame = "SEND\n" + "destination:" + getQueuePrefix() + getQueueName()+"IdontExist" + "\n\n" + "Hello World" + Stomp.NULL;
+ sendFrame(frame);
+
+ String frameReceived = receiveFrame(1000);
+ System.out.println(frameReceived);
+
+ Assert.assertTrue(frameReceived.startsWith("ERROR"));
+ }
+
public void testConnect() throws Exception
{
@@ -124,7 +141,6 @@
{
}
}
-
public void testSendMessage() throws Exception
{
Modified: branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/unit/core/server/impl/fakes/FakePostOffice.java
===================================================================
--- branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/unit/core/server/impl/fakes/FakePostOffice.java 2011-11-18 22:15:50 UTC (rev 11720)
+++ branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/unit/core/server/impl/fakes/FakePostOffice.java 2011-11-18 22:24:01 UTC (rev 11721)
@@ -85,6 +85,12 @@
return null;
}
+ public Bindings lookupBindingsForAddress(final SimpleString address) throws Exception
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
/* (non-Javadoc)
* @see org.hornetq.core.postoffice.PostOffice#getDuplicateIDCache(org.hornetq.utils.SimpleString)
*/
13 years, 1 month
JBoss hornetq SVN: r11720 - in branches/Branch_2_2_AS7: src/main/org/hornetq/core/postoffice/impl and 3 other directories.
by do-not-reply@jboss.org
Author: clebert.suconic(a)jboss.com
Date: 2011-11-18 17:15:50 -0500 (Fri, 18 Nov 2011)
New Revision: 11720
Modified:
branches/Branch_2_2_AS7/src/main/org/hornetq/core/postoffice/PostOffice.java
branches/Branch_2_2_AS7/src/main/org/hornetq/core/postoffice/impl/PostOfficeImpl.java
branches/Branch_2_2_AS7/src/main/org/hornetq/core/postoffice/impl/SimpleAddressManager.java
branches/Branch_2_2_AS7/src/main/org/hornetq/core/protocol/stomp/StompProtocolManager.java
branches/Branch_2_2_AS7/src/main/org/hornetq/core/protocol/stomp/StompSession.java
branches/Branch_2_2_AS7/tests/src/org/hornetq/tests/integration/stomp/StompTest.java
branches/Branch_2_2_AS7/tests/src/org/hornetq/tests/unit/core/server/impl/fakes/FakePostOffice.java
Log:
Stomp to throw exception on inexistent destination = HORNETQ-799
Modified: branches/Branch_2_2_AS7/src/main/org/hornetq/core/postoffice/PostOffice.java
===================================================================
--- branches/Branch_2_2_AS7/src/main/org/hornetq/core/postoffice/PostOffice.java 2011-11-18 22:13:21 UTC (rev 11719)
+++ branches/Branch_2_2_AS7/src/main/org/hornetq/core/postoffice/PostOffice.java 2011-11-18 22:15:50 UTC (rev 11720)
@@ -42,7 +42,21 @@
void addBinding(Binding binding) throws Exception;
Binding removeBinding(SimpleString uniqueName) throws Exception;
+
+ /**
+ * It will lookup the Binding without creating an item on the Queue if non-existent
+ * @param address
+ * @return
+ * @throws Exception
+ */
+ Bindings lookupBindingsForAddress(SimpleString address) throws Exception;
+ /**
+ * Differently to lookupBindings, this will always create a new element on the Queue if non-existent
+ * @param address
+ * @return
+ * @throws Exception
+ */
Bindings getBindingsForAddress(SimpleString address) throws Exception;
Binding getBinding(SimpleString uniqueName);
Modified: branches/Branch_2_2_AS7/src/main/org/hornetq/core/postoffice/impl/PostOfficeImpl.java
===================================================================
--- branches/Branch_2_2_AS7/src/main/org/hornetq/core/postoffice/impl/PostOfficeImpl.java 2011-11-18 22:13:21 UTC (rev 11719)
+++ branches/Branch_2_2_AS7/src/main/org/hornetq/core/postoffice/impl/PostOfficeImpl.java 2011-11-18 22:15:50 UTC (rev 11720)
@@ -541,6 +541,12 @@
return bindings;
}
+
+ public Bindings lookupBindingsForAddress(final SimpleString address) throws Exception
+ {
+ return addressManager.getBindingsForRoutingAddress(address);
+ }
+
public Binding getBinding(final SimpleString name)
{
return addressManager.getBinding(name);
Modified: branches/Branch_2_2_AS7/src/main/org/hornetq/core/postoffice/impl/SimpleAddressManager.java
===================================================================
--- branches/Branch_2_2_AS7/src/main/org/hornetq/core/postoffice/impl/SimpleAddressManager.java 2011-11-18 22:13:21 UTC (rev 11719)
+++ branches/Branch_2_2_AS7/src/main/org/hornetq/core/postoffice/impl/SimpleAddressManager.java 2011-11-18 22:15:50 UTC (rev 11720)
@@ -35,8 +35,14 @@
{
private static final Logger log = Logger.getLogger(SimpleAddressManager.class);
+ /**
+ * HashMap<Address, Binding>
+ */
private final ConcurrentMap<SimpleString, Bindings> mappings = new ConcurrentHashMap<SimpleString, Bindings>();
+ /**
+ * HashMap<QueueName, Binding>
+ */
private final ConcurrentMap<SimpleString, Binding> nameMap = new ConcurrentHashMap<SimpleString, Binding>();
private final BindingsFactory bindingsFactory;
Modified: branches/Branch_2_2_AS7/src/main/org/hornetq/core/protocol/stomp/StompProtocolManager.java
===================================================================
--- branches/Branch_2_2_AS7/src/main/org/hornetq/core/protocol/stomp/StompProtocolManager.java 2011-11-18 22:13:21 UTC (rev 11719)
+++ branches/Branch_2_2_AS7/src/main/org/hornetq/core/protocol/stomp/StompProtocolManager.java 2011-11-18 22:15:50 UTC (rev 11720)
@@ -32,6 +32,7 @@
import org.hornetq.api.core.client.HornetQClient;
import org.hornetq.core.journal.IOAsyncTask;
import org.hornetq.core.logging.Logger;
+import org.hornetq.core.postoffice.Bindings;
import org.hornetq.core.server.HornetQServer;
import org.hornetq.core.server.ServerSession;
import org.hornetq.core.server.impl.ServerMessageImpl;
@@ -536,10 +537,14 @@
String destination = (String)headers.remove(Stomp.Headers.Send.DESTINATION);
String txID = (String)headers.remove(Stomp.Headers.TRANSACTION);
long timestamp = System.currentTimeMillis();
-
+
+ SimpleString address = SimpleString.toSimpleString(destination);
ServerMessageImpl message = new ServerMessageImpl(server.getStorageManager().generateUniqueID(), 512);
message.setTimestamp(timestamp);
- message.setAddress(SimpleString.toSimpleString(destination));
+ message.setAddress(address);
+
+ validateDestination(address);
+
StompUtils.copyStandardHeadersFromFrameToMessage(frame, message);
if (headers.containsKey(Stomp.Headers.CONTENT_LENGTH))
{
@@ -571,6 +576,20 @@
return null;
}
+ /**
+ * @param address
+ * @throws Exception
+ * @throws HornetQException
+ */
+ private void validateDestination(SimpleString address) throws Exception, HornetQException
+ {
+ Bindings binding = server.getPostOffice().lookupBindingsForAddress(address);
+ if (binding == null || binding.getBindings().size() == 0)
+ {
+ throw new HornetQException(HornetQException.ADDRESS_DOES_NOT_EXIST, "Address " + address + " has not been deployed");
+ }
+ }
+
private StompFrame onConnect(StompFrame frame, final StompConnection connection) throws Exception
{
Map<String, Object> headers = frame.getHeaders();
Modified: branches/Branch_2_2_AS7/src/main/org/hornetq/core/protocol/stomp/StompSession.java
===================================================================
--- branches/Branch_2_2_AS7/src/main/org/hornetq/core/protocol/stomp/StompSession.java 2011-11-18 22:13:21 UTC (rev 11719)
+++ branches/Branch_2_2_AS7/src/main/org/hornetq/core/protocol/stomp/StompSession.java 2011-11-18 22:15:50 UTC (rev 11720)
@@ -23,7 +23,6 @@
import org.hornetq.api.core.Message;
import org.hornetq.api.core.Pair;
import org.hornetq.api.core.SimpleString;
-import org.hornetq.api.core.TransportConfiguration;
import org.hornetq.core.logging.Logger;
import org.hornetq.core.message.impl.MessageImpl;
import org.hornetq.core.persistence.OperationContext;
Modified: branches/Branch_2_2_AS7/tests/src/org/hornetq/tests/integration/stomp/StompTest.java
===================================================================
--- branches/Branch_2_2_AS7/tests/src/org/hornetq/tests/integration/stomp/StompTest.java 2011-11-18 22:13:21 UTC (rev 11719)
+++ branches/Branch_2_2_AS7/tests/src/org/hornetq/tests/integration/stomp/StompTest.java 2011-11-18 22:15:50 UTC (rev 11720)
@@ -74,6 +74,23 @@
assertTrue(latch.await(60, TimeUnit.SECONDS));
}
+ public void testSendInvalidDestination() throws Exception
+ {
+ String frame = "CONNECT\n" + "login: brianm\n" + "passcode: wombats\n\n" + Stomp.NULL;
+ sendFrame(frame);
+ frame = receiveFrame(10000);
+
+ Assert.assertTrue(frame.startsWith("CONNECTED"));
+
+ frame = "SEND\n" + "destination:" + getQueuePrefix() + getQueueName()+"IdontExist" + "\n\n" + "Hello World" + Stomp.NULL;
+ sendFrame(frame);
+
+ String frameReceived = receiveFrame(1000);
+ System.out.println(frameReceived);
+
+ Assert.assertTrue(frameReceived.startsWith("ERROR"));
+ }
+
public void testConnect() throws Exception
{
@@ -124,7 +141,6 @@
{
}
}
-
public void testSendMessage() throws Exception
{
Modified: branches/Branch_2_2_AS7/tests/src/org/hornetq/tests/unit/core/server/impl/fakes/FakePostOffice.java
===================================================================
--- branches/Branch_2_2_AS7/tests/src/org/hornetq/tests/unit/core/server/impl/fakes/FakePostOffice.java 2011-11-18 22:13:21 UTC (rev 11719)
+++ branches/Branch_2_2_AS7/tests/src/org/hornetq/tests/unit/core/server/impl/fakes/FakePostOffice.java 2011-11-18 22:15:50 UTC (rev 11720)
@@ -85,6 +85,12 @@
return null;
}
+ public Bindings lookupBindingsForAddress(final SimpleString address) throws Exception
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
/* (non-Javadoc)
* @see org.hornetq.core.postoffice.PostOffice#getDuplicateIDCache(org.hornetq.utils.SimpleString)
*/
13 years, 1 month
JBoss hornetq SVN: r11719 - branches/Branch_2_2_AS7/src/main/org/hornetq/integration/jboss/recovery.
by do-not-reply@jboss.org
Author: clebert.suconic(a)jboss.com
Date: 2011-11-18 17:13:21 -0500 (Fri, 18 Nov 2011)
New Revision: 11719
Modified:
branches/Branch_2_2_AS7/src/main/org/hornetq/integration/jboss/recovery/AS7RecoveryRegistry.java
Log:
getXAResourceRecovery shouldn't NPE if module wasn't setup yet
Modified: branches/Branch_2_2_AS7/src/main/org/hornetq/integration/jboss/recovery/AS7RecoveryRegistry.java
===================================================================
--- branches/Branch_2_2_AS7/src/main/org/hornetq/integration/jboss/recovery/AS7RecoveryRegistry.java 2011-11-18 22:11:50 UTC (rev 11718)
+++ branches/Branch_2_2_AS7/src/main/org/hornetq/integration/jboss/recovery/AS7RecoveryRegistry.java 2011-11-18 22:13:21 UTC (rev 11719)
@@ -21,7 +21,6 @@
*/
package org.hornetq.integration.jboss.recovery;
-
import org.hornetq.jms.server.recovery.HornetQResourceRecovery;
import org.hornetq.jms.server.recovery.RecoveryRegistry;
import org.jboss.msc.service.ServiceName;
@@ -36,6 +35,7 @@
public class AS7RecoveryRegistry implements RecoveryRegistry
{
public static final ServiceName RECOVERY_MANAGER = ServiceName.JBOSS.append("txn").append("ArjunaRecoveryManager");
+
public static volatile ServiceContainer container;
private XAResourceRecoveryRegistry registry;
@@ -61,8 +61,15 @@
private static XAResourceRecoveryRegistry getXAResourceRecoveryRegistry()
{
- @SuppressWarnings("unchecked")
- ServiceController<XAResourceRecoveryRegistry> service = (ServiceController<XAResourceRecoveryRegistry>) container.getService(RECOVERY_MANAGER);
- return service == null ? null : service.getValue();
+ if (container == null)
+ {
+ return null;
+ }
+ else
+ {
+ @SuppressWarnings("unchecked")
+ ServiceController<XAResourceRecoveryRegistry> service = (ServiceController<XAResourceRecoveryRegistry>) container.getService(RECOVERY_MANAGER);
+ return service == null ? null : service.getValue();
+ }
}
}
13 years, 1 month
JBoss hornetq SVN: r11718 - branches/Branch_2_2_AS7/src/main/org/hornetq/ra/recovery.
by do-not-reply@jboss.org
Author: clebert.suconic(a)jboss.com
Date: 2011-11-18 17:11:50 -0500 (Fri, 18 Nov 2011)
New Revision: 11718
Modified:
branches/Branch_2_2_AS7/src/main/org/hornetq/ra/recovery/RecoveryManager.java
Log:
Using the ClassLoading util
Modified: branches/Branch_2_2_AS7/src/main/org/hornetq/ra/recovery/RecoveryManager.java
===================================================================
--- branches/Branch_2_2_AS7/src/main/org/hornetq/ra/recovery/RecoveryManager.java 2011-11-18 20:39:36 UTC (rev 11717)
+++ branches/Branch_2_2_AS7/src/main/org/hornetq/ra/recovery/RecoveryManager.java 2011-11-18 22:11:50 UTC (rev 11718)
@@ -29,6 +29,7 @@
import org.hornetq.jms.server.recovery.RecoveryRegistry;
import org.hornetq.jms.server.recovery.XARecoveryConfig;
import org.hornetq.ra.Util;
+import org.hornetq.utils.ClassloadingUtil;
import java.security.AccessController;
import java.security.PrivilegedAction;
@@ -173,30 +174,7 @@
{
public Object run()
{
- ClassLoader loader = getClass().getClassLoader();
- try
- {
- Class<?> clazz = loader.loadClass(className);
- return clazz.newInstance();
- }
- catch (Throwable t)
- {
- try
- {
- loader = Thread.currentThread().getContextClassLoader();
- if (loader != null)
- return loader.loadClass(className).newInstance();
- }
- catch (RuntimeException e)
- {
- throw e;
- }
- catch (Exception e)
- {
- }
-
- throw new IllegalArgumentException("Could not find class " + className);
- }
+ return ClassloadingUtil.newInstanceFromClassLoader(className);
}
});
}
13 years, 1 month
JBoss hornetq SVN: r11717 - 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: 2011-11-18 15:39:36 -0500 (Fri, 18 Nov 2011)
New Revision: 11717
Modified:
branches/Branch_2_2_EAP/src/main/org/hornetq/core/server/impl/ServerMessageImpl.java
Log:
https://issues.jboss.org/browse/HORNETQ-798 - avoiding synchronization on Queue while doing IO on paging
Modified: branches/Branch_2_2_EAP/src/main/org/hornetq/core/server/impl/ServerMessageImpl.java
===================================================================
--- branches/Branch_2_2_EAP/src/main/org/hornetq/core/server/impl/ServerMessageImpl.java 2011-11-18 20:05:39 UTC (rev 11716)
+++ branches/Branch_2_2_EAP/src/main/org/hornetq/core/server/impl/ServerMessageImpl.java 2011-11-18 20:39:36 UTC (rev 11717)
@@ -283,7 +283,7 @@
@Override
public String toString()
{
- return "ServerMessage[messageID=" + messageID + ",priority=" + this.getPriority() +
+ return "ServerMessage[messageID=" + messageID + ",priority=" + this.getPriority() + ", bodySize=" + this.getBodyBuffer().capacity() +
",expiration=" + (this.getExpiration() != 0 ? new java.util.Date(this.getExpiration()) : 0) +
", durable=" + durable + ", address=" + getAddress() + ",properties=" + properties.toString() + "]@" + System.identityHashCode(this);
}
13 years, 1 month
JBoss hornetq SVN: r11716 - branches/Branch_2_2_AS7/src/main/org/hornetq/core/server/impl.
by do-not-reply@jboss.org
Author: clebert.suconic(a)jboss.com
Date: 2011-11-18 15:05:39 -0500 (Fri, 18 Nov 2011)
New Revision: 11716
Modified:
branches/Branch_2_2_AS7/src/main/org/hornetq/core/server/impl/QueueImpl.java
Log:
Removing Queue synchronization while dealing with paging
Modified: branches/Branch_2_2_AS7/src/main/org/hornetq/core/server/impl/QueueImpl.java
===================================================================
--- branches/Branch_2_2_AS7/src/main/org/hornetq/core/server/impl/QueueImpl.java 2011-11-18 20:01:24 UTC (rev 11715)
+++ branches/Branch_2_2_AS7/src/main/org/hornetq/core/server/impl/QueueImpl.java 2011-11-18 20:05:39 UTC (rev 11716)
@@ -1612,166 +1612,168 @@
// This method will deliver as many messages as possible until all consumers are busy or there are no more matching
// or available messages
- private synchronized void deliver()
+ private void deliver()
{
- if (paused || consumerList.isEmpty())
+ synchronized (this)
{
- return;
- }
-
- if (log.isDebugEnabled())
- {
- log.debug(this + " doing deliver. messageReferences=" + messageReferences.size());
- }
+ if (paused || consumerList.isEmpty())
+ {
+ return;
+ }
- int busyCount = 0;
+ if (log.isDebugEnabled())
+ {
+ log.debug(this + " doing deliver. messageReferences=" + messageReferences.size());
+ }
- int nullRefCount = 0;
+ int busyCount = 0;
- int size = consumerList.size();
+ int nullRefCount = 0;
- int endPos = pos == size - 1 ? 0 : size - 1;
+ int size = consumerList.size();
- int numRefs = messageReferences.size();
+ int endPos = pos == size - 1 ? 0 : size - 1;
- int handled = 0;
-
- long timeout = System.currentTimeMillis() + DELIVERY_TIMEOUT;
+ int numRefs = messageReferences.size();
- while (handled < numRefs)
- {
- if (handled == MAX_DELIVERIES_IN_LOOP)
- {
- // Schedule another one - we do this to prevent a single thread getting caught up in this loop for too long
+ int handled = 0;
- deliverAsync();
+ long timeout = System.currentTimeMillis() + DELIVERY_TIMEOUT;
- return;
- }
-
- if (System.currentTimeMillis() > timeout)
+ while (handled < numRefs)
{
- if (isTrace)
+ if (handled == MAX_DELIVERIES_IN_LOOP)
{
- log.trace("delivery has been running for too long. Scheduling another delivery task now");
- }
-
- deliverAsync();
-
- return;
- }
-
+ // Schedule another one - we do this to prevent a single thread getting caught up in this loop for too
+ // long
- ConsumerHolder holder = consumerList.get(pos);
+ deliverAsync();
- Consumer consumer = holder.consumer;
+ return;
+ }
- if (holder.iter == null)
- {
- holder.iter = messageReferences.iterator();
- }
-
- MessageReference ref;
-
- if (holder.iter.hasNext())
- {
- ref = holder.iter.next();
- }
- else
- {
- ref = null;
- }
-
-
- if (ref == null)
- {
- nullRefCount++;
- }
- else
- {
- if (checkExpired(ref))
+ if (System.currentTimeMillis() > timeout)
{
if (isTrace)
{
- log.trace("Reference " + ref + " being expired");
+ log.trace("delivery has been running for too long. Scheduling another delivery task now");
}
- holder.iter.remove();
- refRemoved(ref);
-
- handled++;
+ deliverAsync();
- continue;
+ return;
}
- Consumer groupConsumer = null;
-
- if (isTrace)
+ ConsumerHolder holder = consumerList.get(pos);
+
+ Consumer consumer = holder.consumer;
+
+ if (holder.iter == null)
{
- log.trace("Queue " + this.getName() + " is delivering reference " + ref);
+ holder.iter = messageReferences.iterator();
}
- // If a group id is set, then this overrides the consumer chosen round-robin
+ MessageReference ref;
- SimpleString groupID = ref.getMessage().getSimpleStringProperty(Message.HDR_GROUP_ID);
+ if (holder.iter.hasNext())
+ {
+ ref = holder.iter.next();
+ }
+ else
+ {
+ ref = null;
+ }
- if (groupID != null)
+ if (ref == null)
{
- groupConsumer = groups.get(groupID);
+ nullRefCount++;
+ }
+ else
+ {
+ if (checkExpired(ref))
+ {
+ if (isTrace)
+ {
+ log.trace("Reference " + ref + " being expired");
+ }
+ holder.iter.remove();
- if (groupConsumer != null)
+ refRemoved(ref);
+
+ handled++;
+
+ continue;
+ }
+
+ Consumer groupConsumer = null;
+
+ if (isTrace)
{
- consumer = groupConsumer;
+ log.trace("Queue " + this.getName() + " is delivering reference " + ref);
}
- }
- HandleStatus status = handle(ref, consumer);
+ // If a group id is set, then this overrides the consumer chosen round-robin
- if (status == HandleStatus.HANDLED)
- {
- holder.iter.remove();
+ SimpleString groupID = ref.getMessage().getSimpleStringProperty(Message.HDR_GROUP_ID);
- refRemoved(ref);
+ if (groupID != null)
+ {
+ groupConsumer = groups.get(groupID);
- if (groupID != null && groupConsumer == null)
+ if (groupConsumer != null)
+ {
+ consumer = groupConsumer;
+ }
+ }
+
+ HandleStatus status = handle(ref, consumer);
+
+ if (status == HandleStatus.HANDLED)
{
- groups.put(groupID, consumer);
+ holder.iter.remove();
+
+ refRemoved(ref);
+
+ if (groupID != null && groupConsumer == null)
+ {
+ groups.put(groupID, consumer);
+ }
+
+ handled++;
}
+ else if (status == HandleStatus.BUSY)
+ {
+ holder.iter.repeat();
- handled++;
+ busyCount++;
+ }
+ else if (status == HandleStatus.NO_MATCH)
+ {
+ }
}
- else if (status == HandleStatus.BUSY)
- {
- holder.iter.repeat();
- busyCount++;
- }
- else if (status == HandleStatus.NO_MATCH)
+ if (pos == endPos)
{
- }
- }
+ // Round robin'd all
- if (pos == endPos)
- {
- // Round robin'd all
-
- if (nullRefCount + busyCount == size)
- {
- if (log.isDebugEnabled())
+ if (nullRefCount + busyCount == size)
{
- log.debug(this + "::All the consumers were busy, giving up now");
+ if (log.isDebugEnabled())
+ {
+ log.debug(this + "::All the consumers were busy, giving up now");
+ }
+ break;
}
- break;
+
+ nullRefCount = busyCount = 0;
}
- nullRefCount = busyCount = 0;
- }
+ pos++;
- pos++;
-
- if (pos == size)
- {
- pos = 0;
+ if (pos == size)
+ {
+ pos = 0;
+ }
}
}
@@ -1817,7 +1819,7 @@
}
}
- private synchronized void depage()
+ private void depage()
{
depagePending = false;
13 years, 1 month
JBoss hornetq SVN: r11715 - in branches/Branch_2_2_AS7: src/main/org/hornetq/core/client/impl and 6 other directories.
by do-not-reply@jboss.org
Author: clebert.suconic(a)jboss.com
Date: 2011-11-18 15:01:24 -0500 (Fri, 18 Nov 2011)
New Revision: 11715
Added:
branches/Branch_2_2_AS7/mac-build.sh
branches/Branch_2_2_AS7/src/main/org/hornetq/utils/ClassloadingUtil.java
Modified:
branches/Branch_2_2_AS7/src/main/org/hornetq/core/client/impl/ClientSessionFactoryImpl.java
branches/Branch_2_2_AS7/src/main/org/hornetq/core/logging/Logger.java
branches/Branch_2_2_AS7/src/main/org/hornetq/core/remoting/impl/ssl/SSLSupport.java
branches/Branch_2_2_AS7/src/main/org/hornetq/core/remoting/server/impl/RemotingServiceImpl.java
branches/Branch_2_2_AS7/src/main/org/hornetq/core/server/impl/HornetQServerImpl.java
branches/Branch_2_2_AS7/src/main/org/hornetq/jms/bridge/impl/JMSBridgeImpl.java
branches/Branch_2_2_AS7/src/main/org/hornetq/utils/XMLUtil.java
Log:
Fixing classLoading
Added: branches/Branch_2_2_AS7/mac-build.sh
===================================================================
--- branches/Branch_2_2_AS7/mac-build.sh (rev 0)
+++ branches/Branch_2_2_AS7/mac-build.sh 2011-11-18 20:01:24 UTC (rev 11715)
@@ -0,0 +1,2 @@
+#you need to define this variable on mac
+./build.sh -Djdk5.home=/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/ "$@"
Property changes on: branches/Branch_2_2_AS7/mac-build.sh
___________________________________________________________________
Added: svn:executable
+ *
Modified: branches/Branch_2_2_AS7/src/main/org/hornetq/core/client/impl/ClientSessionFactoryImpl.java
===================================================================
--- branches/Branch_2_2_AS7/src/main/org/hornetq/core/client/impl/ClientSessionFactoryImpl.java 2011-11-18 17:44:13 UTC (rev 11714)
+++ branches/Branch_2_2_AS7/src/main/org/hornetq/core/client/impl/ClientSessionFactoryImpl.java 2011-11-18 20:01:24 UTC (rev 11715)
@@ -59,6 +59,7 @@
import org.hornetq.spi.core.remoting.ConnectionLifeCycleListener;
import org.hornetq.spi.core.remoting.Connector;
import org.hornetq.spi.core.remoting.ConnectorFactory;
+import org.hornetq.utils.ClassloadingUtil;
import org.hornetq.utils.ConcurrentHashSet;
import org.hornetq.utils.ConfigurationHelper;
import org.hornetq.utils.ExecutorFactory;
@@ -1351,18 +1352,7 @@
{
public ConnectorFactory run()
{
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
- try
- {
- Class<?> clazz = loader.loadClass(connectorFactoryClassName);
- return (ConnectorFactory)clazz.newInstance();
- }
- catch (Exception e)
- {
- throw new IllegalArgumentException("Error instantiating connector factory \"" + connectorFactoryClassName +
- "\"",
- e);
- }
+ return (ConnectorFactory) ClassloadingUtil.newInstanceFromClassLoader(connectorFactoryClassName);
}
});
}
Modified: branches/Branch_2_2_AS7/src/main/org/hornetq/core/logging/Logger.java
===================================================================
--- branches/Branch_2_2_AS7/src/main/org/hornetq/core/logging/Logger.java 2011-11-18 17:44:13 UTC (rev 11714)
+++ branches/Branch_2_2_AS7/src/main/org/hornetq/core/logging/Logger.java 2011-11-18 20:01:24 UTC (rev 11715)
@@ -21,6 +21,7 @@
import org.hornetq.core.logging.impl.JULLogDelegateFactory;
import org.hornetq.spi.core.logging.LogDelegate;
import org.hornetq.spi.core.logging.LogDelegateFactory;
+import org.hornetq.utils.ClassloadingUtil;
/**
*
@@ -202,46 +203,16 @@
delegate.trace(message, t);
}
- /** This seems duplicate code all over the place, but for security reasons we can't let something like this to be open in a
- * utility class, as it would be a door to load anything you like in a safe VM.
- * For that reason any class trying to do a privileged block should do with the AccessController directly.
- * @param className
- * @return
- */
+
private static Object safeInitNewInstance(final String className)
{
return AccessController.doPrivileged(new PrivilegedAction<Object>()
{
public Object run()
{
- ClassLoader loader = this.getClass().getClassLoader();
- try
- {
- Class<?> clazz = loader.loadClass(className);
- return clazz.newInstance();
- }
- catch (Throwable t)
- {
- try
- {
- loader = Thread.currentThread().getContextClassLoader();
- if (loader != null)
- return loader.loadClass(className).newInstance();
- }
- catch (RuntimeException e)
- {
- throw e;
- }
- catch (Exception e)
- {
- }
-
- throw new IllegalArgumentException("Could not find class " + className);
- }
+ return ClassloadingUtil.newInstanceFromClassLoader(className);
}
});
}
-
-
}
Modified: branches/Branch_2_2_AS7/src/main/org/hornetq/core/remoting/impl/ssl/SSLSupport.java
===================================================================
--- branches/Branch_2_2_AS7/src/main/org/hornetq/core/remoting/impl/ssl/SSLSupport.java 2011-11-18 17:44:13 UTC (rev 11714)
+++ branches/Branch_2_2_AS7/src/main/org/hornetq/core/remoting/impl/ssl/SSLSupport.java 2011-11-18 20:01:24 UTC (rev 11715)
@@ -32,6 +32,8 @@
import javax.net.ssl.TrustManagerFactory;
import javax.net.ssl.X509TrustManager;
+import org.hornetq.utils.ClassloadingUtil;
+
/**
* @author <a href="mailto:jmesnil@redhat.com">Jeff Mesnil</a>
*
@@ -197,7 +199,7 @@
throw new Exception("Failed to find a store at " + storePath);
}
-
+
/** This seems duplicate code all over the place, but for security reasons we can't let something like this to be open in a
* utility class, as it would be a door to load anything you like in a safe VM.
* For that reason any class trying to do a privileged block should do with the AccessController directly.
@@ -208,26 +210,7 @@
{
public URL run()
{
- ClassLoader loader = getClass().getClassLoader();
- try
- {
- URL resource = loader.getResource(resourceName);
- if (resource != null)
- return resource;
- }
- catch (Throwable t)
- {
- }
-
- loader = Thread.currentThread().getContextClassLoader();
- if (loader == null)
- return null;
-
- URL resource = loader.getResource(resourceName);
- if (resource != null)
- return resource;
-
- return null;
+ return ClassloadingUtil.findResource(resourceName);
}
});
}
Modified: branches/Branch_2_2_AS7/src/main/org/hornetq/core/remoting/server/impl/RemotingServiceImpl.java
===================================================================
--- branches/Branch_2_2_AS7/src/main/org/hornetq/core/remoting/server/impl/RemotingServiceImpl.java 2011-11-18 17:44:13 UTC (rev 11714)
+++ branches/Branch_2_2_AS7/src/main/org/hornetq/core/remoting/server/impl/RemotingServiceImpl.java 2011-11-18 20:01:24 UTC (rev 11715)
@@ -52,6 +52,7 @@
import org.hornetq.spi.core.remoting.BufferHandler;
import org.hornetq.spi.core.remoting.Connection;
import org.hornetq.spi.core.remoting.ConnectionLifeCycleListener;
+import org.hornetq.utils.ClassloadingUtil;
import org.hornetq.utils.ConfigurationHelper;
import org.hornetq.utils.HornetQThreadFactory;
@@ -640,44 +641,15 @@
}
}
-
- /** This seems duplicate code all over the place, but for security reasons we can't let something like this to be open in a
- * utility class, as it would be a door to load anything you like in a safe VM.
- * For that reason any class trying to do a privileged block should do with the AccessController directly.
- */
private static Object safeInitNewInstance(final String className)
{
return AccessController.doPrivileged(new PrivilegedAction<Object>()
{
public Object run()
{
- ClassLoader loader = getClass().getClassLoader();
- try
- {
- Class<?> clazz = loader.loadClass(className);
- return clazz.newInstance();
- }
- catch (Throwable t)
- {
- try
- {
- loader = Thread.currentThread().getContextClassLoader();
- if (loader != null)
- return loader.loadClass(className).newInstance();
- }
- catch (RuntimeException e)
- {
- throw e;
- }
- catch (Exception e)
- {
- }
-
- throw new IllegalArgumentException("Could not find class " + className);
- }
+ return ClassloadingUtil.newInstanceFromClassLoader(className);
}
});
}
-
}
\ No newline at end of file
Modified: branches/Branch_2_2_AS7/src/main/org/hornetq/core/server/impl/HornetQServerImpl.java
===================================================================
--- branches/Branch_2_2_AS7/src/main/org/hornetq/core/server/impl/HornetQServerImpl.java 2011-11-18 17:44:13 UTC (rev 11714)
+++ branches/Branch_2_2_AS7/src/main/org/hornetq/core/server/impl/HornetQServerImpl.java 2011-11-18 20:01:24 UTC (rev 11715)
@@ -121,6 +121,7 @@
import org.hornetq.spi.core.protocol.RemotingConnection;
import org.hornetq.spi.core.protocol.SessionCallback;
import org.hornetq.spi.core.security.HornetQSecurityManager;
+import org.hornetq.utils.ClassloadingUtil;
import org.hornetq.utils.ExecutorFactory;
import org.hornetq.utils.HornetQThreadFactory;
import org.hornetq.utils.OrderedExecutorFactory;
@@ -2109,30 +2110,7 @@
{
public Object run()
{
- ClassLoader loader = getClass().getClassLoader();
- try
- {
- Class<?> clazz = loader.loadClass(className);
- return clazz.newInstance();
- }
- catch (Throwable t)
- {
- try
- {
- loader = Thread.currentThread().getContextClassLoader();
- if (loader != null)
- return loader.loadClass(className).newInstance();
- }
- catch (RuntimeException e)
- {
- throw e;
- }
- catch (Exception e)
- {
- }
-
- throw new IllegalArgumentException("Could not find class " + className);
- }
+ return ClassloadingUtil.newInstanceFromClassLoader(className);
}
});
}
Modified: branches/Branch_2_2_AS7/src/main/org/hornetq/jms/bridge/impl/JMSBridgeImpl.java
===================================================================
--- branches/Branch_2_2_AS7/src/main/org/hornetq/jms/bridge/impl/JMSBridgeImpl.java 2011-11-18 17:44:13 UTC (rev 11714)
+++ branches/Branch_2_2_AS7/src/main/org/hornetq/jms/bridge/impl/JMSBridgeImpl.java 2011-11-18 20:01:24 UTC (rev 11715)
@@ -56,6 +56,7 @@
import org.hornetq.jms.bridge.QualityOfServiceMode;
import org.hornetq.jms.client.HornetQMessage;
import org.hornetq.jms.client.HornetQSession;
+import org.hornetq.utils.ClassloadingUtil;
/**
*
@@ -2003,6 +2004,7 @@
}
}
}
+
/** This seems duplicate code all over the place, but for security reasons we can't let something like this to be open in a
* utility class, as it would be a door to load anything you like in a safe VM.
@@ -2014,33 +2016,9 @@
{
public Object run()
{
- ClassLoader loader = getClass().getClassLoader();
- try
- {
- Class<?> clazz = loader.loadClass(className);
- return clazz.newInstance();
- }
- catch (Throwable t)
- {
- try
- {
- loader = Thread.currentThread().getContextClassLoader();
- if (loader != null)
- return loader.loadClass(className).newInstance();
- }
- catch (RuntimeException e)
- {
- throw e;
- }
- catch (Exception e)
- {
- }
-
- throw new IllegalArgumentException("Could not find class " + className);
- }
+ return ClassloadingUtil.newInstanceFromClassLoader(className);
}
});
}
-
}
Copied: branches/Branch_2_2_AS7/src/main/org/hornetq/utils/ClassloadingUtil.java (from rev 11506, branches/Branch_2_2_AS7/src/main/org/hornetq/utils/ClassloadingUtil.java)
===================================================================
--- branches/Branch_2_2_AS7/src/main/org/hornetq/utils/ClassloadingUtil.java (rev 0)
+++ branches/Branch_2_2_AS7/src/main/org/hornetq/utils/ClassloadingUtil.java 2011-11-18 20:01:24 UTC (rev 11715)
@@ -0,0 +1,68 @@
+package org.hornetq.utils;
+
+import java.net.URL;
+
+/**
+* This class will be used to perform generic class-loader operations,
+* such as load a class first using TCCL, and then the classLoader used by HornetQ (ClassloadingUtil.getClass().getClassLoader()).
+*
+* Is't required to use a Security Block on any calls to this class.
+*
+* @author <a href="mailto:hgao@redhat.com">Howard Gao</a>
+*/
+
+public class ClassloadingUtil
+{
+ public static Object newInstanceFromClassLoader(final String className)
+ {
+ ClassLoader loader = ClassloadingUtil.class.getClassLoader();
+ try
+ {
+ Class<?> clazz = loader.loadClass(className);
+ return clazz.newInstance();
+ }
+ catch (Throwable t)
+ {
+ try
+ {
+ loader = Thread.currentThread().getContextClassLoader();
+ if (loader != null)
+ return loader.loadClass(className).newInstance();
+ }
+ catch (RuntimeException e)
+ {
+ throw e;
+ }
+ catch (Exception e)
+ {
+ }
+
+ throw new IllegalArgumentException("Could not find class " + className);
+ }
+ }
+
+ public static URL findResource(final String resourceName)
+ {
+ ClassLoader loader = ClassloadingUtil.class.getClassLoader();
+ try
+ {
+ URL resource = loader.getResource(resourceName);
+ if (resource != null)
+ return resource;
+ }
+ catch (Throwable t)
+ {
+ }
+
+ loader = Thread.currentThread().getContextClassLoader();
+ if (loader == null)
+ return null;
+
+ URL resource = loader.getResource(resourceName);
+ if (resource != null)
+ return resource;
+
+ return null;
+ }
+
+}
Modified: branches/Branch_2_2_AS7/src/main/org/hornetq/utils/XMLUtil.java
===================================================================
--- branches/Branch_2_2_AS7/src/main/org/hornetq/utils/XMLUtil.java 2011-11-18 17:44:13 UTC (rev 11714)
+++ branches/Branch_2_2_AS7/src/main/org/hornetq/utils/XMLUtil.java 2011-11-18 20:01:24 UTC (rev 11715)
@@ -18,8 +18,6 @@
import java.io.StringReader;
import java.lang.reflect.Method;
import java.net.URL;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
import java.util.ArrayList;
import java.util.List;
@@ -483,7 +481,7 @@
{
SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
- Schema schema = factory.newSchema(findResource(schemaFile));
+ Schema schema = factory.newSchema(ClassloadingUtil.findResource(schemaFile));
Validator validator = schema.newValidator();
// validate the DOM tree
@@ -531,40 +529,6 @@
return nodes;
}
- /** This seems duplicate code all over the place, but for security reasons we can't let something like this to be open in a
- * utility class, as it would be a door to load anything you like in a safe VM.
- * For that reason any class trying to do a privileged block should do with the AccessController directly.
- */
- private static URL findResource(final String resourceName)
- {
- return AccessController.doPrivileged(new PrivilegedAction<URL>()
- {
- public URL run()
- {
- ClassLoader loader = getClass().getClassLoader();
- try
- {
- URL resource = loader.getResource(resourceName);
- if (resource != null)
- return resource;
- }
- catch (Throwable t)
- {
- }
-
- loader = Thread.currentThread().getContextClassLoader();
- if (loader == null)
- return null;
-
- URL resource = loader.getResource(resourceName);
- if (resource != null)
- return resource;
-
- return null;
- }
- });
- }
-
// Inner classes --------------------------------------------------------------------------------
}
13 years, 1 month
JBoss hornetq SVN: r11714 - branches/Branch_2_2_AS7/src/main/org/hornetq/core/server/impl.
by do-not-reply@jboss.org
Author: clebert.suconic(a)jboss.com
Date: 2011-11-18 12:44:13 -0500 (Fri, 18 Nov 2011)
New Revision: 11714
Modified:
branches/Branch_2_2_AS7/src/main/org/hornetq/core/server/impl/ScheduledDeliveryHandlerImpl.java
Log:
https://issues.jboss.org/browse/JBPAPP-7521 - NPE on filter==null passed on destroy queue
Modified: branches/Branch_2_2_AS7/src/main/org/hornetq/core/server/impl/ScheduledDeliveryHandlerImpl.java
===================================================================
--- branches/Branch_2_2_AS7/src/main/org/hornetq/core/server/impl/ScheduledDeliveryHandlerImpl.java 2011-11-18 17:43:25 UTC (rev 11713)
+++ branches/Branch_2_2_AS7/src/main/org/hornetq/core/server/impl/ScheduledDeliveryHandlerImpl.java 2011-11-18 17:44:13 UTC (rev 11714)
@@ -115,7 +115,7 @@
while (iter.hasNext())
{
MessageReference ref = iter.next();
- if (filter.match(ref.getMessage()))
+ if (filter == null || filter.match(ref.getMessage()))
{
iter.remove();
refs.add(ref);
13 years, 1 month