[GLASSFISH-18819] Glassfish/mq dosen't work normally after setting the port of mq broker into "0" Created: 22/Jun/12  Updated: 19/Sep/14  Resolved: 09/Jul/13

Status: Resolved
Project: glassfish
Component/s: jms
Affects Version/s: 4.0_b41
Fix Version/s: 4.1

Type: Improvement Priority: Major
Reporter: Jeremy_Lv Assignee: David Zhao
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Windows Xp


Attachments: Java Source File Broker.java    

 Description   

[Bug Description]
Glassfish/mq dosen't work normally after setting the port of mq broker into "0"

[Operations]
1、Setting the port of mq broker by executing "%GF_HOME%\mq\bin\imqbrokerd -port 0"
Note:%GF_HOME% is Glassfish v4 Install Directory.

2、After executing "%GF_HOME%\mq\bin\imqcmd list svc -b localhost:0", the following error
message appeared.

----------------------------------------------------------------------------
Warming: [C4003]: Error occurred on connection creation [localhost:0]. - cause: jav
a.net.ConnectException: connect: Address is invalid on local machine, or port is
not valid on remote machine
Error while connecting to the broker on host 'localhost' and port '0'.
com.sun.messaging.jms.JMSException: [C4003]: Error occurred on connection creati
on [localhost:0]. - cause: java.net.ConnectException: connect: Address is invali
d on local machine, or port is not valid on remote machine
Please verify that there is a broker running on the specified host and port or
use the '-b' option to specify the correct broker host and port.
----------------------------------------------------------------------------

[My Suggestion]
I think that firstly, mq should not allow setting the port of mq broker as "0", secondly,when user
sets the port of mq broker as "0", mq should give a error message, for example,

"[B4027]: Invalid property value: port=0" in the admin-console

[Affected versions ]
1 4.0_b42
2 gf's trunk until 2012/06/21



 Comments   
Comment by Jeremy_Lv [ 22/Jun/12 ]

This issue is occurred in glassfish v4.0_b41,however, it's related to the component of mq.
The revised the code as follows:

[Source Directory]
mq-broker\broker-core\src\main\java\com\sun\messaging\jmq\jmsserver\Broker.java

[Diff]
mq-broker\broker-core\src\main\java\com\sun\messaging\jmq\jmsserver\Broker.java
===================================================================
@@ -1486,13 +1486,20 @@

  • if (++n >= args.length)
    + if (++n >= args.length)
    throw new IllegalArgumentException("missing port");
    + try { + checkCmdPortValue( args[n] ); + }

    + catch ( IllegalArgumentException e )

    { + printErr( e.getMessage() ); + throw e; + }

@@ -2317,4 +2324,19 @@
"#topic.create.allow.user=*\n" +
"##############################################\n";
+
+ private void checkCmdPortValue( String p ) {
+ // port range check
+ if ( p != null ) {
+ try {
+ int port = Integer.parseInt(p);
+ if ( ( port <= 0 ) || ( 65535 < port ) )

{ + throw new IllegalArgumentException( rb.getKString(rb.X_BAD_PROPERTY_VALUE, "port=" + p)); + }

+ } catch (NumberFormatException e)

{ + throw new IllegalArgumentException( rb.getKString(rb.X_BAD_PROPERTY_VALUE, "port=" + p)); + }

+ }
+ }
+

[Revised Version]
<mq.version>5.0-002</mq.version>

I have uploaded my revised java file to the attachment.

Comment by TangYong [ 22/Jun/12 ]

Now, mq trunk source seemed not to be checkouted , I also want to know how to checkout the mq trunk source nowaday.

Comment by David Zhao [ 09/Jul/13 ]

Created MQ-321 for it because it is MQ issue instead of GlassFish issue.

Generated at Fri Jul 31 01:02:53 UTC 2015 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.