diff options
author | Robert Gemmell <robbie@apache.org> | 2011-09-25 23:26:50 +0000 |
---|---|---|
committer | Robert Gemmell <robbie@apache.org> | 2011-09-25 23:26:50 +0000 |
commit | 12a7ad9d818f2793ad8708f2ee3d64b5e8d4b3a7 (patch) | |
tree | 7b57e66e0187bd90dbca84c4e13226dc4d902392 | |
parent | 5a9efa793cab32e8341387c2d9b509502aea3612 (diff) | |
download | qpid-python-12a7ad9d818f2793ad8708f2ee3d64b5e8d4b3a7.tar.gz |
QPID-3444: issue an invalid argument execution exception if the exchange name is null or the empty string. Update some constants to ensure the error code is logged with the correct message
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1175625 13f79535-47bb-0310-9956-ffa450edef68
6 files changed, 26 insertions, 16 deletions
diff --git a/java/broker/src/main/java/org/apache/qpid/server/handler/BasicConsumeMethodHandler.java b/java/broker/src/main/java/org/apache/qpid/server/handler/BasicConsumeMethodHandler.java index a5999711bc..765dee2878 100644 --- a/java/broker/src/main/java/org/apache/qpid/server/handler/BasicConsumeMethodHandler.java +++ b/java/broker/src/main/java/org/apache/qpid/server/handler/BasicConsumeMethodHandler.java @@ -144,7 +144,7 @@ public class BasicConsumeMethodHandler implements StateAwareMethodListener<Basic _logger.debug("Closing connection due to invalid selector"); MethodRegistry methodRegistry = protocolConnection.getMethodRegistry(); - AMQMethodBody responseBody = methodRegistry.createChannelCloseBody(AMQConstant.INVALID_ARGUMENT.getCode(), + AMQMethodBody responseBody = methodRegistry.createChannelCloseBody(AMQConstant.ARGUMENT_INVALID.getCode(), new AMQShortString(ise.getMessage()), body.getClazz(), body.getMethod()); diff --git a/java/broker/src/main/java/org/apache/qpid/server/transport/ServerSessionDelegate.java b/java/broker/src/main/java/org/apache/qpid/server/transport/ServerSessionDelegate.java index 22760318b5..17bd06538f 100644 --- a/java/broker/src/main/java/org/apache/qpid/server/transport/ServerSessionDelegate.java +++ b/java/broker/src/main/java/org/apache/qpid/server/transport/ServerSessionDelegate.java @@ -606,6 +606,12 @@ public class ServerSessionDelegate extends SessionDelegate try { + if (nameNullOrEmpty(method.getExchange())) + { + exception(session, method, ExecutionErrorCode.INVALID_ARGUMENT, "Delete not allowed for default exchange"); + return; + } + Exchange exchange = getExchange(session, method.getExchange()); if(exchange == null) @@ -641,6 +647,16 @@ public class ServerSessionDelegate extends SessionDelegate } } + private boolean nameNullOrEmpty(String name) + { + if(name == null || name.length() == 0) + { + return true; + } + + return false; + } + private boolean isStandardExchange(Exchange exchange, Collection<ExchangeType<? extends Exchange>> registeredTypes) { for(ExchangeType type : registeredTypes) @@ -687,9 +703,9 @@ public class ServerSessionDelegate extends SessionDelegate { exception(session, method, ExecutionErrorCode.ILLEGAL_ARGUMENT, "queue not set"); } - else if (!method.hasExchange()) + else if (nameNullOrEmpty(method.getExchange())) { - exception(session, method, ExecutionErrorCode.ILLEGAL_ARGUMENT, "exchange not set"); + exception(session, method, ExecutionErrorCode.INVALID_ARGUMENT, "Bind not allowed for default exchange"); } /* else if (!method.hasBindingKey()) @@ -758,9 +774,9 @@ public class ServerSessionDelegate extends SessionDelegate { exception(session, method, ExecutionErrorCode.ILLEGAL_ARGUMENT, "queue not set"); } - else if (!method.hasExchange()) + else if (nameNullOrEmpty(method.getExchange())) { - exception(session, method, ExecutionErrorCode.ILLEGAL_ARGUMENT, "exchange not set"); + exception(session, method, ExecutionErrorCode.INVALID_ARGUMENT, "Unbind not allowed for default exchange"); } else if (!method.hasBindingKey()) { @@ -790,9 +806,6 @@ public class ServerSessionDelegate extends SessionDelegate } } } - - - super.exchangeUnbind(session, method); } @Override diff --git a/java/client/src/main/java/org/apache/qpid/client/handler/ChannelCloseMethodHandler.java b/java/client/src/main/java/org/apache/qpid/client/handler/ChannelCloseMethodHandler.java index 2cf19bf391..b9d4d6fa95 100644 --- a/java/client/src/main/java/org/apache/qpid/client/handler/ChannelCloseMethodHandler.java +++ b/java/client/src/main/java/org/apache/qpid/client/handler/ChannelCloseMethodHandler.java @@ -78,7 +78,7 @@ public class ChannelCloseMethodHandler implements StateAwareMethodListener<Chann { throw new AMQNoRouteException("Error: " + reason, null, null); } - else if (errorCode == AMQConstant.INVALID_ARGUMENT) + else if (errorCode == AMQConstant.ARGUMENT_INVALID) { _logger.debug("Broker responded with Invalid Argument."); diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/client/channelclose/ChannelCloseMethodHandlerNoCloseOk.java b/java/client/src/test/java/org/apache/qpid/test/unit/client/channelclose/ChannelCloseMethodHandlerNoCloseOk.java index 66f220643c..d560c413e6 100644 --- a/java/client/src/test/java/org/apache/qpid/test/unit/client/channelclose/ChannelCloseMethodHandlerNoCloseOk.java +++ b/java/client/src/test/java/org/apache/qpid/test/unit/client/channelclose/ChannelCloseMethodHandlerNoCloseOk.java @@ -73,7 +73,7 @@ public class ChannelCloseMethodHandlerNoCloseOk implements StateAwareMethodListe { throw new AMQNoRouteException("Error: " + reason, null, null); } - else if (errorCode == AMQConstant.INVALID_ARGUMENT) + else if (errorCode == AMQConstant.ARGUMENT_INVALID) { _logger.debug("Broker responded with Invalid Argument."); diff --git a/java/common/src/main/java/org/apache/qpid/AMQInvalidArgumentException.java b/java/common/src/main/java/org/apache/qpid/AMQInvalidArgumentException.java index baca2a4773..2bbaaef1fc 100644 --- a/java/common/src/main/java/org/apache/qpid/AMQInvalidArgumentException.java +++ b/java/common/src/main/java/org/apache/qpid/AMQInvalidArgumentException.java @@ -34,7 +34,7 @@ public class AMQInvalidArgumentException extends AMQException { public AMQInvalidArgumentException(String message, Throwable cause) { - super(AMQConstant.INVALID_ARGUMENT, message, cause); + super(AMQConstant.ARGUMENT_INVALID, message, cause); } public boolean isHardError() diff --git a/java/common/src/main/java/org/apache/qpid/protocol/AMQConstant.java b/java/common/src/main/java/org/apache/qpid/protocol/AMQConstant.java index f9f6ca8444..14d1befaf1 100644 --- a/java/common/src/main/java/org/apache/qpid/protocol/AMQConstant.java +++ b/java/common/src/main/java/org/apache/qpid/protocol/AMQConstant.java @@ -104,7 +104,7 @@ public final class AMQConstant public static final AMQConstant REQUEST_TIMEOUT = new AMQConstant(408, "Request Timeout", true); - public static final AMQConstant INVALID_ARGUMENT = new AMQConstant(409, "argument invalid", true); + public static final AMQConstant ARGUMENT_INVALID = new AMQConstant(409, "argument invalid", true); /** * The client sent a malformed frame that the server could not decode. This strongly implies a programming error @@ -153,10 +153,7 @@ public final class AMQConstant public static final AMQConstant FRAME_MIN_SIZE = new AMQConstant(4096, "frame min size", true); - /** - * The server does not support the protocol version - */ - public static final AMQConstant UNSUPPORTED_BROKER_PROTOCOL_ERROR = new AMQConstant(542, "broker unsupported protocol", true); + public static final AMQConstant INVALID_ARGUMENT = new AMQConstant(542, "invalid argument", true); /** * The client imp does not support the protocol version */ |