Repository: maven Updated Branches: refs/heads/mng-6275 [created] 39004f6ae
[MNG-6275] Maven Embedder compatible fix - Embedded sets up a classloader to mimic the boot classpath based on parsing the classworldConf - This 'bootLoader' is then installed as the context classloader in the current thread - By default, a running JVM will start with a thread context classloader of 'null' to indicate the system classloader should be used - This change switches to follow the 'correct' behaviour of following the context classloader and falling back to the system class loader only in the case where the context classloader is null. - For running from the CLI, we expect that the thread context classloader will always be null so this should be as before - For running from embedder, we expect that the thread context classloader will have been correctly configured, so this should behave as intended Project: http://git-wip-us.apache.org/repos/asf/maven/repo Commit: http://git-wip-us.apache.org/repos/asf/maven/commit/39004f6a Tree: http://git-wip-us.apache.org/repos/asf/maven/tree/39004f6a Diff: http://git-wip-us.apache.org/repos/asf/maven/diff/39004f6a Branch: refs/heads/mng-6275 Commit: 39004f6aee634a0ac6daa1f99add299ff439f5ec Parents: e44c39c Author: Stephen Connolly <stephen.alan.conno...@gmail.com> Authored: Wed Aug 30 10:23:48 2017 +0100 Committer: Stephen Connolly <stephen.alan.conno...@gmail.com> Committed: Wed Aug 30 10:23:48 2017 +0100 ---------------------------------------------------------------------- .../org/apache/maven/classrealm/DefaultClassRealmManager.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/maven/blob/39004f6a/maven-core/src/main/java/org/apache/maven/classrealm/DefaultClassRealmManager.java ---------------------------------------------------------------------- diff --git a/maven-core/src/main/java/org/apache/maven/classrealm/DefaultClassRealmManager.java b/maven-core/src/main/java/org/apache/maven/classrealm/DefaultClassRealmManager.java index d517924..7be615c 100644 --- a/maven-core/src/main/java/org/apache/maven/classrealm/DefaultClassRealmManager.java +++ b/maven-core/src/main/java/org/apache/maven/classrealm/DefaultClassRealmManager.java @@ -120,7 +120,9 @@ public class DefaultClassRealmManager { try { - ClassRealm classRealm = world.newRealm( realmId, ClassLoader.getSystemClassLoader() ); + ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader(); + ClassRealm classRealm = world.newRealm( realmId, contextClassLoader == null + ? ClassLoader.getSystemClassLoader() : contextClassLoader ); if ( logger.isDebugEnabled() ) {