Details
-
Improvement
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
0.10
-
None
Description
Description of problem:
When JNDI file has a typo, InitialContext(properties) method should raise some
parsing exception to let client program know about the parsing problem.
Currently the exception is swallowed in
PropertiesFileInitialContextFactory.createDestination method, writing to stdout
the exception stack trace only.
How reproducible:
100%
Steps to Reproduce:
1. Run the attached program with the attached MRG.jms.properties
2. In the output, distinguish between stdout and stderr
Actual results:
stdout contains:
WARN [main] (PropertiesFileInitialContextFactory.java:244) - Unable to create
destination:org.apache.qpid.messaging.util.ParseError: expecting LBRACE, got
EOF line:1,7:queue2;
org.apache.qpid.messaging.util.ParseError: expecting LBRACE, got EOF
line:1,7:queue2;
at org.apache.qpid.messaging.util.Parser.eat(Parser.java:65)
at org.apache.qpid.messaging.util.AddressParser.map(AddressParser.java:282)
at
org.apache.qpid.messaging.util.AddressParser.address(AddressParser.java:270)
at org.apache.qpid.messaging.util.AddressParser.parse(AddressParser.java:241)
at org.apache.qpid.messaging.Address.parse(Address.java:40)
at
org.apache.qpid.client.AMQDestination.createAddressFromString(AMQDestination.java:855)
at
org.apache.qpid.client.AMQDestination.createDestination(AMQDestination.java:696)
at
org.apache.qpid.jndi.PropertiesFileInitialContextFactory.createDestination(PropertiesFileInitialContextFactory.java:240)
at
org.apache.qpid.jndi.PropertiesFileInitialContextFactory.createDestinations(PropertiesFileInitialContextFactory.java:160)
at
org.apache.qpid.jndi.PropertiesFileInitialContextFactory.getInitialContext(PropertiesFileInitialContextFactory.java:117)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
at javax.naming.InitialContext.init(InitialContext.java:223)
at javax.naming.InitialContext.<init>(InitialContext.java:197)
at JNDIError.runTest(JNDIError.java:19)
at JNDIError.main(JNDIError.java:12)
stderr contains:
javax.naming.NameNotFoundException: my-queue
at org.apache.qpid.jndi.ReadOnlyContext.lookup(ReadOnlyContext.java:271)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at JNDIError.runTest(JNDIError.java:20)
at JNDIError.main(JNDIError.java:12)
Expected results:
program execution is interrupted by (laterly caught exception) even on
line:
Context context = new InitialContext(properties);
due to parsing error
stderr contains the org.apache.qpid.messaging.util.ParseError exception,
not javax.naming.NameNotFoundException
Additional info:
The requirement makes sense as now only some error log is printed to stdout
(not catch-able by the Java client program). While the API should warn the
application directly using catch-able exception that the parsing went wrong
(and some destination / topic / whatever can't be used in the program later
on).