You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by rg...@apache.org on 2007/04/19 18:24:45 UTC
svn commit: r530474 [5/8] - in /incubator/qpid/trunk/qpid: ./
java/broker/bin/ java/broker/distribution/src/main/assembly/
java/broker/etc/ java/broker/lib/
java/broker/src/main/java/org/apache/qpid/server/
java/broker/src/main/java/org/apache/qpid/ser...
Modified: incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolHandler.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolHandler.java?view=diff&rev=530474&r1=530473&r2=530474
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolHandler.java (original)
+++ incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolHandler.java Thu Apr 19 09:24:30 2007
@@ -34,6 +34,7 @@
import org.apache.qpid.AMQDisconnectedException;
import org.apache.qpid.AMQException;
import org.apache.qpid.AMQTimeoutException;
+import org.apache.qpid.AMQChannelClosedException;
import org.apache.qpid.client.AMQConnection;
import org.apache.qpid.client.AMQSession;
import org.apache.qpid.client.SSLConfiguration;
@@ -248,6 +249,12 @@
sessionClosed(session);
}
+
+ //FIXME Need to correctly handle other exceptions. Things like ...
+// if (cause instanceof AMQChannelClosedException)
+ // which will cause the JMSSession to end due to a channel close and so that Session needs
+ // to be removed from the map so we can correctly still call close without an exception when trying to close
+ // the server closed session. See also CloseChannelMethodHandler as the sessionClose is never called on exception
}
// we reach this point if failover was attempted and failed therefore we need to let the calling app
// know since we cannot recover the situation
@@ -508,11 +515,6 @@
public void closeSession(AMQSession session) throws AMQException
{
_protocolSession.closeSession(session);
- }
-
- public void closeConnection() throws AMQException
- {
- closeConnection(-1);
}
public void closeConnection(long timeout) throws AMQException
Modified: incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/security/CallbackHandlerRegistry.properties
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/security/CallbackHandlerRegistry.properties?view=diff&rev=530474&r1=530473&r2=530474
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/security/CallbackHandlerRegistry.properties (original)
+++ incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/security/CallbackHandlerRegistry.properties Thu Apr 19 09:24:30 2007
@@ -16,5 +16,6 @@
# specific language governing permissions and limitations
# under the License.
#
+CallbackHandler.CRAM-MD5-HASHED=org.apache.qpid.client.security.UsernameHashedPasswordCallbackHandler
CallbackHandler.CRAM-MD5=org.apache.qpid.client.security.UsernamePasswordCallbackHandler
CallbackHandler.PLAIN=org.apache.qpid.client.security.UsernamePasswordCallbackHandler
Modified: incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/security/DynamicSaslRegistrar.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/security/DynamicSaslRegistrar.java?view=diff&rev=530474&r1=530473&r2=530474
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/security/DynamicSaslRegistrar.java (original)
+++ incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/security/DynamicSaslRegistrar.java Thu Apr 19 09:24:30 2007
@@ -20,10 +20,6 @@
*/
package org.apache.qpid.client.security;
-import java.io.BufferedInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.security.Security;
@@ -34,6 +30,7 @@
import javax.security.sasl.SaslClientFactory;
+
import org.apache.log4j.Logger;
import org.apache.qpid.util.FileUtils;
@@ -50,14 +47,11 @@
* mechanism=fully.qualified.class.name
* </pre>
*
- * <p/>Where mechanism is an IANA-registered mechanism name and the fully qualified class name refers to a
- * class that implements javax.security.sasl.SaslClientFactory and provides the specified mechanism.
+ * <p/>Where mechanism is an IANA-registered mechanism name and the fully qualified class name refers to a class that
+ * implements javax.security.sasl.SaslClientFactory and provides the specified mechanism.
*
- * <p><table id="crc"><caption>CRC Card</caption>
- * <tr><th> Responsibilities <th> Collaborations
- * <tr><td> Parse SASL mechanism properties.
- * <tr><td> Create and register security provider for SASL mechanisms.
- * </table>
+ * <p><table id="crc"><caption>CRC Card</caption> <tr><th> Responsibilities <th> Collaborations <tr><td> Parse SASL
+ * mechanism properties. <tr><td> Create and register security provider for SASL mechanisms. </table>
*/
public class DynamicSaslRegistrar
{
@@ -69,10 +63,7 @@
/** The default name of the SASL properties file resource. */
public static final String DEFAULT_RESOURCE_NAME = "org/apache/qpid/client/security/DynamicSaslRegistrar.properties";
- /**
- * Reads the properties file, and creates a dynamic security provider to register the SASL implementations
- * with.
- */
+ /** Reads the properties file, and creates a dynamic security provider to register the SASL implementations with. */
public static void registerSaslProviders()
{
_logger.debug("public static void registerSaslProviders(): called");
@@ -80,8 +71,8 @@
// Open the SASL properties file, using the default name is one is not specified.
String filename = System.getProperty(FILE_PROPERTY);
InputStream is =
- FileUtils.openFileOrDefaultResource(filename, DEFAULT_RESOURCE_NAME,
- DynamicSaslRegistrar.class.getClassLoader());
+ FileUtils.openFileOrDefaultResource(filename, DEFAULT_RESOURCE_NAME,
+ DynamicSaslRegistrar.class.getClassLoader());
try
{
@@ -94,7 +85,7 @@
if (factories.size() > 0)
{
- Security.addProvider(new JCAProvider(factories));
+ Security.insertProviderAt(new JCAProvider(factories), 0);
_logger.debug("Dynamic SASL provider added as a security provider");
}
}
@@ -170,15 +161,15 @@
* @return A map from SASL mechanism names to implementing client factory classes.
*
* @todo Why tree map here? Do really want mechanisms in alphabetical order? Seems more likely that the declared
- * order of the mechanisms is intended to be preserved, so that they are registered in the declared order
- * of preference. Consider LinkedHashMap instead.
+ * order of the mechanisms is intended to be preserved, so that they are registered in the declared order of
+ * preference. Consider LinkedHashMap instead.
*/
private static Map<String, Class<? extends SaslClientFactory>> parseProperties(Properties props)
{
Enumeration e = props.propertyNames();
TreeMap<String, Class<? extends SaslClientFactory>> factoriesToRegister =
- new TreeMap<String, Class<? extends SaslClientFactory>>();
+ new TreeMap<String, Class<? extends SaslClientFactory>>();
while (e.hasMoreElements())
{
Modified: incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/security/DynamicSaslRegistrar.properties
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/security/DynamicSaslRegistrar.properties?view=diff&rev=530474&r1=530473&r2=530474
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/security/DynamicSaslRegistrar.properties (original)
+++ incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/security/DynamicSaslRegistrar.properties Thu Apr 19 09:24:30 2007
@@ -17,3 +17,4 @@
# under the License.
#
AMQPLAIN=org.apache.qpid.client.security.amqplain.AmqPlainSaslClientFactory
+CRAM-MD5-HASHED=org.apache.qpid.client.security.crammd5hashed.CRAMMD5HashedSaslClientFactory
Modified: incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/security/JCAProvider.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/security/JCAProvider.java?view=diff&rev=530474&r1=530473&r2=530474
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/security/JCAProvider.java (original)
+++ incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/security/JCAProvider.java Thu Apr 19 09:24:30 2007
@@ -52,7 +52,7 @@
super("AMQSASLProvider", 1.0, "A JCA provider that registers all "
+ "AMQ SASL providers that want to be registered");
register(providerMap);
- Security.addProvider(this);
+// Security.addProvider(this);
}
/**
Copied: incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/security/UsernameHashedPasswordCallbackHandler.java (from r526122, incubator/qpid/branches/M2/java/client/src/main/java/org/apache/qpid/client/security/UsernameHashedPasswordCallbackHandler.java)
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/security/UsernameHashedPasswordCallbackHandler.java?view=diff&rev=530474&p1=incubator/qpid/branches/M2/java/client/src/main/java/org/apache/qpid/client/security/UsernameHashedPasswordCallbackHandler.java&r1=526122&p2=incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/security/UsernameHashedPasswordCallbackHandler.java&r2=530474
==============================================================================
--- incubator/qpid/branches/M2/java/client/src/main/java/org/apache/qpid/client/security/UsernameHashedPasswordCallbackHandler.java (original)
+++ incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/security/UsernameHashedPasswordCallbackHandler.java Thu Apr 19 09:24:30 2007
@@ -31,15 +31,16 @@
import javax.security.auth.callback.UnsupportedCallbackException;
import javax.security.sasl.RealmCallback;
-import org.apache.qpid.client.protocol.AMQProtocolSession;
-import org.apache.log4j.Logger;
import com.sun.crypto.provider.HmacMD5;
+import org.apache.log4j.Logger;
+
+import org.apache.qpid.client.protocol.AMQProtocolSession;
+
public class UsernameHashedPasswordCallbackHandler implements AMQCallbackHandler
{
private static final Logger _logger = Logger.getLogger(UsernameHashedPasswordCallbackHandler.class);
-
private AMQProtocolSession _protocolSession;
public void initialise(AMQProtocolSession protocolSession)
@@ -58,14 +59,15 @@
}
else if (cb instanceof PasswordCallback)
{
-
try
{
((PasswordCallback) cb).setPassword(getHash(_protocolSession.getPassword()));
}
- catch (Exception e)
+ catch (NoSuchAlgorithmException e)
{
- throw new UnsupportedCallbackException(cb);
+ UnsupportedCallbackException uce = new UnsupportedCallbackException(cb);
+ uce.initCause(e);
+ throw uce;
}
}
else
@@ -89,13 +91,12 @@
byte[] digest = md.digest();
- char[] hash = new char[digest.length + 1];
+ char[] hash = new char[digest.length ];
int index = 0;
for (byte b : digest)
- {
- index++;
- hash[index] = (char) b;
+ {
+ hash[index++] = (char) b;
}
return hash;
Modified: incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/transport/AMQNoTransportForProtocolException.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/transport/AMQNoTransportForProtocolException.java?view=diff&rev=530474&r1=530473&r2=530474
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/transport/AMQNoTransportForProtocolException.java (original)
+++ incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/transport/AMQNoTransportForProtocolException.java Thu Apr 19 09:24:30 2007
@@ -7,9 +7,9 @@
* 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
@@ -33,7 +33,7 @@
public AMQNoTransportForProtocolException(BrokerDetails details, String message)
{
- super(message);
+ super(null, message, null);
_details = details;
}
Modified: incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/transport/AMQTransportConnectionException.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/transport/AMQTransportConnectionException.java?view=diff&rev=530474&r1=530473&r2=530474
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/transport/AMQTransportConnectionException.java (original)
+++ incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/transport/AMQTransportConnectionException.java Thu Apr 19 09:24:30 2007
@@ -7,9 +7,9 @@
* 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
@@ -21,12 +21,12 @@
package org.apache.qpid.client.transport;
import org.apache.qpid.AMQException;
+import org.apache.qpid.protocol.AMQConstant;
public class AMQTransportConnectionException extends AMQException
{
- public AMQTransportConnectionException(String message)
+ public AMQTransportConnectionException(AMQConstant errorCode, String message, Throwable cause)
{
- super(message);
-
+ super(errorCode, message, cause);
}
}
Modified: incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/transport/TransportConnection.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/transport/TransportConnection.java?view=diff&rev=530474&r1=530473&r2=530474
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/transport/TransportConnection.java (original)
+++ incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/transport/TransportConnection.java Thu Apr 19 09:24:30 2007
@@ -7,9 +7,9 @@
* 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
@@ -26,12 +26,14 @@
import java.util.Map;
import org.apache.log4j.Logger;
+
import org.apache.mina.common.IoConnector;
import org.apache.mina.common.IoHandlerAdapter;
import org.apache.mina.common.IoServiceConfig;
import org.apache.mina.transport.socket.nio.SocketConnector;
import org.apache.mina.transport.vmpipe.VmPipeAcceptor;
import org.apache.mina.transport.vmpipe.VmPipeAddress;
+
import org.apache.qpid.client.AMQBrokerDetails;
import org.apache.qpid.client.vmbroker.AMQVMBrokerCreationException;
import org.apache.qpid.jms.BrokerDetails;
@@ -64,13 +66,11 @@
int transport = getTransport(details.getTransport());
if (transport == -1)
-
{
throw new AMQNoTransportForProtocolException(details);
}
if (transport == _currentInstance)
-
{
if (transport == VM)
{
@@ -88,40 +88,42 @@
_currentInstance = transport;
switch (transport)
-
{
- case TCP:
- _instance = new SocketTransportConnection(new SocketTransportConnection.SocketConnectorFactory()
- {
- public IoConnector newSocketConnector()
+
+ case TCP:
+ _instance = new SocketTransportConnection(new SocketTransportConnection.SocketConnectorFactory()
{
- SocketConnector result;
- //FIXME - this needs to be sorted to use the new Mina MultiThread SA.
- if (Boolean.getBoolean("qpidnio"))
- {
- _logger.fatal("Using Qpid NIO - sysproperty 'qpidnio' is set.");
-// result = new org.apache.qpid.nio.SocketConnector(); // non-blocking connector
- }
-// else
+ public IoConnector newSocketConnector()
{
- _logger.info("Using Mina NIO");
- result = new SocketConnector(); // non-blocking connector
- }
+ SocketConnector result;
+ // FIXME - this needs to be sorted to use the new Mina MultiThread SA.
+ if (Boolean.getBoolean("qpidnio"))
+ {
+ _logger.fatal("Using Qpid NIO - sysproperty 'qpidnio' is set.");
+ // result = new org.apache.qpid.nio.SocketConnector(); // non-blocking connector
+ }
+ // else
+
+ {
+ _logger.info("Using Mina NIO");
+ result = new SocketConnector(); // non-blocking connector
+ }
+
+ // Don't have the connector's worker thread wait around for other connections (we only use
+ // one SocketConnector per connection at the moment anyway). This allows short-running
+ // clients (like unit tests) to complete quickly.
+ result.setWorkerTimeout(0);
- // Don't have the connector's worker thread wait around for other connections (we only use
- // one SocketConnector per connection at the moment anyway). This allows short-running
- // clients (like unit tests) to complete quickly.
- result.setWorkerTimeout(0);
+ return result;
+ }
+ });
+ break;
- return result;
- }
- });
- break;
- case VM:
- {
- _instance = getVMTransport(details, Boolean.getBoolean("amqj.AutoCreateVMBroker"));
- break;
- }
+ case VM:
+ {
+ _instance = getVMTransport(details, Boolean.getBoolean("amqj.AutoCreateVMBroker"));
+ break;
+ }
}
return _instance;
@@ -142,7 +144,8 @@
return -1;
}
- private static ITransportConnection getVMTransport(BrokerDetails details, boolean AutoCreate) throws AMQVMBrokerCreationException
+ private static ITransportConnection getVMTransport(BrokerDetails details, boolean AutoCreate)
+ throws AMQVMBrokerCreationException
{
int port = details.getPort();
@@ -154,14 +157,14 @@
}
else
{
- throw new AMQVMBrokerCreationException(port, "VM Broker on port " + port + " does not exist. Auto create disabled.");
+ throw new AMQVMBrokerCreationException(null, port, "VM Broker on port " + port
+ + " does not exist. Auto create disabled.", null);
}
}
return new VmPipeTransportConnection(port);
}
-
public static void createVMBroker(int port) throws AMQVMBrokerCreationException
{
if (_acceptor == null)
@@ -192,7 +195,7 @@
{
_logger.error(e);
- //Try and unbind provider
+ // Try and unbind provider
try
{
VmPipeAddress pipe = new VmPipeAddress(port);
@@ -203,7 +206,7 @@
}
catch (Exception ignore)
{
- //ignore
+ // ignore
}
if (provider == null)
@@ -227,7 +230,7 @@
because = e.getCause().toString();
}
- throw new AMQVMBrokerCreationException(port, because + " Stopped binding of InVM Qpid.AMQP");
+ throw new AMQVMBrokerCreationException(null, port, because + " Stopped binding of InVM Qpid.AMQP", e);
}
}
}
@@ -246,14 +249,14 @@
// can't use introspection to get Provider as it is a server class.
// need to go straight to IoHandlerAdapter but that requries the queues and exchange from the ApplicationRegistry which we can't access.
- //get right constructor and pass in instancec ID - "port"
+ // get right constructor and pass in instancec ID - "port"
IoHandlerAdapter provider;
try
{
- Class[] cnstr = {Integer.class};
- Object[] params = {port};
+ Class[] cnstr = { Integer.class };
+ Object[] params = { port };
provider = (IoHandlerAdapter) Class.forName(protocolProviderClass).getConstructor(cnstr).newInstance(params);
- //Give the broker a second to create
+ // Give the broker a second to create
_logger.info("Created VMBroker Instance:" + port);
}
catch (Exception e)
@@ -270,8 +273,10 @@
because = e.getCause().toString();
}
-
- throw new AMQVMBrokerCreationException(port, because + " Stopped InVM Qpid.AMQP creation");
+ AMQVMBrokerCreationException amqbce =
+ new AMQVMBrokerCreationException(null, port, because + " Stopped InVM Qpid.AMQP creation", null);
+ amqbce.initCause(e);
+ throw amqbce;
}
return provider;
Modified: incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/vmbroker/AMQVMBrokerCreationException.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/vmbroker/AMQVMBrokerCreationException.java?view=diff&rev=530474&r1=530473&r2=530474
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/vmbroker/AMQVMBrokerCreationException.java (original)
+++ incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/vmbroker/AMQVMBrokerCreationException.java Thu Apr 19 09:24:30 2007
@@ -7,9 +7,9 @@
* 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
@@ -21,19 +21,25 @@
package org.apache.qpid.client.vmbroker;
import org.apache.qpid.client.transport.AMQTransportConnectionException;
+import org.apache.qpid.protocol.AMQConstant;
public class AMQVMBrokerCreationException extends AMQTransportConnectionException
{
private int _port;
+ /**
+ * @param port
+ *
+ * @deprecated
+ */
public AMQVMBrokerCreationException(int port)
{
- this(port, "Unable to create vm broker");
+ this(null, port, "Unable to create vm broker", null);
}
- public AMQVMBrokerCreationException(int port, String message)
+ public AMQVMBrokerCreationException(AMQConstant errorCode, int port, String message, Throwable cause)
{
- super(message);
+ super(errorCode, message, cause);
_port = port;
}
Modified: incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/jms/FailoverPolicy.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/jms/FailoverPolicy.java?view=diff&rev=530474&r1=530473&r2=530474
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/jms/FailoverPolicy.java (original)
+++ incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/jms/FailoverPolicy.java Thu Apr 19 09:24:30 2007
@@ -101,7 +101,7 @@
}
catch (Exception cnfe)
{
- throw new IllegalArgumentException("Unknown failover method:" + failoverMethod);
+ throw new IllegalArgumentException("Unknown failover method:" + failoverMethod, cnfe);
}
}
}
Modified: incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/client/MessageListenerMultiConsumerTest.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/client/MessageListenerMultiConsumerTest.java?view=diff&rev=530474&r1=530473&r2=530474
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/client/MessageListenerMultiConsumerTest.java (original)
+++ incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/client/MessageListenerMultiConsumerTest.java Thu Apr 19 09:24:30 2007
@@ -65,6 +65,7 @@
private final CountDownLatch _allMessagesSent = new CountDownLatch(2); //all messages Sent Lock
+
protected void setUp() throws Exception
{
super.setUp();
@@ -122,30 +123,39 @@
TransportConnection.killAllVMBrokers();
}
+// public void testRecieveC1thenC2() throws Exception
+// {
+//
+// for (int msg = 0; msg < MSG_COUNT / 2; msg++)
+// {
+//
+// assertTrue(_consumer1.receive() != null);
+// }
+//
+// for (int msg = 0; msg < MSG_COUNT / 2; msg++)
+// {
+// assertTrue(_consumer2.receive() != null);
+// }
+// }
- public void testRecieveC1thenC2() throws Exception
+ public void testRecieveInterleaved() throws Exception
{
-
- for (int msg = 0; msg < MSG_COUNT / 2; msg++)
+ int msg = 0;
+ int MAX_LOOPS = MSG_COUNT * 2;
+ for (int loops = 0; msg < MSG_COUNT || loops < MAX_LOOPS; loops++)
{
- assertTrue(_consumer1.receive() != null);
- }
-
- for (int msg = 0; msg < MSG_COUNT / 2; msg++)
- {
- assertTrue(_consumer2.receive() != null);
+ if (_consumer1.receive(100) != null)
+ {
+ msg++;
+ }
+ if (_consumer2.receive(100) != null)
+ {
+ msg++;
+ }
}
- }
-
- public void testRecieveInterleaved() throws Exception
- {
- for (int msg = 0; msg < MSG_COUNT / 2; msg++)
- {
- assertTrue(_consumer1.receive() != null);
- assertTrue(_consumer2.receive() != null);
- }
+ assertEquals("Not all messages received.", MSG_COUNT, msg);
}
@@ -161,7 +171,7 @@
if (receivedCount1 == MSG_COUNT / 2)
{
- _allMessagesSent.countDown();
+ _allMessagesSent.countDown();
}
}
@@ -194,6 +204,18 @@
}
assertEquals(MSG_COUNT, receivedCount1 + receivedCount2);
+ }
+
+ public void testRecieveC2Only_OnlyRunWith_REGISTER_CONSUMERS_FLOWED() throws Exception
+ {
+ if (Boolean.parseBoolean(System.getProperties().getProperty("REGISTER_CONSUMERS_FLOWED", "false")))
+ {
+ for (int msg = 0; msg < MSG_COUNT; msg++)
+ {
+ assertTrue(MSG_COUNT + " msg should be received. Only received:" + msg,
+ _consumer2.receive(1000) != null);
+ }
+ }
}
Modified: incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/client/MessageListenerTest.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/client/MessageListenerTest.java?view=diff&rev=530474&r1=530473&r2=530474
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/client/MessageListenerTest.java (original)
+++ incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/client/MessageListenerTest.java Thu Apr 19 09:24:30 2007
@@ -144,6 +144,36 @@
}
+ public void testRecieveTheUseMessageListener() throws Exception
+ {
+
+ _logger.error("Test disabled as initial receive is not called first");
+ // Perform initial receive to start connection
+// assertTrue(_consumer.receive(2000) != null);
+// receivedCount++;
+
+ // Sleep to ensure remaining 4 msgs end up on _synchronousQueue
+// Thread.sleep(1000);
+
+ // Set the message listener and wait for the messages to come in.
+ _consumer.setMessageListener(this);
+
+ _logger.info("Waiting 3 seconds for messages");
+
+ try
+ {
+ _awaitMessages.await(3000, TimeUnit.MILLISECONDS);
+ }
+ catch (InterruptedException e)
+ {
+ //do nothing
+ }
+ //Should have recieved all async messages
+ assertEquals(MSG_COUNT, receivedCount);
+
+ }
+
+
public void onMessage(Message message)
{
_logger.info("Received Message(" + receivedCount + "):" + message);
Modified: incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/client/ResetMessageListenerTest.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/client/ResetMessageListenerTest.java?view=diff&rev=530474&r1=530473&r2=530474
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/client/ResetMessageListenerTest.java (original)
+++ incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/client/ResetMessageListenerTest.java Thu Apr 19 09:24:30 2007
@@ -83,7 +83,7 @@
Hashtable<String, String> env = new Hashtable<String, String>();
env.put("connectionfactory.connection", "amqp://guest:guest@MLT_ID/test?brokerlist='vm://:1'");
- env.put("queue.queue", "direct://amq.direct//MessageListenerTest");
+ env.put("queue.queue", "direct://amq.direct//ResetMessageListenerTest");
_context = factory.getInitialContext(env);
Modified: incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/close/MessageRequeueTest.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/close/MessageRequeueTest.java?view=diff&rev=530474&r1=530473&r2=530474
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/close/MessageRequeueTest.java (original)
+++ incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/close/MessageRequeueTest.java Thu Apr 19 09:24:30 2007
@@ -330,7 +330,7 @@
public void testRequeue() throws JMSException, AMQException, URLSyntaxException
{
int run = 0;
- while (run < 10)
+// while (run < 10)
{
run++;
@@ -350,17 +350,10 @@
_logger.debug("Create Consumer");
MessageConsumer consumer = session.createConsumer(q);
- try
- {
- Thread.sleep(2000);
- }
- catch (InterruptedException e)
- {
- //
- }
+ conn.start();
_logger.debug("Receiving msg");
- Message msg = consumer.receive(1000);
+ Message msg = consumer.receive(2000);
assertNotNull("Message should not be null", msg);
Modified: incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/topic/DurableSubscriptionTest.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/topic/DurableSubscriptionTest.java?view=diff&rev=530474&r1=530473&r2=530474
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/topic/DurableSubscriptionTest.java (original)
+++ incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/topic/DurableSubscriptionTest.java Thu Apr 19 09:24:30 2007
@@ -100,7 +100,9 @@
AMQTopic topic = new AMQTopic(con,"MyTopic");
Session session1 = con.createSession(false, AMQSession.NO_ACKNOWLEDGE);
MessageConsumer consumer1 = session1.createConsumer(topic);
- MessageProducer producer = session1.createProducer(topic);
+
+ Session sessionProd = con.createSession(false, AMQSession.NO_ACKNOWLEDGE);
+ MessageProducer producer = sessionProd.createProducer(topic);
Session session2 = con.createSession(false, AMQSession.NO_ACKNOWLEDGE);
TopicSubscriber consumer2 = session2.createDurableSubscriber(topic, "MySubscription");
@@ -112,12 +114,12 @@
Message msg;
msg = consumer1.receive();
assertEquals("A", ((TextMessage) msg).getText());
- msg = consumer1.receive(1000);
+ msg = consumer1.receive(100);
assertEquals(null, msg);
msg = consumer2.receive();
assertEquals("A", ((TextMessage) msg).getText());
- msg = consumer2.receive(1000);
+ msg = consumer2.receive(100);
assertEquals(null, msg);
consumer2.close();
@@ -127,14 +129,14 @@
producer.send(session1.createTextMessage("B"));
- msg = consumer1.receive();
+ msg = consumer1.receive(100);
assertEquals("B", ((TextMessage) msg).getText());
- msg = consumer1.receive(1000);
+ msg = consumer1.receive(100);
assertEquals(null, msg);
- msg = consumer3.receive();
+ msg = consumer3.receive(100);
assertEquals("B", ((TextMessage) msg).getText());
- msg = consumer3.receive(1000);
+ msg = consumer3.receive(100);
assertEquals(null, msg);
con.close();
Modified: incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/transacted/CommitRollbackTest.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/transacted/CommitRollbackTest.java?view=diff&rev=530474&r1=530473&r2=530474
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/transacted/CommitRollbackTest.java (original)
+++ incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/transacted/CommitRollbackTest.java Thu Apr 19 09:24:30 2007
@@ -53,12 +53,15 @@
Queue _jmsQueue;
private static final Logger _logger = Logger.getLogger(CommitRollbackTest.class);
+ private static final String BROKER = "vm://:1";
protected void setUp() throws Exception
{
super.setUp();
- TransportConnection.createVMBroker(1);
-
+ if (BROKER.startsWith("vm"))
+ {
+ TransportConnection.createVMBroker(1);
+ }
testMethod++;
queue += testMethod;
@@ -68,7 +71,7 @@
private void newConnection() throws AMQException, URLSyntaxException, JMSException
{
- conn = new AMQConnection("amqp://guest:guest@client/test?brokerlist='vm://:1'");
+ conn = new AMQConnection("amqp://guest:guest@client/test?brokerlist='" + BROKER + "'");
_session = conn.createSession(true, Session.CLIENT_ACKNOWLEDGE);
@@ -87,7 +90,10 @@
super.tearDown();
conn.close();
- TransportConnection.killVMBroker(1);
+ if (BROKER.startsWith("vm"))
+ {
+ TransportConnection.killVMBroker(1);
+ }
}
/**
@@ -261,7 +267,7 @@
assertTrue("session is not transacted", _pubSession.getTransacted());
_logger.info("sending test message");
- String MESSAGE_TEXT = "testGetThenDisconnect";
+ String MESSAGE_TEXT = "testGetThenRollback";
_publisher.send(_pubSession.createTextMessage(MESSAGE_TEXT));
_pubSession.commit();
@@ -394,16 +400,60 @@
_logger.info("receiving result");
result = _consumer.receive(1000);
assertNotNull("test message was consumed and rolled back, but is gone", result);
- assertEquals("1", ((TextMessage) result).getText());
- assertTrue("Messasge is not marked as redelivered" + result, result.getJMSRedelivered());
-
- result = _consumer.receive(1000);
- assertNotNull("test message was consumed and rolled back, but is gone", result);
- assertEquals("2", ((TextMessage) result).getText());
- assertTrue("Messasge is not marked as redelivered" + result, result.getJMSRedelivered());
+ if (result.getJMSRedelivered())
+ {
+ assertEquals("1", ((TextMessage) result).getText());
+
+ result = _consumer.receive(1000);
+ assertNotNull("test message was consumed and rolled back, but is gone", result);
+ assertEquals("2", ((TextMessage) result).getText());
+ assertTrue("Messasge is not marked as redelivered" + result, result.getJMSRedelivered());
+ }
+ else
+ {
+ assertEquals("2", ((TextMessage) result).getText());
+ assertTrue("Messasge is marked as redelivered" + result, !result.getJMSRedelivered());
+
+ result = _consumer.receive(1000);
+ assertNotNull("test message was consumed and rolled back, but is gone", result);
+ assertEquals("1", ((TextMessage) result).getText());
+ assertTrue("Messasge is not marked as redelivered" + result, result.getJMSRedelivered());
+ }
result = _consumer.receive(1000);
assertNull("test message should be null:" + result, result);
+
+ }
+
+
+ public void testPutThenRollbackThenGet() throws Exception
+ {
+ assertTrue("session is not transacted", _session.getTransacted());
+ assertTrue("session is not transacted", _pubSession.getTransacted());
+
+ _logger.info("sending test message");
+ String MESSAGE_TEXT = "testPutThenRollbackThenGet";
+
+ _publisher.send(_pubSession.createTextMessage(MESSAGE_TEXT));
+ _pubSession.commit();
+
+ assertNotNull(_consumer.receive(100));
+
+ _publisher.send(_pubSession.createTextMessage(MESSAGE_TEXT));
+
+ _logger.info("rolling back");
+ _pubSession.rollback();
+
+ _logger.info("receiving result");
+ Message result = _consumer.receive(1000);
+ assertNull("test message was put and rolled back, but is still present", result);
+
+ _publisher.send(_pubSession.createTextMessage(MESSAGE_TEXT));
+
+ _pubSession.commit();
+
+ assertNotNull(_consumer.receive(100));
+
}
}
Modified: incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/testutil/Config.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/testutil/Config.java?view=diff&rev=530474&r1=530473&r2=530474
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/testutil/Config.java (original)
+++ incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/testutil/Config.java Thu Apr 19 09:24:30 2007
@@ -172,7 +172,7 @@
}
catch(NumberFormatException e)
{
- throw new RuntimeException("Bad port number: " + value);
+ throw new RuntimeException("Bad port number: " + value, e);
}
}
else if("-name".equalsIgnoreCase(key))
Modified: incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/testutil/QpidClientConnection.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/testutil/QpidClientConnection.java?view=diff&rev=530474&r1=530473&r2=530474
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/testutil/QpidClientConnection.java (original)
+++ incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/testutil/QpidClientConnection.java Thu Apr 19 09:24:30 2007
@@ -3,6 +3,7 @@
import org.apache.qpid.client.AMQConnectionFactory;
import org.apache.qpid.client.AMQConnectionURL;
import org.apache.qpid.client.AMQConnection;
+import org.apache.qpid.client.JMSAMQException;
import org.apache.qpid.url.URLSyntaxException;
import org.apache.log4j.Logger;
@@ -70,7 +71,7 @@
}
catch (URLSyntaxException e)
{
- throw new JMSException("URL syntax error in [" + brokerUrl + "]: " + e.getMessage());
+ throw new JMSAMQException("URL syntax error in [" + brokerUrl + "]: " + e.getMessage(), e);
}
}
}
Modified: incubator/qpid/trunk/qpid/java/common/bin/qpid-run
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/common/bin/qpid-run?view=diff&rev=530474&r1=530473&r2=530474
==============================================================================
--- incubator/qpid/trunk/qpid/java/common/bin/qpid-run (original)
+++ incubator/qpid/trunk/qpid/java/common/bin/qpid-run Thu Apr 19 09:24:30 2007
@@ -106,15 +106,20 @@
export EXTERNAL_CLASSPATH=$CLASSPATH
unset CLASSPATH
-conf=$QPID_HOME/etc/$program.conf
-if [ ! -e $conf ]; then
- conf=$QPID_HOME/etc/$(basename ${sourced}).conf
+#Use QPID_CLASSPATH if set
+if [ -n "$QPID_CLASSPATH" ]; then
+ export CLASSPATH=$QPID_CLASSPATH
+ echo "Using QPID_CLASSPATH" $QPID_CLASSPATH
+else
+ echo "Warning: Qpid classpath not set. CLASSPATH must include qpid jars."
fi
-if [ -r $conf ]; then
- . $conf
+#Use QPID_JAVA_MEM if set
+if [ -n "$QPID_JAVA_MEM" ]; then
+ export JAVA_MEM=$QPID_JAVA_MEM
+ echo "Using QPID_JAVA_MEM setting" $QPID_JAVA_MEM
else
- die "unable to source $conf"
+ echo "Info: QPID_JAVA_MEM not set. Defaulting to JAVA_MEM" $JAVA_MEM
fi
declare -a RUN_ARGS JAVA_ARGS
Modified: incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/AMQException.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/AMQException.java?view=diff&rev=530474&r1=530473&r2=530474
==============================================================================
--- incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/AMQException.java (original)
+++ incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/AMQException.java Thu Apr 19 09:24:30 2007
@@ -23,11 +23,41 @@
import org.apache.log4j.Logger;
import org.apache.qpid.protocol.AMQConstant;
-/** Generic AMQ exception. */
+/**
+ * AMQException forms the root exception of all exceptions relating to the AMQ protocol. It provides space to associate
+ * an AMQ error code with the exception, which is a numberic value, with a meaning defined by the protocol.
+ *
+ * <p/><table id="crc"><caption>CRC Card</caption>
+ * <tr><th> Responsibilities <th> Collaborations
+ * <tr><td> Represents an exception condition associated with an AMQ protocol error code.
+ * </table>
+ *
+ * @todo This exception class is also used as a generic exception throughout Qpid code. This usage may not be strictly
+ * correct if this is to signify a protocol exception. Should review.
+ */
public class AMQException extends Exception
{
+ /** Holds the AMQ error code constant associated with this exception. */
private AMQConstant _errorCode;
+ /**
+ * Creates an exception with an optional error code, optional message and optional underlying cause.
+ *
+ * @param errorCode The error code. May be null if not to be set.
+ * @param msg The exception message. May be null if not to be set.
+ * @param t The underlying cause of the exception. May be null if not to be set.
+ */
+ public AMQException(AMQConstant errorCode, String msg, Throwable t)
+ {
+ super(((msg == null) ? "" : msg) + ((errorCode == null) ? "" : (" [error code " + errorCode + "]")), t);
+ _errorCode = errorCode;
+ }
+
+ /**
+ * @param message
+ *
+ * @deprecated Use {@link #AMQException(org.apache.qpid.protocol.AMQConstant, String, Throwable)} instead.
+ */
public AMQException(String message)
{
super(message);
@@ -35,6 +65,12 @@
_errorCode = AMQConstant.getConstant(-1);
}
+ /**
+ * @param msg
+ * @param t
+ *
+ * @deprecated Use {@link #AMQException(org.apache.qpid.protocol.AMQConstant, String, Throwable)} instead.
+ */
public AMQException(String msg, Throwable t)
{
super(msg, t);
@@ -42,18 +78,19 @@
_errorCode = AMQConstant.getConstant(-1);
}
- public AMQException(AMQConstant errorCode, String msg, Throwable t)
- {
- super(msg + " [error code " + errorCode + ']', t);
- _errorCode = errorCode;
- }
-
+ /**
+ * @param errorCode
+ * @param msg
+ *
+ * @deprecated Use {@link #AMQException(org.apache.qpid.protocol.AMQConstant, String, Throwable)} instead.
+ */
public AMQException(AMQConstant errorCode, String msg)
{
super(msg + " [error code " + errorCode + ']');
_errorCode = errorCode;
}
+ /*
public AMQException(Logger logger, String msg, Throwable t)
{
this(msg, t);
@@ -71,10 +108,15 @@
this(errorCode, msg);
logger.error(getMessage(), this);
}
+ */
+ /**
+ * Gets the AMQ protocol exception code associated with this exception.
+ *
+ * @return The AMQ protocol exception code associated with this exception.
+ */
public AMQConstant getErrorCode()
{
return _errorCode;
}
-
}
Modified: incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/configuration/PropertyException.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/configuration/PropertyException.java?view=diff&rev=530474&r1=530473&r2=530474
==============================================================================
--- incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/configuration/PropertyException.java (original)
+++ incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/configuration/PropertyException.java Thu Apr 19 09:24:30 2007
@@ -1,3 +1,4 @@
+/* Copyright Rupert Smith, 2005 to 2006, all rights reserved. */
/*
*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -7,9 +8,9 @@
* 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
@@ -21,6 +22,7 @@
package org.apache.qpid.configuration;
import org.apache.log4j.Logger;
+
import org.apache.qpid.AMQException;
import org.apache.qpid.protocol.AMQConstant;
@@ -49,7 +51,7 @@
super(errorCode, msg);
}
- public PropertyException(Logger logger, String msg, Throwable t)
+ /*public PropertyException(Logger logger, String msg, Throwable t)
{
super(logger, msg, t);
}
@@ -62,5 +64,5 @@
public PropertyException(Logger logger, AMQConstant errorCode, String msg)
{
super(logger, errorCode, msg);
- }
+ }*/
}
Modified: incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQDataBlockDecoder.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQDataBlockDecoder.java?view=diff&rev=530474&r1=530473&r2=530474
==============================================================================
--- incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQDataBlockDecoder.java (original)
+++ incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQDataBlockDecoder.java Thu Apr 19 09:24:30 2007
@@ -94,7 +94,7 @@
if(bodyFactory == null)
{
- throw new AMQFrameDecodingException("Unsupported frame type: " + type);
+ throw new AMQFrameDecodingException(null, "Unsupported frame type: " + type, null);
}
final int channel = in.getUnsignedShort();
@@ -103,8 +103,8 @@
// bodySize can be zero
if (channel < 0 || bodySize < 0)
{
- throw new AMQFrameDecodingException("Undecodable frame: type = " + type + " channel = " + channel +
- " bodySize = " + bodySize);
+ throw new AMQFrameDecodingException(null, "Undecodable frame: type = " + type + " channel = " + channel +
+ " bodySize = " + bodySize, null);
}
AMQFrame frame = new AMQFrame(in, channel, bodySize, bodyFactory);
@@ -113,7 +113,7 @@
byte marker = in.get();
if ((marker & 0xFF) != 0xCE)
{
- throw new AMQFrameDecodingException("End of frame marker not found. Read " + marker + " length=" + bodySize + " type=" + type);
+ throw new AMQFrameDecodingException(null, "End of frame marker not found. Read " + marker + " length=" + bodySize + " type=" + type, null);
}
return frame;
}
Modified: incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQFrameDecodingException.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQFrameDecodingException.java?view=diff&rev=530474&r1=530473&r2=530474
==============================================================================
--- incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQFrameDecodingException.java (original)
+++ incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQFrameDecodingException.java Thu Apr 19 09:24:30 2007
@@ -1,3 +1,4 @@
+/* Copyright Rupert Smith, 2005 to 2006, all rights reserved. */
/*
*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -7,9 +8,9 @@
* 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
@@ -21,21 +22,23 @@
package org.apache.qpid.framing;
import org.apache.log4j.Logger;
+
import org.apache.qpid.AMQException;
+import org.apache.qpid.protocol.AMQConstant;
public class AMQFrameDecodingException extends AMQException
{
- public AMQFrameDecodingException(String message)
+ /*public AMQFrameDecodingException(String message)
{
super(message);
- }
+ }*/
- public AMQFrameDecodingException(String message, Throwable t)
+ public AMQFrameDecodingException(AMQConstant errorCode, String message, Throwable t)
{
- super(message, t);
+ super(errorCode, message, t);
}
- public AMQFrameDecodingException(Logger log, String message)
+ /*public AMQFrameDecodingException(Logger log, String message)
{
super(log, message);
}
@@ -43,6 +46,5 @@
public AMQFrameDecodingException(Logger log, String message, Throwable t)
{
super(log, message, t);
- }
-
+ }*/
}
Modified: incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQShortString.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQShortString.java?view=diff&rev=530474&r1=530473&r2=530474
==============================================================================
--- incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQShortString.java (original)
+++ incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQShortString.java Thu Apr 19 09:24:30 2007
@@ -9,7 +9,7 @@
* and thus can be held more effectively in a byte buffer.
*
*/
-public final class AMQShortString implements CharSequence
+public final class AMQShortString implements CharSequence, Comparable<AMQShortString>
{
private static final Logger _logger = Logger.getLogger(AMQShortString.class);
Modified: incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/framing/BasicContentHeaderProperties.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/framing/BasicContentHeaderProperties.java?view=diff&rev=530474&r1=530473&r2=530474
==============================================================================
--- incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/framing/BasicContentHeaderProperties.java (original)
+++ incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/framing/BasicContentHeaderProperties.java Thu Apr 19 09:24:30 2007
@@ -341,7 +341,7 @@
}
catch (AMQFrameDecodingException e)
{
- throw new RuntimeException("Error in content header data: " + e);
+ throw new RuntimeException("Error in content header data: " + e, e);
}
final int endPos = buffer.position();
@@ -381,7 +381,7 @@
}
catch (AMQFrameDecodingException e)
{
- throw new RuntimeException("Error in content header data: " + e);
+ throw new RuntimeException("Error in content header data: " + e, e);
}
}
Modified: incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/framing/ContentHeaderPropertiesFactory.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/framing/ContentHeaderPropertiesFactory.java?view=diff&rev=530474&r1=530473&r2=530474
==============================================================================
--- incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/framing/ContentHeaderPropertiesFactory.java (original)
+++ incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/framing/ContentHeaderPropertiesFactory.java Thu Apr 19 09:24:30 2007
@@ -49,7 +49,7 @@
}
else
{
- throw new AMQFrameDecodingException("Unsupport content header class id: " + classId);
+ throw new AMQFrameDecodingException(null, "Unsupport content header class id: " + classId, null);
}
properties.populatePropertiesFromBuffer(buffer, propertyFlags, size);
return properties;
Modified: incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/framing/EncodingUtils.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/framing/EncodingUtils.java?view=diff&rev=530474&r1=530473&r2=530474
==============================================================================
--- incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/framing/EncodingUtils.java (original)
+++ incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/framing/EncodingUtils.java Thu Apr 19 09:24:30 2007
@@ -7,9 +7,9 @@
* 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
@@ -23,6 +23,7 @@
import java.nio.charset.Charset;
import org.apache.log4j.Logger;
+
import org.apache.mina.common.ByteBuffer;
public class EncodingUtils
@@ -49,96 +50,95 @@
}
}
-
public static int encodedShortStringLength(short s)
{
- if( s == 0 )
+ if (s == 0)
{
return 1 + 1;
}
int len = 0;
- if(s < 0)
+ if (s < 0)
{
- len=1;
+ len = 1;
// sloppy - doesn't work of Integer.MIN_VALUE
- s=(short)-s;
+ s = (short) -s;
}
- if(s>9999)
+ if (s > 9999)
{
- return 1+5;
+ return 1 + 5;
}
- else if(s>999)
+ else if (s > 999)
{
- return 1+4;
+ return 1 + 4;
}
- else if(s>99)
+ else if (s > 99)
{
- return 1+3;
+ return 1 + 3;
}
- else if(s>9)
+ else if (s > 9)
{
- return 1+2;
+ return 1 + 2;
}
else
{
- return 1+1;
+ return 1 + 1;
}
}
-
public static int encodedShortStringLength(int i)
{
- if( i == 0 )
+ if (i == 0)
{
return 1 + 1;
}
int len = 0;
- if(i < 0)
+ if (i < 0)
{
- len=1;
+ len = 1;
// sloppy - doesn't work of Integer.MIN_VALUE
- i=-i;
+ i = -i;
}
// range is now 1 - 2147483647
- if(i < Short.MAX_VALUE)
+ if (i < Short.MAX_VALUE)
{
- return len + encodedShortStringLength((short)i);
+ return len + encodedShortStringLength((short) i);
}
else if (i > 999999)
{
- return len + 6 + encodedShortStringLength((short)(i/1000000));
+ return len + 6 + encodedShortStringLength((short) (i / 1000000));
}
else // if (i > 99999)
{
- return len + 5 + encodedShortStringLength((short)(i/100000));
+ return len + 5 + encodedShortStringLength((short) (i / 100000));
}
}
public static int encodedShortStringLength(long l)
{
- if(l == 0)
+ if (l == 0)
{
return 1 + 1;
}
int len = 0;
- if(l < 0)
+ if (l < 0)
{
- len=1;
+ len = 1;
// sloppy - doesn't work of Long.MIN_VALUE
- l=-l;
+ l = -l;
}
- if(l < Integer.MAX_VALUE)
+
+ if (l < Integer.MAX_VALUE)
{
return len + encodedShortStringLength((int) l);
}
- else if(l > 9999999999L)
+ else if (l > 9999999999L)
{
return len + 10 + encodedShortStringLength((int) (l / 10000000000L));
}
@@ -149,7 +149,6 @@
}
-
public static int encodedShortStringLength(AMQShortString s)
{
if (s == null)
@@ -162,7 +161,6 @@
}
}
-
public static int encodedLongStringLength(String s)
{
if (s == null)
@@ -219,7 +217,6 @@
return 0;
}
-
public static void writeShortStringBytes(ByteBuffer buffer, String s)
{
if (s != null)
@@ -230,6 +227,7 @@
{
encodedString[i] = (byte) cha[i];
}
+
writeBytes(buffer, encodedString);
}
else
@@ -239,7 +237,6 @@
}
}
-
public static void writeShortStringBytes(ByteBuffer buffer, AMQShortString s)
{
if (s != null)
@@ -256,7 +253,7 @@
public static void writeLongStringBytes(ByteBuffer buffer, String s)
{
- assert s == null || s.length() <= 0xFFFE;
+ assert (s == null) || (s.length() <= 0xFFFE);
if (s != null)
{
int len = s.length();
@@ -267,6 +264,7 @@
{
encodedString[i] = (byte) cha[i];
}
+
buffer.put(encodedString);
}
else
@@ -277,7 +275,7 @@
public static void writeLongStringBytes(ByteBuffer buffer, char[] s)
{
- assert s == null || s.length <= 0xFFFE;
+ assert (s == null) || (s.length <= 0xFFFE);
if (s != null)
{
int len = s.length;
@@ -287,6 +285,7 @@
{
encodedString[i] = (byte) s[i];
}
+
buffer.put(encodedString);
}
else
@@ -297,7 +296,7 @@
public static void writeLongStringBytes(ByteBuffer buffer, byte[] bytes)
{
- assert bytes == null || bytes.length <= 0xFFFE;
+ assert (bytes == null) || (bytes.length <= 0xFFFE);
if (bytes != null)
{
writeUnsignedInteger(buffer, bytes.length);
@@ -330,7 +329,6 @@
}
}
-
public static int unsignedIntegerLength()
{
return 4;
@@ -356,7 +354,6 @@
}
}
-
public static void writeFieldTableBytes(ByteBuffer buffer, FieldTable table)
{
if (table != null)
@@ -400,10 +397,9 @@
if (value1)
{
- packedValue = (byte) (packedValue | (byte)(1 << 1));
+ packedValue = (byte) (packedValue | (byte) (1 << 1));
}
-
buffer.put(packedValue);
}
@@ -413,213 +409,181 @@
if (value1)
{
- packedValue = (byte) (packedValue | (byte)(1 << 1));
+ packedValue = (byte) (packedValue | (byte) (1 << 1));
}
if (value2)
{
- packedValue = (byte) (packedValue | (byte)(1 << 2));
+ packedValue = (byte) (packedValue | (byte) (1 << 2));
}
-
buffer.put(packedValue);
}
-
-
- public static void writeBooleans(ByteBuffer buffer,
- boolean value0,
- boolean value1,
- boolean value2,
- boolean value3)
+ public static void writeBooleans(ByteBuffer buffer, boolean value0, boolean value1, boolean value2, boolean value3)
{
byte packedValue = value0 ? (byte) 1 : (byte) 0;
if (value1)
{
- packedValue = (byte) (packedValue | (byte)(1 << 1));
+ packedValue = (byte) (packedValue | (byte) (1 << 1));
}
if (value2)
{
- packedValue = (byte) (packedValue | (byte)(1 << 2));
+ packedValue = (byte) (packedValue | (byte) (1 << 2));
}
if (value3)
{
- packedValue = (byte) (packedValue | (byte)(1 << 3));
+ packedValue = (byte) (packedValue | (byte) (1 << 3));
}
buffer.put(packedValue);
}
- public static void writeBooleans(ByteBuffer buffer,
- boolean value0,
- boolean value1,
- boolean value2,
- boolean value3,
- boolean value4)
+ public static void writeBooleans(ByteBuffer buffer, boolean value0, boolean value1, boolean value2, boolean value3,
+ boolean value4)
{
byte packedValue = value0 ? (byte) 1 : (byte) 0;
if (value1)
{
- packedValue = (byte) (packedValue | (byte)(1 << 1));
+ packedValue = (byte) (packedValue | (byte) (1 << 1));
}
if (value2)
{
- packedValue = (byte) (packedValue | (byte)(1 << 2));
+ packedValue = (byte) (packedValue | (byte) (1 << 2));
}
if (value3)
{
- packedValue = (byte) (packedValue | (byte)(1 << 3));
+ packedValue = (byte) (packedValue | (byte) (1 << 3));
}
if (value4)
{
- packedValue = (byte) (packedValue | (byte)(1 << 4));
+ packedValue = (byte) (packedValue | (byte) (1 << 4));
}
buffer.put(packedValue);
}
- public static void writeBooleans(ByteBuffer buffer,
- boolean value0,
- boolean value1,
- boolean value2,
- boolean value3,
- boolean value4,
- boolean value5)
+ public static void writeBooleans(ByteBuffer buffer, boolean value0, boolean value1, boolean value2, boolean value3,
+ boolean value4, boolean value5)
{
byte packedValue = value0 ? (byte) 1 : (byte) 0;
if (value1)
{
- packedValue = (byte) (packedValue | (byte)(1 << 1));
+ packedValue = (byte) (packedValue | (byte) (1 << 1));
}
if (value2)
{
- packedValue = (byte) (packedValue | (byte)(1 << 2));
+ packedValue = (byte) (packedValue | (byte) (1 << 2));
}
if (value3)
{
- packedValue = (byte) (packedValue | (byte)(1 << 3));
+ packedValue = (byte) (packedValue | (byte) (1 << 3));
}
if (value4)
{
- packedValue = (byte) (packedValue | (byte)(1 << 4));
+ packedValue = (byte) (packedValue | (byte) (1 << 4));
}
if (value5)
{
- packedValue = (byte) (packedValue | (byte)(1 << 5));
+ packedValue = (byte) (packedValue | (byte) (1 << 5));
}
buffer.put(packedValue);
}
- public static void writeBooleans(ByteBuffer buffer,
- boolean value0,
- boolean value1,
- boolean value2,
- boolean value3,
- boolean value4,
- boolean value5,
- boolean value6)
+ public static void writeBooleans(ByteBuffer buffer, boolean value0, boolean value1, boolean value2, boolean value3,
+ boolean value4, boolean value5, boolean value6)
{
byte packedValue = value0 ? (byte) 1 : (byte) 0;
if (value1)
{
- packedValue = (byte) (packedValue | (byte)(1 << 1));
+ packedValue = (byte) (packedValue | (byte) (1 << 1));
}
if (value2)
{
- packedValue = (byte) (packedValue | (byte)(1 << 2));
+ packedValue = (byte) (packedValue | (byte) (1 << 2));
}
if (value3)
{
- packedValue = (byte) (packedValue | (byte)(1 << 3));
+ packedValue = (byte) (packedValue | (byte) (1 << 3));
}
if (value4)
{
- packedValue = (byte) (packedValue | (byte)(1 << 4));
+ packedValue = (byte) (packedValue | (byte) (1 << 4));
}
if (value5)
{
- packedValue = (byte) (packedValue | (byte)(1 << 5));
+ packedValue = (byte) (packedValue | (byte) (1 << 5));
}
if (value6)
{
- packedValue = (byte) (packedValue | (byte)(1 << 6));
+ packedValue = (byte) (packedValue | (byte) (1 << 6));
}
buffer.put(packedValue);
}
- public static void writeBooleans(ByteBuffer buffer,
- boolean value0,
- boolean value1,
- boolean value2,
- boolean value3,
- boolean value4,
- boolean value5,
- boolean value6,
- boolean value7)
+ public static void writeBooleans(ByteBuffer buffer, boolean value0, boolean value1, boolean value2, boolean value3,
+ boolean value4, boolean value5, boolean value6, boolean value7)
{
byte packedValue = value0 ? (byte) 1 : (byte) 0;
if (value1)
{
- packedValue = (byte) (packedValue | (byte)(1 << 1));
+ packedValue = (byte) (packedValue | (byte) (1 << 1));
}
if (value2)
{
- packedValue = (byte) (packedValue | (byte)(1 << 2));
+ packedValue = (byte) (packedValue | (byte) (1 << 2));
}
if (value3)
{
- packedValue = (byte) (packedValue | (byte)(1 << 3));
+ packedValue = (byte) (packedValue | (byte) (1 << 3));
}
if (value4)
{
- packedValue = (byte) (packedValue | (byte)(1 << 4));
+ packedValue = (byte) (packedValue | (byte) (1 << 4));
}
if (value5)
{
- packedValue = (byte) (packedValue | (byte)(1 << 5));
+ packedValue = (byte) (packedValue | (byte) (1 << 5));
}
if (value6)
{
- packedValue = (byte) (packedValue | (byte)(1 << 6));
+ packedValue = (byte) (packedValue | (byte) (1 << 6));
}
if (value7)
{
- packedValue = (byte) (packedValue | (byte)(1 << 7));
+ packedValue = (byte) (packedValue | (byte) (1 << 7));
}
buffer.put(packedValue);
}
-
-
-
/**
* This is used for writing longstrs.
*
@@ -647,26 +611,27 @@
public static boolean[] readBooleans(ByteBuffer buffer)
{
final byte packedValue = buffer.get();
- if(packedValue == 0)
+ if (packedValue == 0)
{
return ALL_FALSE_ARRAY;
}
+
final boolean[] result = new boolean[8];
result[0] = ((packedValue & 1) != 0);
result[1] = ((packedValue & (1 << 1)) != 0);
result[2] = ((packedValue & (1 << 2)) != 0);
result[3] = ((packedValue & (1 << 3)) != 0);
- if((packedValue & 0xF0) == 0)
+ if ((packedValue & 0xF0) == 0)
{
result[0] = ((packedValue & 1) != 0);
}
+
result[4] = ((packedValue & (1 << 4)) != 0);
result[5] = ((packedValue & (1 << 5)) != 0);
result[6] = ((packedValue & (1 << 6)) != 0);
result[7] = ((packedValue & (1 << 7)) != 0);
-
return result;
}
@@ -742,6 +707,7 @@
{
stringChars[i] = (char) stringBytes[i];
}
+
return new String(stringChars);
}
}
@@ -757,6 +723,7 @@
{
byte[] result = new byte[(int) length];
buffer.get(result);
+
return result;
}
}
@@ -764,15 +731,14 @@
public static long readTimestamp(ByteBuffer buffer)
{
// Discard msb from AMQ timestamp
- //buffer.getUnsignedInt();
+ // buffer.getUnsignedInt();
return buffer.getLong();
}
-
static byte[] hexToByteArray(String id)
{
// Should check param for null, long enough for this check, upper-case and trailing char
- String s = (id.charAt(1) == 'x') ? id.substring(2) : id; // strip 0x
+ String s = (id.charAt(1) == 'x') ? id.substring(2) : id; // strip 0x
int len = s.length();
int byte_len = len / 2;
@@ -786,7 +752,7 @@
byte b1 = Byte.parseByte(s.substring(ch, ch + 1), 16);
byte b2 = Byte.parseByte(s.substring(ch + 1, ch + 2), 16);
- b[i] = (byte) (b1 * 16 + b2);
+ b[i] = (byte) ((b1 * 16) + b2);
}
return (b);
@@ -795,7 +761,7 @@
public static char[] convertToHexCharArray(byte[] from)
{
int length = from.length;
- char[] result_buff = new char[length * 2 + 2];
+ char[] result_buff = new char[(length * 2) + 2];
result_buff[0] = '0';
result_buff[1] = 'x';
@@ -831,7 +797,7 @@
byte[] from = new byte[size];
// Is this not the same.
- //bb.get(from, 0, length);
+ // bb.get(from, 0, length);
for (int i = 0; i < size; i++)
{
from[i] = bb.get(i);
@@ -840,9 +806,9 @@
return (new String(convertToHexCharArray(from)));
}
- private static char hex_chars[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
+ private static char[] hex_chars = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
- //**** new methods
+ // **** new methods
// AMQP_BOOLEAN_PROPERTY_PREFIX
@@ -854,6 +820,7 @@
public static boolean readBoolean(ByteBuffer buffer)
{
byte packedValue = buffer.get();
+
return (packedValue == 1);
}
@@ -878,7 +845,6 @@
return 1;
}
-
// AMQP_SHORT_PROPERTY_PREFIX
public static void writeShort(ByteBuffer buffer, Short aShort)
{
@@ -943,7 +909,6 @@
return 4;
}
-
// Double_PROPERTY_PREFIX
public static void writeDouble(ByteBuffer buffer, Double aDouble)
{
@@ -960,7 +925,6 @@
return 8;
}
-
public static byte[] readBytes(ByteBuffer buffer)
{
short length = buffer.getUnsigned();
@@ -981,7 +945,7 @@
{
if (data != null)
{
- // TODO: check length fits in an unsigned byte
+ // TODO: check length fits in an unsigned byte
writeUnsignedByte(buffer, (short) data.length);
buffer.put(data);
}
@@ -992,7 +956,7 @@
}
}
- //CHAR_PROPERTY
+ // CHAR_PROPERTY
public static int encodedCharLength()
{
return encodedByteLength();
@@ -1000,31 +964,29 @@
public static char readChar(ByteBuffer buffer)
{
- //This is valid as we know that the Character is ASCII 0..127
+ // This is valid as we know that the Character is ASCII 0..127
return (char) buffer.get();
}
public static void writeChar(ByteBuffer buffer, char character)
{
- //This is valid as we know that the Character is ASCII 0..127
+ // This is valid as we know that the Character is ASCII 0..127
writeByte(buffer, (byte) character);
}
-
-
-
public static long readLongAsShortString(ByteBuffer buffer)
{
short length = buffer.getUnsigned();
short pos = 0;
- if(length == 0)
+ if (length == 0)
{
return 0L;
}
+
byte digit = buffer.get();
boolean isNegative;
long result = 0;
- if(digit == (byte)'-')
+ if (digit == (byte) '-')
{
isNegative = true;
pos++;
@@ -1034,15 +996,16 @@
{
isNegative = false;
}
- result = digit - (byte)'0';
+
+ result = digit - (byte) '0';
pos++;
- while(pos < length)
+ while (pos < length)
{
pos++;
digit = buffer.get();
result = (result << 3) + (result << 1);
- result += digit - (byte)'0';
+ result += digit - (byte) '0';
}
return result;
@@ -1051,33 +1014,13 @@
public static long readUnsignedInteger(ByteBuffer buffer)
{
long l = 0xFF & buffer.get();
- l <<=8;
+ l <<= 8;
l = l | (0xFF & buffer.get());
- l <<=8;
+ l <<= 8;
l = l | (0xFF & buffer.get());
- l <<=8;
+ l <<= 8;
l = l | (0xFF & buffer.get());
return l;
}
-
-
- public static void main(String[] args)
- {
- ByteBuffer buf = ByteBuffer.allocate(8);
- buf.setAutoExpand(true);
-
- long l = (long) Integer.MAX_VALUE;
- l += 1024L;
-
- writeUnsignedInteger(buf, l);
-
- buf.flip();
-
- long l2 = readUnsignedInteger(buf);
-
- System.out.println("before: " + l);
- System.out.println("after: " + l2);
- }
-
}
Modified: incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/framing/VersionSpecificRegistry.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/framing/VersionSpecificRegistry.java?view=diff&rev=530474&r1=530473&r2=530474
==============================================================================
--- incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/framing/VersionSpecificRegistry.java (original)
+++ incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/framing/VersionSpecificRegistry.java Thu Apr 19 09:24:30 2007
@@ -148,34 +148,30 @@
}
catch(NullPointerException e)
{
- throw new AMQFrameDecodingException(_log,
- "Class " + classID + " unknown in AMQP version " + _protocolMajorVersion + "-" + _protocolMinorVersion
- + " (while trying to decode class " + classID + " method " + methodID + ".");
+ throw new AMQFrameDecodingException(null, "Class " + classID + " unknown in AMQP version " + _protocolMajorVersion
+ + "-" + _protocolMinorVersion + " (while trying to decode class " + classID + " method " + methodID + ".", e);
}
catch(IndexOutOfBoundsException e)
{
if(classID >= _registry.length)
{
- throw new AMQFrameDecodingException(_log,
- "Class " + classID + " unknown in AMQP version " + _protocolMajorVersion + "-" + _protocolMinorVersion
- + " (while trying to decode class " + classID + " method " + methodID + ".");
-
+ throw new AMQFrameDecodingException(null, "Class " + classID + " unknown in AMQP version " + _protocolMajorVersion
+ + "-" + _protocolMinorVersion + " (while trying to decode class " + classID + " method " + methodID
+ + ".", e);
}
else
{
- throw new AMQFrameDecodingException(_log,
- "Method " + methodID + " unknown in AMQP version " + _protocolMajorVersion + "-" + _protocolMinorVersion
- + " (while trying to decode class " + classID + " method " + methodID + ".");
-
+ throw new AMQFrameDecodingException(null, "Method " + methodID + " unknown in AMQP version "
+ + _protocolMajorVersion + "-" + _protocolMinorVersion + " (while trying to decode class " + classID
+ + " method " + methodID + ".", e);
}
}
if (bodyFactory == null)
{
- throw new AMQFrameDecodingException(_log,
- "Method " + methodID + " unknown in AMQP version " + _protocolMajorVersion + "-" + _protocolMinorVersion
- + " (while trying to decode class " + classID + " method " + methodID + ".");
+ throw new AMQFrameDecodingException(null, "Method " + methodID + " unknown in AMQP version " + _protocolMajorVersion
+ + "-" + _protocolMinorVersion + " (while trying to decode class " + classID + " method " + methodID + ".", null);
}
Modified: incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/pool/Event.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/pool/Event.java?view=diff&rev=530474&r1=530473&r2=530474
==============================================================================
--- incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/pool/Event.java (original)
+++ incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/pool/Event.java Thu Apr 19 09:24:30 2007
@@ -85,4 +85,27 @@
}
+
+ public static final class CloseEvent extends Event
+ {
+ private final IoFilter.NextFilter _nextFilter;
+
+ public CloseEvent(final IoFilter.NextFilter nextFilter)
+ {
+ super();
+ _nextFilter = nextFilter;
+ }
+
+
+ public void process(IoSession session)
+ {
+ _nextFilter.sessionClosed(session);
+ }
+
+ public IoFilter.NextFilter getNextFilter()
+ {
+ return _nextFilter;
+ }
+ }
+
}