{"record":{"id":"29f3835029356ee8","repo":"flowable/flowable-engine","slug":"path-can-not-be-null-or-empty-syntax","errorCode":null,"errorMessage":"Path can not be null or empty. Syntax: ","messagePattern":"Path can not be null or empty\\. Syntax: ","errorType":"exception","errorClass":"MalformedURLException","httpStatus":null,"severity":"error","filePath":"modules/flowable-osgi/src/main/java/org/flowable/osgi/BarURLHandler.java","lineNumber":50,"sourceCode":"    private static final Logger LOGGER = LoggerFactory.getLogger(BarURLHandler.class);\n\n    private static final String SYNTAX = \"bar: bar-xml-uri\";\n\n    private URL barXmlURL;\n\n    /**\n     * Open the connection for the given URL.\n     * \n     * @param url\n     *            the url from which to open a connection.\n     * @return a connection on the specified URL.\n     * @throws IOException\n     *             if an error occurs or if the URL is malformed.\n     */\n    @Override\n    public URLConnection openConnection(URL url) throws IOException {\n        if (url.getPath() == null || url.getPath().trim().length() == 0) {\n            throw new MalformedURLException(\"Path can not be null or empty. Syntax: \" + SYNTAX);\n        }\n        barXmlURL = new URL(url.getPath());\n\n        LOGGER.debug(\"bar xml URL is: [{}]\", barXmlURL);\n        return new Connection(url);\n    }\n\n    public URL getBarXmlURL() {\n        return barXmlURL;\n    }\n\n    public class Connection extends URLConnection {\n\n        public Connection(URL url) {\n            super(url);\n        }\n\n        @Override","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-osgi/src/main/java/org/flowable/osgi/BarURLHandler.java#L32-L68","documentation":"The Flowable OSGi BAR URL handler (bar:) requires the URL path to point at the BAR deployment XML. openConnection validates the path before use and throws MalformedURLException when it is null or blank, appending the expected SYNTAX. This fails fast rather than producing a confusing NullPointerException from the inner URL constructor.","triggerScenarios":"Calling new URL(\"bar:...\") or resolving a bar: URL whose path portion is null or whitespace-only, e.g. new URL(\"bar:\") or new URL(\"bar: \"), which then invokes BarURLHandler.openConnection.","commonSituations":"Malformed deployment descriptor references in OSGi manifests; string concatenation that dropped the actual bar XML location; programmatically constructed URLs missing the path component.","solutions":["Ensure the bar: URL includes a valid path to the bar XML, e.g. bar:file:/path/to/deployment.bar.xml or bar:http://host/bar.xml","Log/inspect the full URL before constructing it","Null/empty-check the URL string before wrapping it in java.net.URL"],"exampleFix":"// before\nURL url = new URL(\"bar:\" + maybeNullPath);\n// after\nif (maybeNullPath == null || maybeNullPath.trim().isEmpty()) {\n    throw new IllegalArgumentException(\"bar path is required\");\n}\nURL url = new URL(\"bar:\" + maybeNullPath);","handlingStrategy":"validation","validationCode":"boolean validBarUrl(String u) {\n    if (u == null || !u.startsWith(\"bar:\")) return false;\n    String path = u.substring(4);\n    return path != null && !path.trim().isEmpty();\n}","typeGuard":null,"tryCatchPattern":"try {\n    URLConnection conn = new URL(barUrl).openConnection();\n} catch (MalformedURLException e) {\n    throw new IllegalArgumentException(\"Invalid bar URL, expected \" + SYNTAX + \": \" + barUrl, e);\n}","preventionTips":["Always include the resource path after the bar: scheme","Validate URL strings at configuration load time, not at connection time"],"tags":["osgi","url","validation"],"backgroundTag":"invalid-url-format","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-18T11:17:12.947Z"}