From 3fa59ae052adc930209ff47e3223262a03f12ccc Mon Sep 17 00:00:00 2001 From: Alex Rudyy Date: Tue, 31 Mar 2015 08:22:10 +0000 Subject: QPID-6469: Remove content of AMQProtocolEngine#exception as it is not used in new i/o layer git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1670271 13f79535-47bb-0310-9956-ffa450edef68 --- .../server/protocol/v0_8/AMQProtocolEngine.java | 46 +--------- .../protocol/v0_8/AMQProtocolEngineTest.java | 98 ---------------------- 2 files changed, 1 insertion(+), 143 deletions(-) (limited to 'qpid/java') diff --git a/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQProtocolEngine.java b/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQProtocolEngine.java index 2cdb425bb5..2178b4f6f3 100644 --- a/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQProtocolEngine.java +++ b/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQProtocolEngine.java @@ -1158,51 +1158,7 @@ public class AMQProtocolEngine implements ServerProtocolEngine, public void exception(Throwable throwable) { - if (throwable instanceof AMQProtocolHeaderException) - { - sendResponseAndCloseSender(new ProtocolInitiation(ProtocolVersion.getLatestSupportedVersion())); - - _logger.error("Error in protocol initiation " + this + ":" + getRemoteAddress() + " :" + throwable.getMessage(), throwable); - } - else if (throwable instanceof IOException) - { - _logger.info("IOException caught in " + this + ", connection closed implicitly: " + throwable); - } - else - { - try - { - _logger.error("Exception caught in " + this + ", closing connection explicitly: " + throwable, throwable); - - ConnectionCloseBody closeBody = _methodRegistry.createConnectionCloseBody(AMQConstant.INTERNAL_ERROR.getCode(), - AMQShortString.validValueOf( - throwable.getMessage()), - _currentClassId, - _currentMethodId); - sendResponseAndCloseSender(closeBody.generateFrame(0)); - } - finally - { - if (!(throwable instanceof TransportException - || throwable instanceof ConnectionScopedRuntimeException)) - { - if (throwable instanceof Error) - { - throw (Error) throwable; - } - - if (throwable instanceof RuntimeException) - { - throw (RuntimeException) throwable; - } - - if (throwable instanceof Throwable) - { - throw new ServerScopedRuntimeException("Unexpected exception", throwable); - } - } - } - } + // noop - exception method is not used by new i/o layer } private void sendResponseAndCloseSender(AMQDataBlock dataBlock) diff --git a/qpid/java/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/AMQProtocolEngineTest.java b/qpid/java/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/AMQProtocolEngineTest.java index 9121600dcd..cc5da731b8 100644 --- a/qpid/java/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/AMQProtocolEngineTest.java +++ b/qpid/java/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/AMQProtocolEngineTest.java @@ -103,102 +103,4 @@ public class AMQProtocolEngineTest extends QpidTestCase assertFalse("Unexpected closeWhenNoRoute after client properties set", engine.isCloseWhenNoRoute()); } - public void testThrownExceptionOnSendingResponseFromExceptionHandler() - { - ByteBufferSender sender = mock(ByteBufferSender.class); - when(_network.getSender()).thenReturn(sender); - doThrow(new SenderException("exception on close")).when(sender).close(); - doThrow(new SenderException("exception on send")).when(sender).send(any(ByteBuffer.class)); - - AMQProtocolEngine engine = new AMQProtocolEngine(_broker, _network, 0, _port, _transport); - - try - { - engine.exception(new ConnectionScopedRuntimeException("test")); - } - catch (Exception e) - { - fail("Unexpected exception is thrown " + e); - } - - doThrow(new NullPointerException("unexpected exception")).when(sender).send(any(ByteBuffer.class)); - try - { - engine.exception(new ConnectionScopedRuntimeException("test")); - fail("Unexpected exception should be reported"); - } - catch (NullPointerException e) - { - // pass - } - - } - - public void testExceptionHandling() - { - ByteBufferSender sender = mock(ByteBufferSender.class); - when(_network.getSender()).thenReturn(sender); - - AMQProtocolEngine engine = new AMQProtocolEngine(_broker, _network, 0, _port, _transport); - - try - { - engine.exception(new ConnectionScopedRuntimeException("test")); - } - catch (Exception e) - { - fail("Unexpected exception is thrown " + e); - } - - - try - { - engine.exception(new SenderException("test")); - } - catch (NullPointerException e) - { - fail("Unexpected exception should be reported"); - } - - try - { - engine.exception(new NullPointerException("test")); - fail("NullPointerException should be re-thrown"); - } - catch (NullPointerException e) - { - //pass - } - - try - { - engine.exception(new ServerScopedRuntimeException("test")); - fail("ServerScopedRuntimeException should be re-thrown"); - } - catch (ServerScopedRuntimeException e) - { - //pass - } - - try - { - engine.exception(new AMQException(AMQConstant.INTERNAL_ERROR, "test")); - fail("AMQException should be re-thrown as ServerScopedRuntimeException"); - } - catch (ServerScopedRuntimeException e) - { - //pass - } - - try - { - engine.exception(new Error("test")); - fail("Error should be re-thrown"); - } - catch (Error e) - { - //pass - } - } - } -- cgit v1.2.1