Home / Function/ URL() — netty Function Reference

URL() — netty Function Reference

Architecture documentation for the URL() function in NativeLibraryLoader.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  0e52c8e7_1e67_40f4_2a1c_6c33fc417f6e["URL()"]
  e940cc67_3be6_5ff3_e560_4d68972dc13b["NativeLibraryLoader"]
  0e52c8e7_1e67_40f4_2a1c_6c33fc417f6e -->|defined in| e940cc67_3be6_5ff3_e560_4d68972dc13b
  2c0bfd33_d083_1660_4138_47c853fc9d33["digest()"]
  0e52c8e7_1e67_40f4_2a1c_6c33fc417f6e -->|calls| 2c0bfd33_d083_1660_4138_47c853fc9d33
  style 0e52c8e7_1e67_40f4_2a1c_6c33fc417f6e fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

common/src/main/java/io/netty/util/internal/NativeLibraryLoader.java lines 258–312

    private static URL getResource(String path, ClassLoader loader) {
        final Enumeration<URL> urls;
        try {
            if (loader == null) {
                urls = ClassLoader.getSystemResources(path);
            } else {
                urls = loader.getResources(path);
            }
        } catch (IOException iox) {
            throw new RuntimeException("An error occurred while getting the resources for " + path, iox);
        }

        List<URL> urlsList = Collections.list(urls);
        int size = urlsList.size();
        switch (size) {
            case 0:
                return null;
            case 1:
                return urlsList.get(0);
            default:
                if (DETECT_NATIVE_LIBRARY_DUPLICATES) {
                    try {
                        MessageDigest md = MessageDigest.getInstance("SHA-256");
                        // We found more than 1 resource with the same name. Let's check if the content of the file is
                        // the same as in this case it will not have any bad effect.
                        URL url = urlsList.get(0);
                        byte[] digest = digest(md, url);
                        boolean allSame = true;
                        if (digest != null) {
                            for (int i = 1; i < size; i++) {
                                byte[] digest2 = digest(md, urlsList.get(i));
                                if (digest2 == null || !Arrays.equals(digest, digest2)) {
                                    allSame = false;
                                    break;
                                }
                            }
                        } else {
                            allSame = false;
                        }
                        if (allSame) {
                            return url;
                        }
                    } catch (NoSuchAlgorithmException e) {
                        logger.debug("Don't support SHA-256, can't check if resources have same content.", e);
                    }

                    throw new IllegalStateException(
                            "Multiple resources found for '" + path + "' with different content: " + urlsList);
                } else {
                    logger.warn("Multiple resources found for '" + path + "' with different content: " +
                            urlsList + ". Please fix your dependency graph.");
                    return urlsList.get(0);
                }
        }
    }

Domain

Subdomains

Calls

Frequently Asked Questions

What does URL() do?
URL() is a function in the netty codebase, defined in common/src/main/java/io/netty/util/internal/NativeLibraryLoader.java.
Where is URL() defined?
URL() is defined in common/src/main/java/io/netty/util/internal/NativeLibraryLoader.java at line 258.
What does URL() call?
URL() calls 1 function(s): digest.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free