ham1 opened a new issue, #2908:
URL: https://github.com/apache/activemq/issues/2908

   Since 6.2.5 (#1910), a broker created from an `xbean:file:` URI whose path 
contains a space fails to start:
   
   ```java
   BrokerFactory.createBroker("xbean:file:/tmp/a%20b/activemq.xml", true);
   ```
   
   ```
   java.net.MalformedURLException: file:/tmp/a b/activemq.xml
   Caused by: java.net.URISyntaxException: Illegal character in path at index 
11: file:/tmp/a b/activemq.xml
   ```
   
   Seen with 6.3.2. `Utils` is the same in 6.2.5 - 6.4.0 and on main, so they 
should all be affected. 6.2.4 does not have the check.
   
   What happens:
   1. `XBeanBrokerFactory.createBroker(URI)` takes `getSchemeSpecificPart()`, 
which decodes `%20` to a space.
   2. `Utils.resourceFromString` gets `file:/tmp/a b/activemq.xml`. Because of 
the `file:` prefix it is not found by `new File(uri).exists()`, so it goes to 
the URL branch.
   3. `validateUrlAllowed` -> `getProtocolFromScheme` calls `new 
URI(uriString)` on the decoded string, which throws on the space.
   
   The same happens for any character that is not legal in a URI once decoded, 
such as `%` (written as `%25`).
   
   Calling `Utils.resourceFromString` directly with an existing file at `/tmp/a 
b/x.xml`:
   
   | input | default protocols (`file,classpath`) | `*` |
   |---|---|---|
   | `file:/tmp/a b/x.xml` | URISyntaxException | loads |
   | `/tmp/a b/x.xml` | loads | loads |
   
   Workarounds:
   - leave out `file:` and use the path, for example 
`xbean:/tmp/a%20b/activemq.xml`, so it is found as a file before the URL check
   - `-Dorg.apache.activemq.xbean.XBEAN_BROKER_FACTORY_PROTOCOLS=*`, which 
skips the check, but also allows every protocol again
   
   A possible fix could be to get the scheme in `getProtocolFromScheme` without 
parsing the decoded string as a URI, for example with `ResourceUtils.toURI` 
(which encodes spaces) or `new URL(uriString).getProtocol()`, while keeping the 
remote file check from #1950.
   
   Found in the Apache JMeter build, whose CI workspace path has a space 
(apache/jmeter#6874).
   
   Generated-by: claude-opus-5-5
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information, visit: https://activemq.apache.org/contact


Reply via email to