fix: changing how scripts are loaded from the classpath (#45358) (#45399)

closes: #43975


(cherry picked from commit 819de5e33a)

Signed-off-by: Steve Hawkins <shawkins@redhat.com>
This commit is contained in:
Steven Hawkins
2026-01-14 02:12:27 -05:00
committed by GitHub
parent 79f975f38c
commit e1385daf56

View File

@@ -20,6 +20,8 @@ package org.keycloak.quarkus.deployment;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
@@ -1041,9 +1043,13 @@ class KeycloakProcessor {
// descriptor is at META-INF/
Path basePath = Path.of(url.getPath()).getParent().getParent();
String path = basePath.resolve(fileName).toString();
if (!path.startsWith(url.getProtocol())) {
path = url.getProtocol() + ":" + path;
}
try {
return basePath.resolve(fileName).toUri().toURL().openStream();
} catch (IOException e) {
return new URI(path).toURL().openStream();
} catch (IOException | URISyntaxException e) {
throw new RuntimeException("Failed to read script file from: " + fileName);
}
});