@@ -69,7 +69,7 @@ public final class FacadeClassLoader extends ClassLoader implements Closeable {
69
69
private static final Map <String , CuratedApplication > curatedApplications = new HashMap <>();
70
70
71
71
// JUnit discovery is single threaded, so no need for concurrency on this map
72
- private final Map <String , StartupAction > runtimeClassLoaders = new HashMap <>();
72
+ private final Map <String , QuarkusClassLoader > runtimeClassLoaders = new HashMap <>();
73
73
private static final String NO_PROFILE = "no-profile" ;
74
74
75
75
/*
@@ -439,8 +439,8 @@ private QuarkusClassLoader getQuarkusClassLoader(Class<?> requiredTestClass, Cla
439
439
String profileKey = getProfileKey (profile );
440
440
441
441
try {
442
- StartupAction startupAction ;
443
442
String key ;
443
+ QuarkusClassLoader classLoader ;
444
444
445
445
// We cannot directly access TestResourceUtil as long as we're in the core module, but the app classloaders can.
446
446
// But, chicken-and-egg, we may not have an app classloader yet. However, if we don't, we won't need to worry about restarts, but this instance clearly cannot need a restart
@@ -450,8 +450,8 @@ private QuarkusClassLoader getQuarkusClassLoader(Class<?> requiredTestClass, Cla
450
450
// If we make a classloader with a null profile, we get the problem of starting dev services multiple times, which is very bad (if temporary) - once that issue is fixed, could reconsider
451
451
if (keyMakerClassLoader == null ) {
452
452
// Making a classloader uses the profile key to look up a curated application
453
- startupAction = getOrCreateRuntimeClassLoader (profileKey , requiredTestClass , profile );
454
- keyMakerClassLoader = startupAction . getClassLoader () ;
453
+ classLoader = getOrCreateRuntimeClassLoader (profileKey , requiredTestClass , profile );
454
+ keyMakerClassLoader = classLoader ;
455
455
456
456
// We cannot use the startup action one because it's a base runtime classloader and so will not have the right access to application classes (they're in its banned list)
457
457
final String resourceKey = requiredTestClass != null ? getResourceKey (requiredTestClass , profile ) : null ;
@@ -463,18 +463,15 @@ private QuarkusClassLoader getQuarkusClassLoader(Class<?> requiredTestClass, Cla
463
463
464
464
// The resource key might be null, and that's ok
465
465
key = profileKey + resourceKey ;
466
- startupAction = runtimeClassLoaders .get (key );
467
- if (startupAction == null ) {
466
+ classLoader = runtimeClassLoaders .get (key );
467
+ if (classLoader == null ) {
468
468
// Making a classloader uses the profile key to look up a curated application
469
- startupAction = getOrCreateRuntimeClassLoader (profileKey , requiredTestClass , profile );
469
+ classLoader = getOrCreateRuntimeClassLoader (profileKey , requiredTestClass , profile );
470
470
}
471
-
472
471
}
473
472
474
- // If we didn't have a classloader and didn't get a resource key
475
- runtimeClassLoaders .put (key , startupAction );
476
-
477
- return startupAction .getClassLoader ();
473
+ runtimeClassLoaders .put (key , classLoader );
474
+ return classLoader ;
478
475
} catch (RuntimeException e ) {
479
476
// Exceptions here get swallowed by the JUnit framework and we don't get any debug information unless we print it ourself
480
477
e .printStackTrace ();
@@ -543,13 +540,12 @@ private QuarkusClassLoader getOrCreateBaseClassLoader(String key, Class<?> requi
543
540
return curatedApplication .getOrCreateBaseRuntimeClassLoader ();
544
541
}
545
542
546
- private StartupAction getOrCreateRuntimeClassLoader (String key , Class <?> requiredTestClass , Class <?> profile )
543
+ private QuarkusClassLoader getOrCreateRuntimeClassLoader (String key , Class <?> requiredTestClass , Class <?> profile )
547
544
throws ClassNotFoundException , NoSuchMethodException , InvocationTargetException , InstantiationException ,
548
545
IllegalAccessException , AppModelResolverException , BootstrapException , IOException {
549
546
CuratedApplication curatedApplication = getOrCreateCuratedApplication (key , requiredTestClass );
550
547
StartupAction startupAction = AppMakerHelper .getStartupAction (requiredTestClass ,
551
548
curatedApplication , profile );
552
-
553
549
QuarkusClassLoader loader = startupAction .getClassLoader ();
554
550
555
551
Class <?> configProviderResolverClass = loader .loadClass (ConfigProviderResolver .class .getName ());
@@ -561,7 +557,7 @@ private StartupAction getOrCreateRuntimeClassLoader(String key, Class<?> require
561
557
configProviderResolverClass .getDeclaredMethod ("setInstance" , configProviderResolverClass )
562
558
.invoke (null , testConfigProviderResolver );
563
559
564
- return startupAction ;
560
+ return loader ;
565
561
566
562
}
567
563
0 commit comments