From 4307712f88203886b481f55b3aaede87d0d2eaf3 Mon Sep 17 00:00:00 2001 From: Holly Cummins Date: Wed, 6 Sep 2023 19:31:07 +0100 Subject: [PATCH] See what breaks if we just ... put arc back after tearing it down --- .../runner/bootstrap/StartupActionImpl.java | 4 ++-- .../io/quarkus/arc/deployment/ArcProcessor.java | 2 ++ .../java/io/quarkus/arc/runtime/ArcRecorder.java | 1 + .../runtime/src/main/java/io/quarkus/arc/Arc.java | 14 +++++++++++--- .../quarkus/test/junit/QuarkusTestExtension.java | 10 ++++++++++ 5 files changed, 26 insertions(+), 5 deletions(-) diff --git a/core/deployment/src/main/java/io/quarkus/runner/bootstrap/StartupActionImpl.java b/core/deployment/src/main/java/io/quarkus/runner/bootstrap/StartupActionImpl.java index f8ea92d5f7b00c..75c70aa44bd700 100644 --- a/core/deployment/src/main/java/io/quarkus/runner/bootstrap/StartupActionImpl.java +++ b/core/deployment/src/main/java/io/quarkus/runner/bootstrap/StartupActionImpl.java @@ -79,8 +79,8 @@ public StartupActionImpl(CuratedApplication curatedApplication, BuildResult buil transformedClasses); runtimeClassLoader = curatedApplication.createRuntimeClassLoader( resources, transformedClasses); - System.out.println("HOLLY STARTUP ACTION MADE RUNtime " + runtimeClassLoader); - System.out.println("startup thread is " + Thread.currentThread()); + System.out.println("HOLLY FUNQ STARTUP ACTION MADE RUNtime " + runtimeClassLoader); + System.out.println("FUNQ startup thread is " + Thread.currentThread()); // new Exception().printStackTrace(); } this.runtimeClassLoader = runtimeClassLoader; diff --git a/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/ArcProcessor.java b/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/ArcProcessor.java index 16ba770850c40e..14f16d6e092cdd 100644 --- a/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/ArcProcessor.java +++ b/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/ArcProcessor.java @@ -774,6 +774,8 @@ public boolean test(ClassInfo clazz) { } /* + * TODO consolidate this with the code above, see if it enables prod test and quarkus test to co-exist, and isolate to its + * own change set? * TODO I'm not really happy with this as a general solution. Without this, we see classes being transformed twice if a * QuarkusProdModeTest is used and transformations are needed (such as adding a constructor) * I followed the model we use for QuarkusComponentTest, but it's limited in how much it will catch. diff --git a/extensions/arc/runtime/src/main/java/io/quarkus/arc/runtime/ArcRecorder.java b/extensions/arc/runtime/src/main/java/io/quarkus/arc/runtime/ArcRecorder.java index e4af7ea639bb5f..933a7f9f6887ce 100644 --- a/extensions/arc/runtime/src/main/java/io/quarkus/arc/runtime/ArcRecorder.java +++ b/extensions/arc/runtime/src/main/java/io/quarkus/arc/runtime/ArcRecorder.java @@ -57,6 +57,7 @@ public void run() { } public void initExecutor(ExecutorService executor) { + System.out.println("FUNQ will set executor on arc, cl is " + Arc.class.getClassLoader()); Arc.setExecutor(executor); } diff --git a/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/Arc.java b/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/Arc.java index d625c8e309e813..13d3effa9d7e71 100644 --- a/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/Arc.java +++ b/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/Arc.java @@ -29,18 +29,18 @@ public static ArcContainer initialize() { * @see #initialize() */ public static ArcContainer initialize(ArcInitConfig arcInitConfig) { - System.out.println("HOLLY starting to init arc"); + System.out.println("HOLLY FUNQ starting to init arc" + Arc.class.getClassLoader()); ArcContainerImpl container = INSTANCE.get(); if (container == null) { synchronized (INSTANCE) { container = INSTANCE.get(); - System.out.println("arc container instance is " + container); + System.out.println("FUNQ arc container instance is " + container); if (container == null) { // Set the container instance first because Arc.container() can be used within ArcContainerImpl.init() container = new ArcContainerImpl(arcInitConfig.getCurrentContextFactory(), arcInitConfig.isStrictCompatibility()); INSTANCE.set(container); - System.out.println("arc did set container"); + System.out.println("FUNQ arc did set container"); container.init(); } } @@ -49,6 +49,13 @@ public static ArcContainer initialize(ArcInitConfig arcInitConfig) { } public static void setExecutor(ExecutorService executor) { + System.out.println(INSTANCE.get() + "HOLLY FUNQ trying to set the executor " + Arc.class.getClassLoader()); + if (INSTANCE.get() == null) { + // TODO this happens because we tear things down and don't put them back properly + // Can we just ... init ourselves? + System.out.println("TODO HACK just putting it back"); + initialize(); + } INSTANCE.get().setExecutor(executor); } @@ -67,6 +74,7 @@ public static void shutdown() { container = INSTANCE.get(); if (container != null) { container.shutdown(); + System.out.println("HOLLY FUNQ shutting down, setting instance to null " + Arc.class.getClassLoader()); INSTANCE.set(null); } } diff --git a/test-framework/junit5/src/main/java/io/quarkus/test/junit/QuarkusTestExtension.java b/test-framework/junit5/src/main/java/io/quarkus/test/junit/QuarkusTestExtension.java index b72172ee5f1374..957f34c89c6206 100644 --- a/test-framework/junit5/src/main/java/io/quarkus/test/junit/QuarkusTestExtension.java +++ b/test-framework/junit5/src/main/java/io/quarkus/test/junit/QuarkusTestExtension.java @@ -233,6 +233,7 @@ public Thread newThread(Runnable r) { // populateDeepCloneField(startupAction); //must be done after the TCCL has been set + // TODO could we load this with the normal class of this test? I think we could testResourceManager = (Closeable) Thread.currentThread().getContextClassLoader() .loadClass(TestResourceManager.class.getName()) .getConstructor(Class.class, Class.class, List.class, boolean.class, Map.class, Optional.class, Path.class) @@ -256,9 +257,11 @@ public Thread newThread(Runnable r) { populateTestMethodInvokers(startupAction.getClassLoader()); if (profileInstance == null || !profileInstance.runMainMethod()) { + System.out.println("HOLLY FUNQ DOING THE STARTUP PATH"); runningQuarkusApplication = startupAction .run(profileInstance == null ? new String[0] : profileInstance.commandLineParameters()); } else { + System.out.println("HOLLY FUNQ doing the main class path"); Class lifecycleManager = Class.forName(ApplicationLifecycleManager.class.getName(), true, startupAction.getClassLoader()); @@ -623,6 +626,13 @@ private QuarkusTestExtensionState ensureStarted(ExtensionContext extensionContex boolean reloadTestResources = !Objects.equals(extensionContext.getRequiredTestClass(), currentJUnitTestClass) && !isNested(currentJUnitTestClass, extensionContext.getRequiredTestClass()) && (hasPerTestResources || hasPerTestResources(extensionContext)); + System.out.println("HOLLY FUNQ reload test resources is " + reloadTestResources); + System.out.println( + "HOLLY FUNQ equality " + Objects.equals(extensionContext.getRequiredTestClass(), currentJUnitTestClass)); + System.out.println("HOLLY FUNQ nested " + isNested(currentJUnitTestClass, extensionContext.getRequiredTestClass())); + System.out.println("HOLLY FUNQ pertest " + hasPerTestResources); + System.out.println("HOLLY FUNQ per test for context " + hasPerTestResources(extensionContext)); + System.out.println("HOLLY FUNQ is wrong profile is " + wrongProfile); if ((state == null && !failedBoot) || wrongProfile || reloadTestResources) { if (wrongProfile || reloadTestResources) { if (state != null) {