pinpoint-apm/pinpoint · error · RuntimeException

MalformedURL error

Error message

MalformedURL error

What it means

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.

Source

Thrown at agent-module/bootstraps/bootstrap/src/main/java/com/navercorp/pinpoint/bootstrap/PathUtils.java:36

import java.net.MalformedURLException;
import java.net.URL;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

final class PathUtils {
    private PathUtils() {
    }

    public static URL toURL(Path path) {
        Objects.requireNonNull(path, "path");

        try {
            return path.toUri().toURL();
        } catch (MalformedURLException e) {
            throw new RuntimeException("MalformedURL error", e);
        }
    }

    public static URL[] toURLs(List<Path> pathList) {
        Objects.requireNonNull(pathList, "pathList");

        List<URL> list = new ArrayList<>(pathList.size());
        for (Path path : pathList) {
            list.add(PathUtils.toURL(path));
        }
        return list.toArray(new URL[0]);
    }
}

View on GitHub (pinned to 744c3d3075)

Solutions

  1. Log the offending Path and confirm it is a regular file location under the agent directory
  2. Use standard file-system paths for the agent installation (no exotic providers or unusual characters)
  3. Catch the RuntimeException at the call site and skip/report the bad jar instead of aborting the whole agent if one path is malformed
  4. If a custom filesystem provider is required, convert with new URL(providerScheme, host, path) explicitly rather than relying on toUri().toURL()

Example fix

// before
URL url = PathUtils.toURL(path);
// after
URL url;
try {
    url = PathUtils.toURL(path);
} catch (RuntimeException e) {
    logger.warn("Skipping malformed path: {}", path, e);
    continue;
}
Defensive patterns

Strategy: try-catch

Validate before calling

if (path == null || !Files.isRegularFile(path)) throw new IllegalArgumentException("invalid jar path: " + path);

Try / catch

try {
    return PathUtils.toURL(path);
} catch (RuntimeException e) {
    logger.warn("bad URL for path {}", path, e);
    return null;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "Invalid URL" errors: why new URL(), URI.parse, and reqwest::Url reject your string — missing scheme, whitespace, and bad path format — this error's family across 39 libraries.

Related errors


AI-assisted analysis of pinpoint-apm/pinpoint@744c3d3075 (2026-09-07). Data as JSON: /api/errors/c3422939186e7aeb. Report an issue: GitHub.