Skip to content

Commit

Permalink
Clean up ClassTransformingBuildStep's static variable between each te…
Browse files Browse the repository at this point in the history
…st run
  • Loading branch information
yrodiere committed Aug 17, 2023
1 parent 708ea79 commit c10432b
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import io.quarkus.deployment.builditem.ApplicationArchivesBuildItem;
import io.quarkus.deployment.builditem.ArchiveRootBuildItem;
import io.quarkus.deployment.builditem.BytecodeTransformerBuildItem;
import io.quarkus.deployment.builditem.CuratedApplicationShutdownBuildItem;
import io.quarkus.deployment.builditem.LaunchModeBuildItem;
import io.quarkus.deployment.builditem.LiveReloadBuildItem;
import io.quarkus.deployment.builditem.RemovedResourceBuildItem;
Expand Down Expand Up @@ -71,13 +72,19 @@ public static byte[] transform(String className, byte[] classData) {
return lastTransformers.apply(className, classData);
}

private static void reset() {
lastTransformers = null;
transformedClassesCache.clear();
}

@BuildStep
TransformedClassesBuildItem handleClassTransformation(List<BytecodeTransformerBuildItem> bytecodeTransformerBuildItems,
ApplicationArchivesBuildItem appArchives, LiveReloadBuildItem liveReloadBuildItem,
LaunchModeBuildItem launchModeBuildItem, ClassLoadingConfig classLoadingConfig,
CurateOutcomeBuildItem curateOutcomeBuildItem, List<RemovedResourceBuildItem> removedResourceBuildItems,
ArchiveRootBuildItem archiveRoot, LaunchModeBuildItem launchMode, PackageConfig packageConfig,
ExecutorService buildExecutor)
ExecutorService buildExecutor,
CuratedApplicationShutdownBuildItem shutdown)
throws ExecutionException, InterruptedException {
if (bytecodeTransformerBuildItems.isEmpty() && classLoadingConfig.removedResources.isEmpty()
&& removedResourceBuildItems.isEmpty()) {
Expand Down Expand Up @@ -117,6 +124,7 @@ TransformedClassesBuildItem handleClassTransformation(List<BytecodeTransformerBu
final ConcurrentLinkedDeque<Future<TransformedClassesBuildItem.TransformedClass>> transformed = new ConcurrentLinkedDeque<>();
final Map<Path, Set<TransformedClassesBuildItem.TransformedClass>> transformedClassesByJar = new HashMap<>();
ClassLoader transformCl = Thread.currentThread().getContextClassLoader();
shutdown.addCloseTask(ClassTransformingBuildStep::reset, true);
lastTransformers = new BiFunction<String, byte[], byte[]>() {
@Override
public byte[] apply(String className, byte[] originalBytes) {
Expand Down

0 comments on commit c10432b

Please sign in to comment.