-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Load test classes with runtime classloader #34681
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,6 +61,9 @@ public class CuratedApplication implements Serializable, AutoCloseable { | |
*/ | ||
private volatile QuarkusClassLoader baseRuntimeClassLoader; | ||
|
||
// TODO this probably isn't the right place to store this | ||
private volatile QuarkusClassLoader runtimeClassLoader; | ||
|
||
private final QuarkusBootstrap quarkusBootstrap; | ||
private final CurationResult curationResult; | ||
private final ConfiguredClassLoading configuredClassLoading; | ||
|
@@ -252,6 +255,7 @@ public synchronized QuarkusClassLoader getOrCreateBaseRuntimeClassLoader() { | |
quarkusBootstrap.getBaseClassLoader(), false) | ||
.setAssertionsEnabled(quarkusBootstrap.isAssertionsEnabled()); | ||
builder.addClassLoaderEventListeners(quarkusBootstrap.getClassLoaderEventListeners()); | ||
builder.setCuratedApplication(this); | ||
|
||
if (configuredClassLoading.isFlatTestClassPath()) { | ||
//in test mode we have everything in the base class loader | ||
|
@@ -390,7 +394,9 @@ public QuarkusClassLoader createRuntimeClassLoader(ClassLoader base, Map<String, | |
+ runtimeClassLoaderCount.getAndIncrement(), | ||
getOrCreateBaseRuntimeClassLoader(), false) | ||
.setAssertionsEnabled(quarkusBootstrap.isAssertionsEnabled()) | ||
.setCuratedApplication(this) | ||
.setAggregateParentResources(true); | ||
|
||
builder.setTransformedClasses(transformedClasses); | ||
|
||
builder.addNormalPriorityElement(new MemoryClassPathElement(resources, true)); | ||
|
@@ -416,7 +422,9 @@ public QuarkusClassLoader createRuntimeClassLoader(ClassLoader base, Map<String, | |
for (Path root : configuredClassLoading.getAdditionalClasspathElements()) { | ||
builder.addNormalPriorityElement(ClassPathElement.fromPath(root, true)); | ||
} | ||
return builder.build(); | ||
QuarkusClassLoader loader = builder.build(); | ||
runtimeClassLoader = loader; | ||
return loader; | ||
} | ||
|
||
public boolean isReloadableArtifact(ArtifactKey key) { | ||
|
@@ -440,6 +448,11 @@ public void close() { | |
augmentationElements.clear(); | ||
} | ||
|
||
// TODO delete this? the model doesn't really work? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doesn't really work, in what sense? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good question. That comment is so old I wasn't entirely sure myself, when I was reviewing the TODOs. :) I think what it's referring to is that at an early stage of development I had good ideas about re-using more of the curated application + base classloaders between different applications. That is, if I decided we needed to restart, instead of throwing everything out, I'd do a light tidy and then re-use the lower levels of the classloader stack. That might still be a good thing to do, and it would reduce the memory footprint of the new 'load everything upfront' pattern. If we can do restarts for continuous testing we should be able to achieve some reuse in normal mode testing. But I never made it work. So I think that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🙏🏽 |
||
public void tidy() { | ||
this.runtimeClassLoader = null; | ||
} | ||
|
||
/** | ||
* TODO: Fix everything in the universe to do loading properly | ||
* | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any specific hints about the possible problems?