diff options
author | Keith Wall <kwall@apache.org> | 2012-08-08 22:07:10 +0000 |
---|---|---|
committer | Keith Wall <kwall@apache.org> | 2012-08-08 22:07:10 +0000 |
commit | ac2f0e12ac68372487128f97961f6919bfe2ece5 (patch) | |
tree | 60b3e28ec4aec434d7d503f01d037e19661253a5 | |
parent | 1f1e4b3168588648e8ee341e763250350d2be0cb (diff) | |
download | qpid-python-ac2f0e12ac68372487128f97961f6919bfe2ece5.tar.gz |
QPID-4162: Change Java Client/Java Broker to send a session.detached in response to receiving unexpected control on detached transport, as required by AMQP 0-10 spec. The previous behaviour (throwing a ProtocolViolationException) was causing sporadic test failures on a number of CI instances for both Java and Python tests.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1370991 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | qpid/java/common/src/main/java/org/apache/qpid/transport/Connection.java | 26 | ||||
-rw-r--r-- | qpid/java/common/src/main/java/org/apache/qpid/transport/ProtocolViolationException.java | 35 |
2 files changed, 21 insertions, 40 deletions
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/Connection.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/Connection.java index 388e3442bf..e87851cf7d 100644 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/Connection.java +++ b/qpid/java/common/src/main/java/org/apache/qpid/transport/Connection.java @@ -382,7 +382,7 @@ public class Connection extends ConnectionInvoker { log.debug("SEND: [%s] %s", this, event); } - Sender s = sender; + Sender<ProtocolEvent> s = sender; if (s == null) { throw new ConnectionException("connection closed"); @@ -415,15 +415,23 @@ public class Connection extends ConnectionInvoker public void dispatch(Method method) { - Session ssn = getSession(method.getChannel()); + int channel = method.getChannel(); + Session ssn = getSession(channel); if(ssn != null) { ssn.received(method); } else { - throw new ProtocolViolationException( - "Received frames for an already detached session", null); + /* + * A peer receiving any other control on a detached transport MUST discard it and + * send a session.detached with the "not-attached" reason code. + */ + if(log.isDebugEnabled()) + { + log.debug("Control received on unattached channel : %d", channel); + } + invokeSessionDetached(channel, SessionDetachCode.NOT_ATTACHED); } } @@ -663,7 +671,7 @@ public class Connection extends ConnectionInvoker public void setServerProperties(final Map<String, Object> serverProperties) { - _serverProperties = serverProperties == null ? Collections.EMPTY_MAP : serverProperties; + _serverProperties = serverProperties == null ? Collections.<String, Object>emptyMap() : serverProperties; } public Map<String, Object> getServerProperties() @@ -719,4 +727,12 @@ public class Connection extends ConnectionInvoker { return _localAddress; } + + private void invokeSessionDetached(int channel, SessionDetachCode sessionDetachCode) + { + SessionDetached sessionDetached = new SessionDetached(); + sessionDetached.setChannel(channel); + sessionDetached.setCode(sessionDetachCode); + invoke(sessionDetached); + } } diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/ProtocolViolationException.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/ProtocolViolationException.java deleted file mode 100644 index 6787157e8e..0000000000 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/ProtocolViolationException.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * 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 - * regarding copyright ownership. The ASF licenses this file - * 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.transport; - - -/** - * ProtocolViolationException - * - */ - -public final class ProtocolViolationException extends ConnectionException -{ - public ProtocolViolationException(String msg,Throwable cause) - { - super(msg, cause); - } -} |