{"record":{"id":"c3422939186e7aeb","repo":"pinpoint-apm/pinpoint","slug":"malformedurl-error","errorCode":null,"errorMessage":"MalformedURL error","messagePattern":"MalformedURL error","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"agent-module/bootstraps/bootstrap/src/main/java/com/navercorp/pinpoint/bootstrap/PathUtils.java","lineNumber":36,"sourceCode":"\nimport java.net.MalformedURLException;\nimport java.net.URL;\nimport java.nio.file.Path;\nimport java.util.ArrayList;\nimport java.util.List;\nimport java.util.Objects;\n\nfinal class PathUtils {\n    private PathUtils() {\n    }\n\n    public static URL toURL(Path path) {\n        Objects.requireNonNull(path, \"path\");\n\n        try {\n            return path.toUri().toURL();\n        } catch (MalformedURLException e) {\n            throw new RuntimeException(\"MalformedURL error\", e);\n        }\n    }\n\n    public static URL[] toURLs(List<Path> pathList) {\n        Objects.requireNonNull(pathList, \"pathList\");\n\n        List<URL> list = new ArrayList<>(pathList.size());\n        for (Path path : pathList) {\n            list.add(PathUtils.toURL(path));\n        }\n        return list.toArray(new URL[0]);\n    }\n}\n","sourceCodeStart":18,"sourceCodeEnd":50,"githubUrl":"https://github.com/pinpoint-apm/pinpoint/blob/744c3d3075e595656abb1ae331ad2c0e4c9eb996/agent-module/bootstraps/bootstrap/src/main/java/com/navercorp/pinpoint/bootstrap/PathUtils.java#L18-L50","documentation":"PathUtils.toURL(Path) converts a Path to a URL via path.toUri().toURL(). Although Path.toUri() rarely produces a malformed URL, MalformedURLException is rethrown as RuntimeException 'MalformedURL error'. Callers (agent jar collection, PathUtils.toURLs) treat this as fatal when building agent classloader URLs.","triggerScenarios":"Converting a Path whose URI cannot be turned into a URL — in practice only via exotic filesystem providers/characters or a wrapped null/invalid scheme; otherwise essentially never with normal file paths.","commonSituations":"Custom filesystem providers (zip/jimfs) whose URIs confuse URL conversion; odd characters in the agent installation path; JVM URL handler issues after security-policy or protocol-handler restrictions.","solutions":["Log the offending Path and confirm it is a regular file location under the agent directory","Use standard file-system paths for the agent installation (no exotic providers or unusual characters)","Catch the RuntimeException at the call site and skip/report the bad jar instead of aborting the whole agent if one path is malformed","If a custom filesystem provider is required, convert with new URL(providerScheme, host, path) explicitly rather than relying on toUri().toURL()"],"exampleFix":"// before\nURL url = PathUtils.toURL(path);\n// after\nURL url;\ntry {\n    url = PathUtils.toURL(path);\n} catch (RuntimeException e) {\n    logger.warn(\"Skipping malformed path: {}\", path, e);\n    continue;\n}","handlingStrategy":"try-catch","validationCode":"if (path == null || !Files.isRegularFile(path)) throw new IllegalArgumentException(\"invalid jar path: \" + path);","typeGuard":null,"tryCatchPattern":"try {\n    return PathUtils.toURL(path);\n} catch (RuntimeException e) {\n    logger.warn(\"bad URL for path {}\", path, e);\n    return null;\n}","preventionTips":["Keep agent paths simple ASCII filesystem locations","Sanity-check each collected jar path before URL conversion","Prefer PathUtils.toURLs for batch conversion with consistent handling"],"tags":["url","filesystem","java"],"backgroundTag":"invalid-url-format","analyzedSha":"744c3d3075e595656abb1ae331ad2c0e4c9eb996","analyzedAt":"2026-09-07T18:48:45.289Z","contentChangedAt":"2026-09-07T18:48:45.289Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}