diff options
14 files changed, 120 insertions, 225 deletions
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/DefaultExchangeFactory.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/DefaultExchangeFactory.java index d90113fa35..c349b44d6d 100644 --- a/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/DefaultExchangeFactory.java +++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/DefaultExchangeFactory.java @@ -65,11 +65,11 @@ public class DefaultExchangeFactory implements ExchangeFactory } catch (InstantiationException e) { - throw new AMQException(_logger, "Unable to create exchange: " + e, e); + throw new AMQException("Unable to create exchange: " + e, e); } catch (IllegalAccessException e) { - throw new AMQException(_logger, "Unable to create exchange: " + e, e); + throw new AMQException("Unable to create exchange: " + e, e); } } } diff --git a/qpid/java/client/example/src/main/java/org/apache/qpid/example/publisher/MessageFactoryException.java b/qpid/java/client/example/src/main/java/org/apache/qpid/example/publisher/MessageFactoryException.java index 34360d6708..0a4231c977 100644 --- a/qpid/java/client/example/src/main/java/org/apache/qpid/example/publisher/MessageFactoryException.java +++ b/qpid/java/client/example/src/main/java/org/apache/qpid/example/publisher/MessageFactoryException.java @@ -1,4 +1,5 @@ /* + * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -6,21 +7,21 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. + * */ package org.apache.qpid.example.publisher; -import org.apache.log4j.Logger; - -public class MessageFactoryException extends Exception { +public class MessageFactoryException extends Exception +{ private int _errorCode; @@ -46,27 +47,8 @@ public class MessageFactoryException extends Exception { _errorCode = errorCode; } - public MessageFactoryException(Logger logger, String msg, Throwable t) - { - this(msg, t); - logger.error(getMessage(), this); - } - - public MessageFactoryException(Logger logger, String msg) - { - this(msg); - logger.error(getMessage(), this); - } - - public MessageFactoryException(Logger logger, int errorCode, String msg) - { - this(errorCode, msg); - logger.error(getMessage(), this); - } - public int getErrorCode() { return _errorCode; } } - diff --git a/qpid/java/client/example/src/main/java/org/apache/qpid/example/publisher/UndeliveredMessageException.java b/qpid/java/client/example/src/main/java/org/apache/qpid/example/publisher/UndeliveredMessageException.java index 3335833c2d..399cbc9427 100644 --- a/qpid/java/client/example/src/main/java/org/apache/qpid/example/publisher/UndeliveredMessageException.java +++ b/qpid/java/client/example/src/main/java/org/apache/qpid/example/publisher/UndeliveredMessageException.java @@ -1,4 +1,5 @@ /* + * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -6,24 +7,24 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. + * */ package org.apache.qpid.example.publisher; -import org.apache.log4j.Logger; - /** * Exception thrown by monitor when cannot send a message marked for immediate delivery */ -public class UndeliveredMessageException extends Exception { +public class UndeliveredMessageException extends Exception +{ private int _errorCode; @@ -49,24 +50,6 @@ public class UndeliveredMessageException extends Exception { _errorCode = errorCode; } - public UndeliveredMessageException(Logger logger, String msg, Throwable t) - { - this(msg, t); - logger.error(getMessage(), this); - } - - public UndeliveredMessageException(Logger logger, String msg) - { - this(msg); - logger.error(getMessage(), this); - } - - public UndeliveredMessageException(Logger logger, int errorCode, String msg) - { - this(errorCode, msg); - logger.error(getMessage(), this); - } - public int getErrorCode() { return _errorCode; diff --git a/qpid/java/client/example/src/main/java/org/apache/qpid/example/shared/ConnectionException.java b/qpid/java/client/example/src/main/java/org/apache/qpid/example/shared/ConnectionException.java index 8723983862..6eb847ea9d 100644 --- a/qpid/java/client/example/src/main/java/org/apache/qpid/example/shared/ConnectionException.java +++ b/qpid/java/client/example/src/main/java/org/apache/qpid/example/shared/ConnectionException.java @@ -1,4 +1,5 @@ /* + * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -6,21 +7,21 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. + * */ package org.apache.qpid.example.shared; -import org.apache.log4j.Logger; - -public class ConnectionException extends Exception { +public class ConnectionException extends Exception +{ private int _errorCode; @@ -46,24 +47,6 @@ public class ConnectionException extends Exception { _errorCode = errorCode; } - public ConnectionException(Logger logger, String msg, Throwable t) - { - this(msg, t); - logger.error(getMessage(), this); - } - - public ConnectionException(Logger logger, String msg) - { - this(msg); - logger.error(getMessage(), this); - } - - public ConnectionException(Logger logger, int errorCode, String msg) - { - this(errorCode, msg); - logger.error(getMessage(), this); - } - public int getErrorCode() { return _errorCode; diff --git a/qpid/java/client/example/src/main/java/org/apache/qpid/example/shared/ContextException.java b/qpid/java/client/example/src/main/java/org/apache/qpid/example/shared/ContextException.java index 787cecd541..bf805ab817 100644 --- a/qpid/java/client/example/src/main/java/org/apache/qpid/example/shared/ContextException.java +++ b/qpid/java/client/example/src/main/java/org/apache/qpid/example/shared/ContextException.java @@ -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 @@ -20,9 +20,8 @@ */ package org.apache.qpid.example.shared; -import org.apache.log4j.Logger; - -public class ContextException extends Exception { +public class ContextException extends Exception +{ private int _errorCode; @@ -48,24 +47,6 @@ public class ContextException extends Exception { _errorCode = errorCode; } - public ContextException(Logger logger, String msg, Throwable t) - { - this(msg, t); - logger.error(getMessage(), this); - } - - public ContextException(Logger logger, String msg) - { - this(msg); - logger.error(getMessage(), this); - } - - public ContextException(Logger logger, int errorCode, String msg) - { - this(errorCode, msg); - logger.error(getMessage(), this); - } - public int getErrorCode() { return _errorCode; diff --git a/qpid/java/client/example/src/main/java/org/apache/qpid/example/shared/InitialContextHelper.java b/qpid/java/client/example/src/main/java/org/apache/qpid/example/shared/InitialContextHelper.java index b39892b688..8505d1d457 100644 --- a/qpid/java/client/example/src/main/java/org/apache/qpid/example/shared/InitialContextHelper.java +++ b/qpid/java/client/example/src/main/java/org/apache/qpid/example/shared/InitialContextHelper.java @@ -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 @@ -20,18 +20,20 @@ */ package org.apache.qpid.example.shared; -import org.apache.log4j.Logger; +import java.io.IOException; +import java.io.InputStream; +import java.util.Properties; import javax.naming.InitialContext; import javax.naming.NamingException; -import java.util.Properties; -import java.io.InputStream; -import java.io.IOException; + +import org.apache.log4j.Logger; /** * Class that provides helper methods for JNDI */ -public class InitialContextHelper { +public class InitialContextHelper +{ public static final String _defaultPropertiesName = "example.properties"; protected static Properties _fileProperties; @@ -42,7 +44,7 @@ public class InitialContextHelper { { try { - if (propertiesName == null || propertiesName.length() == 0) + if ((propertiesName == null) || (propertiesName.length() == 0)) { propertiesName = _defaultPropertiesName; } @@ -50,18 +52,18 @@ public class InitialContextHelper { _fileProperties = new Properties(); ClassLoader cl = this.getClass().getClassLoader(); - //NB: Need to change path to reflect package if moving classes around ! + // NB: Need to change path to reflect package if moving classes around ! InputStream is = cl.getResourceAsStream("org/apache/qpid/example/shared/" + propertiesName); _fileProperties.load(is); _initialContext = new InitialContext(_fileProperties); } catch (IOException e) { - throw new ContextException(_log, e.toString()); + throw new ContextException(e.toString()); } catch (NamingException n) { - throw new ContextException(_log, n.toString()); + throw new ContextException(n.toString()); } } diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession.java index 184bc44912..82f9a036d2 100644 --- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession.java +++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession.java @@ -769,7 +769,7 @@ public class AMQSession extends Closeable implements Session, QueueSession, Topi } else { - amqe = new AMQException(_logger, "Closing session forcibly", e); + amqe = new AMQException("Closing session forcibly", e); } _connection.deregisterSession(_channelId); closeProducersAndConsumers(amqe); diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ConnectionStartMethodHandler.java b/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ConnectionStartMethodHandler.java index f6ddfdc715..28c0c4f3c9 100644 --- a/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ConnectionStartMethodHandler.java +++ b/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ConnectionStartMethodHandler.java @@ -170,7 +170,7 @@ public class ConnectionStartMethodHandler implements StateAwareMethodListener } catch (UnsupportedEncodingException e) { - throw new AMQException(_log, "Unable to decode data: " + e, e); + throw new AMQException("Unable to decode data: " + e, e); } } else diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/message/UnexpectedBodyReceivedException.java b/qpid/java/client/src/main/java/org/apache/qpid/client/message/UnexpectedBodyReceivedException.java index 21526ac6d2..54a8283763 100644 --- a/qpid/java/client/src/main/java/org/apache/qpid/client/message/UnexpectedBodyReceivedException.java +++ b/qpid/java/client/src/main/java/org/apache/qpid/client/message/UnexpectedBodyReceivedException.java @@ -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 @@ -20,25 +20,23 @@ */ package org.apache.qpid.client.message; -import org.apache.log4j.Logger; import org.apache.qpid.AMQException; import org.apache.qpid.protocol.AMQConstant; public class UnexpectedBodyReceivedException extends AMQException { - - public UnexpectedBodyReceivedException(Logger logger, String msg, Throwable t) + public UnexpectedBodyReceivedException(String msg, Throwable t) { - super(logger, msg, t); + super(msg, t); } - public UnexpectedBodyReceivedException(Logger logger, String msg) + public UnexpectedBodyReceivedException(String msg) { - super(logger, msg); + super(msg); } - public UnexpectedBodyReceivedException(Logger logger, AMQConstant errorCode, String msg) + public UnexpectedBodyReceivedException(AMQConstant errorCode, String msg) { - super(logger, errorCode, msg); + super(errorCode, msg); } } diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolSession.java b/qpid/java/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolSession.java index e875b4dca8..35aa69bd82 100644 --- a/qpid/java/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolSession.java +++ b/qpid/java/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolSession.java @@ -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 @@ -27,11 +27,14 @@ import javax.jms.JMSException; import javax.security.sasl.SaslClient; import org.apache.commons.lang.StringUtils; + import org.apache.log4j.Logger; + import org.apache.mina.common.CloseFuture; import org.apache.mina.common.IdleStatus; import org.apache.mina.common.IoSession; import org.apache.mina.common.WriteFuture; + import org.apache.qpid.AMQException; import org.apache.qpid.client.AMQConnection; import org.apache.qpid.client.AMQSession; @@ -45,10 +48,10 @@ import org.apache.qpid.framing.ContentBody; import org.apache.qpid.framing.ContentHeaderBody; import org.apache.qpid.framing.MainRegistry; import org.apache.qpid.framing.ProtocolInitiation; -import org.apache.qpid.framing.VersionSpecificRegistry; import org.apache.qpid.framing.ProtocolVersion; -import org.apache.qpid.protocol.AMQVersionAwareProtocolSession; +import org.apache.qpid.framing.VersionSpecificRegistry; import org.apache.qpid.protocol.AMQConstant; +import org.apache.qpid.protocol.AMQVersionAwareProtocolSession; /** * Wrapper for protocol session that provides type-safe access to session attributes. <p/> The underlying protocol @@ -98,8 +101,8 @@ public class AMQProtocolSession implements AMQVersionAwareProtocolSession private byte _protocolMinorVersion; private byte _protocolMajorVersion; - private VersionSpecificRegistry _registry = MainRegistry.getVersionSpecificRegistry(ProtocolVersion.getLatestSupportedVersion()); - + private VersionSpecificRegistry _registry = + MainRegistry.getVersionSpecificRegistry(ProtocolVersion.getLatestSupportedVersion()); /** * No-arg constructor for use by test subclass - has to initialise final vars NOT intended for use other then for @@ -118,19 +121,20 @@ public class AMQProtocolSession implements AMQVersionAwareProtocolSession _minaProtocolSession = protocolSession; // properties of the connection are made available to the event handlers _minaProtocolSession.setAttribute(AMQ_CONNECTION, connection); - //fixme - real value needed + // fixme - real value needed _minaProtocolSession.setWriteTimeout(LAST_WRITE_FUTURE_JOIN_TIMEOUT); _stateManager = new AMQStateManager(this); } - public AMQProtocolSession(AMQProtocolHandler protocolHandler, IoSession protocolSession, AMQConnection connection, AMQStateManager stateManager) + public AMQProtocolSession(AMQProtocolHandler protocolHandler, IoSession protocolSession, AMQConnection connection, + AMQStateManager stateManager) { _protocolHandler = protocolHandler; _minaProtocolSession = protocolSession; _minaProtocolSession.setAttachment(this); // properties of the connection are made available to the event handlers _minaProtocolSession.setAttribute(AMQ_CONNECTION, connection); - //fixme - real value needed + // fixme - real value needed _minaProtocolSession.setWriteTimeout(LAST_WRITE_FUTURE_JOIN_TIMEOUT); _stateManager = stateManager; _stateManager.setProtocolSession(this); @@ -242,18 +246,20 @@ public class AMQProtocolSession implements AMQVersionAwareProtocolSession _channelId2UnprocessedMsgMap.put(message.getChannelId(), message); } - public void messageContentHeaderReceived(int channelId, ContentHeaderBody contentHeader) - throws AMQException + public void messageContentHeaderReceived(int channelId, ContentHeaderBody contentHeader) throws AMQException { UnprocessedMessage msg = (UnprocessedMessage) _channelId2UnprocessedMsgMap.get(channelId); if (msg == null) { throw new AMQException("Error: received content header without having received a BasicDeliver frame first"); } + if (msg.getContentHeader() != null) { - throw new AMQException("Error: received duplicate content header or did not receive correct number of content body frames"); + throw new AMQException( + "Error: received duplicate content header or did not receive correct number of content body frames"); } + msg.setContentHeader(contentHeader); if (contentHeader.bodySize == 0) { @@ -268,11 +274,13 @@ public class AMQProtocolSession implements AMQVersionAwareProtocolSession { throw new AMQException("Error: received content body without having received a JMSDeliver frame first"); } + if (msg.getContentHeader() == null) { _channelId2UnprocessedMsgMap.remove(channelId); throw new AMQException("Error: received content body without having received a ContentHeader frame first"); } + try { msg.receiveBody(contentBody); @@ -282,6 +290,7 @@ public class AMQProtocolSession implements AMQVersionAwareProtocolSession _channelId2UnprocessedMsgMap.remove(channelId); throw e; } + if (msg.isAllBodyDataReceived()) { deliverMessageToAMQSession(channelId, msg); @@ -317,7 +326,7 @@ public class AMQProtocolSession implements AMQVersionAwareProtocolSession WriteFuture f = _minaProtocolSession.write(frame); if (wait) { - //fixme -- time out? + // fixme -- time out? f.join(); } else @@ -332,10 +341,12 @@ public class AMQProtocolSession implements AMQVersionAwareProtocolSession { throw new IllegalArgumentException("Attempt to register a session with a channel id <= zero"); } + if (session == null) { throw new IllegalArgumentException("Attempt to register a null session"); } + _logger.debug("Add session with channel id " + channelId); _channelId2SessionMap.put(channelId, session); } @@ -346,6 +357,7 @@ public class AMQProtocolSession implements AMQVersionAwareProtocolSession { throw new IllegalArgumentException("Attempt to deregister a session with a channel id <= zero"); } + _logger.debug("Removing session with channelId " + channelId); _channelId2SessionMap.remove(channelId); } @@ -388,12 +400,13 @@ public class AMQProtocolSession implements AMQVersionAwareProtocolSession final AMQSession session = (AMQSession) _channelId2SessionMap.get(chId); try { - session.closed(new AMQException(_logger, code, text)); + session.closed(new AMQException(code, text)); } catch (JMSException e) { throw new AMQException("JMSException received while closing session", e); } + return true; } else @@ -415,7 +428,7 @@ public class AMQProtocolSession implements AMQVersionAwareProtocolSession public void closeProtocolSession(boolean waitLast) { _logger.debug("Waiting for last write to join."); - if (waitLast && _lastWriteFuture != null) + if (waitLast && (_lastWriteFuture != null)) { _lastWriteFuture.join(LAST_WRITE_FUTURE_JOIN_TIMEOUT); } @@ -437,8 +450,9 @@ public class AMQProtocolSession implements AMQVersionAwareProtocolSession { id = _queueId++; } - //get rid of / and : and ; from address for spec conformance + // get rid of / and : and ; from address for spec conformance String localAddress = StringUtils.replaceChars(_minaProtocolSession.getLocalAddress().toString(), "/;:", ""); + return new AMQShortString("tmp_" + localAddress + "_" + id); } diff --git a/qpid/java/common/src/main/java/org/apache/qpid/AMQException.java b/qpid/java/common/src/main/java/org/apache/qpid/AMQException.java index 0222fd9b4e..32c1e76a39 100644 --- a/qpid/java/common/src/main/java/org/apache/qpid/AMQException.java +++ b/qpid/java/common/src/main/java/org/apache/qpid/AMQException.java @@ -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 @@ -20,7 +20,6 @@ */ package org.apache.qpid; -import org.apache.log4j.Logger; import org.apache.qpid.protocol.AMQConstant; /** Generic AMQ exception. */ @@ -31,14 +30,14 @@ public class AMQException extends Exception public AMQException(String message) { super(message); - //fixme This method needs removed and all AMQExceptions need a valid error code + // fixme This method needs removed and all AMQExceptions need a valid error code _errorCode = AMQConstant.getConstant(-1); } public AMQException(String msg, Throwable t) { super(msg, t); - //fixme This method needs removed and all AMQExceptions need a valid error code + // fixme This method needs removed and all AMQExceptions need a valid error code _errorCode = AMQConstant.getConstant(-1); } @@ -54,24 +53,6 @@ public class AMQException extends Exception _errorCode = errorCode; } - public AMQException(Logger logger, String msg, Throwable t) - { - this(msg, t); - logger.error(getMessage(), this); - } - - public AMQException(Logger logger, String msg) - { - this(msg); - logger.error(getMessage(), this); - } - - public AMQException(Logger logger, AMQConstant errorCode, String msg) - { - this(errorCode, msg); - logger.error(getMessage(), this); - } - public AMQConstant getErrorCode() { return _errorCode; diff --git a/qpid/java/common/src/main/java/org/apache/qpid/configuration/PropertyException.java b/qpid/java/common/src/main/java/org/apache/qpid/configuration/PropertyException.java index 958f59191f..022e7b8a76 100644 --- a/qpid/java/common/src/main/java/org/apache/qpid/configuration/PropertyException.java +++ b/qpid/java/common/src/main/java/org/apache/qpid/configuration/PropertyException.java @@ -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 @@ -20,7 +20,6 @@ */ package org.apache.qpid.configuration; -import org.apache.log4j.Logger; import org.apache.qpid.AMQException; import org.apache.qpid.protocol.AMQConstant; @@ -48,19 +47,4 @@ public class PropertyException extends AMQException { super(errorCode, msg); } - - public PropertyException(Logger logger, String msg, Throwable t) - { - super(logger, msg, t); - } - - public PropertyException(Logger logger, String msg) - { - super(logger, msg); - } - - public PropertyException(Logger logger, AMQConstant errorCode, String msg) - { - super(logger, errorCode, msg); - } } diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQFrameDecodingException.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQFrameDecodingException.java index a24bd6aaa9..a3d4513240 100644 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQFrameDecodingException.java +++ b/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQFrameDecodingException.java @@ -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 @@ -20,7 +20,6 @@ */ package org.apache.qpid.framing; -import org.apache.log4j.Logger; import org.apache.qpid.AMQException; public class AMQFrameDecodingException extends AMQException @@ -34,15 +33,4 @@ public class AMQFrameDecodingException extends AMQException { super(message, t); } - - public AMQFrameDecodingException(Logger log, String message) - { - super(log, message); - } - - public AMQFrameDecodingException(Logger log, String message, Throwable t) - { - super(log, message, t); - } - } diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/VersionSpecificRegistry.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/VersionSpecificRegistry.java index ebe0b91cf4..085479f227 100644 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/VersionSpecificRegistry.java +++ b/qpid/java/common/src/main/java/org/apache/qpid/framing/VersionSpecificRegistry.java @@ -20,16 +20,16 @@ */
package org.apache.qpid.framing;
-import org.apache.qpid.framing.abstraction.ProtocolVersionMethodConverter;
-
import org.apache.log4j.Logger;
+
import org.apache.mina.common.ByteBuffer;
+import org.apache.qpid.framing.abstraction.ProtocolVersionMethodConverter;
+
public class VersionSpecificRegistry
{
private static final Logger _log = Logger.getLogger(VersionSpecificRegistry.class);
-
private final byte _protocolMajorVersion;
private final byte _protocolMinorVersion;
@@ -48,26 +48,31 @@ public class VersionSpecificRegistry _protocolVersionConverter = loadProtocolVersionConverters(major, minor);
}
- private static ProtocolVersionMethodConverter loadProtocolVersionConverters(byte protocolMajorVersion, byte protocolMinorVersion)
+ private static ProtocolVersionMethodConverter loadProtocolVersionConverters(byte protocolMajorVersion,
+ byte protocolMinorVersion)
{
try
{
Class<ProtocolVersionMethodConverter> versionMethodConverterClass =
- (Class<ProtocolVersionMethodConverter>) Class.forName("org.apache.qpid.framing.MethodConverter_"+protocolMajorVersion + "_" + protocolMinorVersion);
+ (Class<ProtocolVersionMethodConverter>) Class.forName("org.apache.qpid.framing.MethodConverter_"
+ + protocolMajorVersion + "_" + protocolMinorVersion);
+
return versionMethodConverterClass.newInstance();
}
catch (ClassNotFoundException e)
{
_log.warn("Could not find protocol conversion classes for " + protocolMajorVersion + "-" + protocolMinorVersion);
- if(protocolMinorVersion != 0)
+ if (protocolMinorVersion != 0)
{
protocolMinorVersion--;
+
return loadProtocolVersionConverters(protocolMajorVersion, protocolMinorVersion);
}
else if (protocolMajorVersion != 0)
{
protocolMajorVersion--;
+
return loadProtocolVersionConverters(protocolMajorVersion, protocolMinorVersion);
}
else
@@ -75,7 +80,6 @@ public class VersionSpecificRegistry return null;
}
-
}
catch (IllegalAccessException e)
{
@@ -83,7 +87,7 @@ public class VersionSpecificRegistry }
catch (InstantiationException e)
{
- throw new IllegalStateException("Unable to load protocol version converter: ", e);
+ throw new IllegalStateException("Unable to load protocol version converter: ", e);
}
}
@@ -115,73 +119,68 @@ public class VersionSpecificRegistry public void registerMethod(final short classID, final short methodID, final AMQMethodBodyInstanceFactory instanceFactory)
{
- if(_registry.length <= classID)
+ if (_registry.length <= classID)
{
AMQMethodBodyInstanceFactory[][] oldRegistry = _registry;
- _registry = new AMQMethodBodyInstanceFactory[classID+1][];
+ _registry = new AMQMethodBodyInstanceFactory[classID + 1][];
System.arraycopy(oldRegistry, 0, _registry, 0, oldRegistry.length);
}
- if(_registry[classID] == null)
+ if (_registry[classID] == null)
{
- _registry[classID] = new AMQMethodBodyInstanceFactory[methodID > DEFAULT_MAX_METHOD_ID ? methodID + 1 : DEFAULT_MAX_METHOD_ID + 1];
+ _registry[classID] =
+ new AMQMethodBodyInstanceFactory[(methodID > DEFAULT_MAX_METHOD_ID) ? (methodID + 1)
+ : (DEFAULT_MAX_METHOD_ID + 1)];
}
- else if(_registry[classID].length <= methodID)
+ else if (_registry[classID].length <= methodID)
{
AMQMethodBodyInstanceFactory[] oldMethods = _registry[classID];
- _registry[classID] = new AMQMethodBodyInstanceFactory[methodID+1];
- System.arraycopy(oldMethods,0,_registry[classID],0,oldMethods.length);
+ _registry[classID] = new AMQMethodBodyInstanceFactory[methodID + 1];
+ System.arraycopy(oldMethods, 0, _registry[classID], 0, oldMethods.length);
}
_registry[classID][methodID] = instanceFactory;
}
-
- public AMQMethodBody get(short classID, short methodID, ByteBuffer in, long size)
- throws AMQFrameDecodingException
+ public AMQMethodBody get(short classID, short methodID, ByteBuffer in, long size) throws AMQFrameDecodingException
{
AMQMethodBodyInstanceFactory bodyFactory;
try
{
bodyFactory = _registry[classID][methodID];
}
- catch(NullPointerException e)
+ 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("Class " + classID + " unknown in AMQP version " + _protocolMajorVersion
+ + "-" + _protocolMinorVersion + " (while trying to decode class " + classID + " method " + methodID + ".");
}
- catch(IndexOutOfBoundsException e)
+ catch (IndexOutOfBoundsException e)
{
- if(classID >= _registry.length)
+ 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("Class " + classID + " unknown in AMQP version " + _protocolMajorVersion
+ + "-" + _protocolMinorVersion + " (while trying to decode class " + classID + " method " + methodID
+ + ".");
}
else
{
- throw new AMQFrameDecodingException(_log,
- "Method " + methodID + " unknown in AMQP version " + _protocolMajorVersion + "-" + _protocolMinorVersion
- + " (while trying to decode class " + classID + " method " + methodID + ".");
+ throw new AMQFrameDecodingException("Method " + methodID + " unknown in AMQP version "
+ + _protocolMajorVersion + "-" + _protocolMinorVersion + " (while trying to decode class " + classID
+ + " method " + methodID + ".");
}
}
-
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("Method " + methodID + " unknown in AMQP version " + _protocolMajorVersion
+ + "-" + _protocolMinorVersion + " (while trying to decode class " + classID + " method " + methodID + ".");
}
-
return bodyFactory.newInstance(in, size);
-
}
public ProtocolVersionMethodConverter getProtocolVersionMethodConverter()
|