Bug 876193

Summary: No exception on creating already existing broker object (but declaring it as different type)
Product: Red Hat Enterprise MRG Reporter: Petr Matousek <pematous>
Component: qpid-javaAssignee: Rajith Attapattu <rattapat+nobody>
Status: CLOSED ERRATA QA Contact: Petr Matousek <pematous>
Severity: medium Docs Contact:
Priority: medium    
Version: DevelopmentCC: esammons, iboverma, jross, lzhaldyb, mcressma
Target Milestone: 2.3Keywords: Regression
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: qpid-java-0.18-6 Doc Type: Bug Fix
Doc Text:
Cause: Incorrect error handling causes the addressing code to ignore this issues. Consequence: The application does not get notified that an exchange of a different type with the same name exists. Fix: Fixed the error handling code to pass the error through to the application. Result: An error is thrown when creating an exchange (with the same name) that already exists but has a different type. (Ex requested direct, but a topic exchange exists by the same name)
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-03-06 18:52:45 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Petr Matousek 2012-11-13 14:26:36 UTC
Description of problem:

An exception was thrown (ie. not-allowed: Exchange declared to be of type topic, requested fanout.. see additional info for more details) when trying to create broker object and the object is already existing but was declared as a different type.

Starting from qpid-java-*-0.18-4 no Exception is thrown and messages are delivered to the existing object.

Version-Release number of selected component (if applicable):
qpid-java-*-0.18-4 and later

How reproducible:
100%

Steps to Reproduce:
1. java -cp ${CLASSPATH} org.apache.qpid.example.Spout "ex;{create:sender, node: {type:topic,x-declare:{type:topic}}}"
2. java -cp ${CLASSPATH} org.apache.qpid.example.Spout "ex;{create:sender, node: {type:topic,x-declare:{type:fanout}}}"
3. No exception
4. qpid-stat -e (both the messages were delivered to the topic exchange declared in step 1.)
  
Actual results:
no error message, message is delivered to the address even if the address properties differs

Expected results:
An error message is printed on creating already existing broker object and the existing object is declared as different type 

Additional info:
# rpm -qa | grep qpid-java
qpid-java-common-0.18-2.el5
qpid-java-example-0.18-2.el5
qpid-java-client-0.18-2.el5
# ./run_example.sh org.apache.qpid.example.Spout "ex726100;{ create:sender,assert:sender, node: { type:topic,x-declare:{type:topic} }, link: {  } }"
{}
</snip>
# ./run_example.sh org.apache.qpid.example.Spout "ex726100;{ create:sender, node: { type:topic,x-declare:{type:fanout} }, link: {  } }"
{}
IoReceiver - localhost/127.0.0.1:5672 2012-11-13 11:17:34,959 ERROR [apache.qpid.client.AMQConnection] Throwable Received but no listener set: org.apache.qpid.AMQException: ch=0 id=1 ExecutionException(errorCode=NOT_ALLOWED, commandId=1, classCode=7, commandCode=1, fieldIndex=0, description=not-allowed: Exchange declared to be of type topic, requested fanout (qpid/broker/SessionAdapter.cpp:125), errorInfo={}) [error code 530: not allowed]
main 2012-11-13 11:17:34,976 ERROR [apache.qpid.client.AMQConnection] Throwable Received but no listener set: org.apache.qpid.AMQException: ch=0 id=1 ExecutionException(errorCode=NOT_ALLOWED, commandId=1, classCode=7, commandCode=1, fieldIndex=0, description=not-allowed: Exchange declared to be of type topic, requested fanout (qpid/broker/SessionAdapter.cpp:125), errorInfo={}) [error code 530: not allowed]
Exception in thread "main" javax.jms.JMSException: Error creating producer
	at org.apache.qpid.client.AMQSession_0_10.createMessageProducer(AMQSession_0_10.java:660)
	at org.apache.qpid.client.AMQSession_0_10.createMessageProducer(AMQSession_0_10.java:67)
	at org.apache.qpid.client.AMQSession$7.execute(AMQSession.java:2633)
	at org.apache.qpid.client.AMQSession$7.execute(AMQSession.java:2624)
	at org.apache.qpid.client.AMQConnectionDelegate_0_10.executeRetrySupport(AMQConnectionDelegate_0_10.java:369)
	at org.apache.qpid.client.AMQConnection.executeRetrySupport(AMQConnection.java:593)
	at org.apache.qpid.client.failover.FailoverRetrySupport.execute(FailoverRetrySupport.java:102)
	at org.apache.qpid.client.AMQSession.createProducerImpl(AMQSession.java:2622)
	at org.apache.qpid.client.AMQSession.createProducer(AMQSession.java:1201)
	at org.apache.qpid.client.AMQSession.createProducer(AMQSession.java:102)
	at org.apache.qpid.example.Spout.<init>(Spout.java:91)
	at org.apache.qpid.example.Spout.main(Spout.java:146)
Caused by: org.apache.qpid.AMQException: Exception occured while verifying destination
	at org.apache.qpid.client.BasicMessageProducer_0_10.declareDestination(BasicMessageProducer_0_10.java:93)
	at org.apache.qpid.client.BasicMessageProducer.<init>(BasicMessageProducer.java:151)
	at org.apache.qpid.client.BasicMessageProducer_0_10.<init>(BasicMessageProducer_0_10.java:66)
	at org.apache.qpid.client.AMQSession_0_10.createMessageProducer(AMQSession_0_10.java:655)
	... 11 more
Caused by: org.apache.qpid.AMQException: ch=0 id=1 ExecutionException(errorCode=NOT_ALLOWED, commandId=1, classCode=7, commandCode=1, fieldIndex=0, description=not-allowed: Exchange declared to be of type topic, requested fanout (qpid/broker/SessionAdapter.cpp:125), errorInfo={}) [error code 530: not allowed]
	at org.apache.qpid.client.AMQSession_0_10.setCurrentException(AMQSession_0_10.java:1051)
	at org.apache.qpid.client.AMQSession_0_10.sync(AMQSession_0_10.java:1031)
	at org.apache.qpid.client.AMQSession_0_10.sendExchangeDeclare(AMQSession_0_10.java:699)
	at org.apache.qpid.client.AMQSession_0_10.handleAddressBasedDestination(AMQSession_0_10.java:1243)
	at org.apache.qpid.client.BasicMessageProducer_0_10.declareDestination(BasicMessageProducer_0_10.java:89)
	... 14 more

Comment 2 Rajith Attapattu 2012-12-07 23:01:16 UTC
This issue is tracked upstream via QPID-4497

A fix is committed upstream at http://svn.apache.org/viewvc?rev=1418539&view=rev

Comment 3 Rajith Attapattu 2012-12-11 18:57:47 UTC
I have made a mistake in the above comment. The correct JIRA is QPID-4496

It's best to port http://svn.apache.org/viewvc?rev=1419708&view=rev as it fixes a typo in the error message.

Alternatively you could manually fix the typo when porting the commit mentioned in the previous comment.

Rajith

Comment 5 Petr Matousek 2012-12-14 14:31:49 UTC
This issue has been fixed.

Verified on rhel5.9 and rhel6.3 (x86_64, i386)

packages used for testing:
qpid-java-*-0.18-6

-> VERIFIED

Comment 7 errata-xmlrpc 2013-03-06 18:52:45 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHSA-2013-0561.html