From 0b458d05147fe788bc730afff50043c15eda15ca Mon Sep 17 00:00:00 2001 From: Martin Kouba Date: Mon, 11 Dec 2023 10:03:56 +0100 Subject: [PATCH] ArC: detect incorrect usage of javax.inject.Singleton - jakarta.inject.Singleton should be used instead --- .../arc/deployment/WrongAnnotationUsageProcessor.java | 1 + .../arc/test/wrongannotations/WrongSingletonTest.java | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/WrongAnnotationUsageProcessor.java b/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/WrongAnnotationUsageProcessor.java index 5bbd2bdfcc330..3477a61bf3870 100644 --- a/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/WrongAnnotationUsageProcessor.java +++ b/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/WrongAnnotationUsageProcessor.java @@ -44,6 +44,7 @@ void detect(ArcConfig config, ApplicationIndexBuildItem applicationIndex, Custom unsupported.add(new UnsupportedAnnotation("com.google.inject.Singleton", correctSingleton)); unsupported.add(new UnsupportedAnnotation("jakarta.ejb.Singleton", correctSingleton)); unsupported.add(new UnsupportedAnnotation("groovy.lang.Singleton", correctSingleton)); + unsupported.add(new UnsupportedAnnotation("javax.inject.Singleton", correctSingleton)); String correctInject = "@jakarta.inject.Inject"; unsupported.add(new UnsupportedAnnotation("javax.inject.Inject", correctInject)); diff --git a/extensions/arc/deployment/src/test/java/io/quarkus/arc/test/wrongannotations/WrongSingletonTest.java b/extensions/arc/deployment/src/test/java/io/quarkus/arc/test/wrongannotations/WrongSingletonTest.java index fa23c3038be6b..04bb22f7ad028 100644 --- a/extensions/arc/deployment/src/test/java/io/quarkus/arc/test/wrongannotations/WrongSingletonTest.java +++ b/extensions/arc/deployment/src/test/java/io/quarkus/arc/test/wrongannotations/WrongSingletonTest.java @@ -21,11 +21,12 @@ public class WrongSingletonTest { @RegisterExtension static final QuarkusUnitTest config = new QuarkusUnitTest() - .withApplicationRoot((jar) -> jar - .addClasses(EjbSingleton.class)) + .withApplicationRoot(root -> root + .addClasses(EjbSingleton.class, GuiceProducers.class, JavaxSingleton.class)) .assertException(t -> { Throwable rootCause = ExceptionUtil.getRootCause(t); assertTrue(rootCause.getMessage().contains("jakarta.ejb.Singleton"), t.toString()); + assertTrue(rootCause.getMessage().contains("javax.inject.Singleton"), t.toString()); assertTrue(rootCause.getMessage().contains("com.google.inject.Singleton"), t.toString()); }); @@ -55,4 +56,9 @@ List produceEjbSingleton() { } + @javax.inject.Singleton + static class JavaxSingleton { + + } + }