Skip to content

Commit

Permalink
Fix ScriptUtils.runInitScript() in hierarchical classloader setup by …
Browse files Browse the repository at this point in the history
…using TCCL (#5167)
  • Loading branch information
famod authored Apr 6, 2022
1 parent 297621f commit 06fc95f
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -293,10 +293,13 @@ public static boolean containsSqlScriptDelimiters(String script, String delim) {
*/
public static void runInitScript(DatabaseDelegate databaseDelegate, String initScriptPath) {
try {
URL resource = ScriptUtils.class.getClassLoader().getResource(initScriptPath);
URL resource = Thread.currentThread().getContextClassLoader().getResource(initScriptPath);
if (resource == null) {
LOGGER.warn("Could not load classpath init script: {}", initScriptPath);
throw new ScriptLoadException("Could not load classpath init script: " + initScriptPath + ". Resource not found.");
resource = ScriptUtils.class.getClassLoader().getResource(initScriptPath);
if (resource == null) {
LOGGER.warn("Could not load classpath init script: {}", initScriptPath);
throw new ScriptLoadException("Could not load classpath init script: " + initScriptPath + ". Resource not found.");
}
}
String scripts = IOUtils.toString(resource, StandardCharsets.UTF_8);
executeDatabaseScript(databaseDelegate, initScriptPath, scripts);
Expand Down

0 comments on commit 06fc95f

Please sign in to comment.