From 9d8fbddcb4165ca068475c806ad858c86e28f3bc Mon Sep 17 00:00:00 2001 From: Guillaume Smet Date: Tue, 25 Jun 2024 13:46:06 +0200 Subject: [PATCH] Avoid storing the class bytes in MemoryClassPathElement ProtectionDomain Related to #41417 --- .../classloading/MemoryClassPathElement.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/classloading/MemoryClassPathElement.java b/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/classloading/MemoryClassPathElement.java index b77b6dbf18168..e75d1919e2637 100644 --- a/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/classloading/MemoryClassPathElement.java +++ b/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/classloading/MemoryClassPathElement.java @@ -21,6 +21,9 @@ public class MemoryClassPathElement extends AbstractClassPathElement { + private static final ProtectionDomain NULL_PROTECTION_DOMAIN = new ProtectionDomain( + new CodeSource(null, (Certificate[]) null), null); + private volatile Map resources; private volatile long lastModified = System.currentTimeMillis(); private final boolean runtime; @@ -112,14 +115,10 @@ public Set getProvidedResources() { @Override public ProtectionDomain getProtectionDomain() { - URL url = null; - try { - url = new URL(null, "quarkus:/", new MemoryUrlStreamHandler("quarkus:/")); - } catch (MalformedURLException e) { - throw new RuntimeException("Unable to create protection domain for memory element", e); - } - CodeSource codesource = new CodeSource(url, (Certificate[]) null); - return new ProtectionDomain(codesource, null); + // we used to include the class bytes in the ProtectionDomain + // but it is not a good idea + // see https://github.com/quarkusio/quarkus/issues/41417 for more details about the problem + return NULL_PROTECTION_DOMAIN; } @Override