Author: kwall
Date: Wed Aug 8 22:07:10 2012
New Revision: 1370991
URL: http://svn.apache.org/viewvc?rev=1370991&view=rev
Log:
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.
Removed:
qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/transport/ProtocolViolationException.java
Modified:
qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/transport/Connection.java
Modified:
qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/transport/Connection.java
URL:
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/transport/Connection.java?rev=1370991&r1=1370990&r2=1370991&view=diff
==============================================================================
---
qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/transport/Connection.java
(original)
+++
qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/transport/Connection.java
Wed Aug 8 22:07:10 2012
@@ -382,7 +382,7 @@ public class Connection extends Connecti
{
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 Connecti
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 Connecti
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 Connecti
{
return _localAddress;
}
+
+ private void invokeSessionDetached(int channel, SessionDetachCode
sessionDetachCode)
+ {
+ SessionDetached sessionDetached = new SessionDetached();
+ sessionDetached.setChannel(channel);
+ sessionDetached.setCode(sessionDetachCode);
+ invoke(sessionDetached);
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]