From 554ae55dd9b07a24a18639a015689d5467f2d8fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yoann=20Rodi=C3=A8re?= Date: Fri, 3 May 2024 15:20:29 +0200 Subject: [PATCH] Fix DisableLoggingFeature for JBoss Threads/Hibernate/Infinispan/Websocket-client The log level we get in beforeAnalysis may be null, in which case we still want to reset it after analysis. From the javadoc of Logger#getLevel: > Get the log Level that has been specified for this Logger. > The result may be null, which means that this logger's effective level will be inherited from its parent. --- .../io/quarkus/runtime/graal/DisableLoggingFeature.java | 6 ++---- .../envers/runtime/graal/DisableLoggingFeature.java | 6 ++---- .../hibernate/orm/runtime/graal/DisableLoggingFeature.java | 6 ++---- .../elasticsearch/runtime/graal/DisableLoggingFeature.java | 6 ++---- .../hibernate/validator/runtime/DisableLoggingFeature.java | 6 ++---- .../client/runtime/graal/DisableLoggingFeature.java | 6 ++---- .../websockets/client/runtime/DisableLoggingFeature.java | 6 ++---- 7 files changed, 14 insertions(+), 28 deletions(-) diff --git a/core/runtime/src/main/java/io/quarkus/runtime/graal/DisableLoggingFeature.java b/core/runtime/src/main/java/io/quarkus/runtime/graal/DisableLoggingFeature.java index 955884c00e8ac..2b5565c8015ef 100644 --- a/core/runtime/src/main/java/io/quarkus/runtime/graal/DisableLoggingFeature.java +++ b/core/runtime/src/main/java/io/quarkus/runtime/graal/DisableLoggingFeature.java @@ -31,10 +31,8 @@ public void beforeAnalysis(BeforeAnalysisAccess access) { public void afterAnalysis(AfterAnalysisAccess access) { for (String category : CATEGORIES) { Level level = categoryMap.remove(category); - if (level != null) { - Logger logger = Logger.getLogger(category); - logger.setLevel(level); - } + Logger logger = Logger.getLogger(category); + logger.setLevel(level); } } diff --git a/extensions/hibernate-envers/runtime/src/main/java/io/quarkus/hibernate/envers/runtime/graal/DisableLoggingFeature.java b/extensions/hibernate-envers/runtime/src/main/java/io/quarkus/hibernate/envers/runtime/graal/DisableLoggingFeature.java index de6d22b94c1a6..481398edb364d 100644 --- a/extensions/hibernate-envers/runtime/src/main/java/io/quarkus/hibernate/envers/runtime/graal/DisableLoggingFeature.java +++ b/extensions/hibernate-envers/runtime/src/main/java/io/quarkus/hibernate/envers/runtime/graal/DisableLoggingFeature.java @@ -32,10 +32,8 @@ public void beforeAnalysis(BeforeAnalysisAccess access) { public void afterAnalysis(AfterAnalysisAccess access) { for (String category : CATEGORIES) { Level level = categoryMap.remove(category); - if (level != null) { - Logger logger = Logger.getLogger(category); - logger.setLevel(level); - } + Logger logger = Logger.getLogger(category); + logger.setLevel(level); } } diff --git a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/graal/DisableLoggingFeature.java b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/graal/DisableLoggingFeature.java index 50acd745f0063..ccd4be97371f3 100644 --- a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/graal/DisableLoggingFeature.java +++ b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/graal/DisableLoggingFeature.java @@ -34,10 +34,8 @@ public void beforeAnalysis(BeforeAnalysisAccess access) { public void afterAnalysis(AfterAnalysisAccess access) { for (String category : CATEGORIES) { Level level = categoryMap.remove(category); - if (level != null) { - Logger logger = Logger.getLogger(category); - logger.setLevel(level); - } + Logger logger = Logger.getLogger(category); + logger.setLevel(level); } } diff --git a/extensions/hibernate-search-orm-elasticsearch/runtime/src/main/java/io/quarkus/hibernate/search/orm/elasticsearch/runtime/graal/DisableLoggingFeature.java b/extensions/hibernate-search-orm-elasticsearch/runtime/src/main/java/io/quarkus/hibernate/search/orm/elasticsearch/runtime/graal/DisableLoggingFeature.java index 245bc72fca92d..e3666fda2aed3 100644 --- a/extensions/hibernate-search-orm-elasticsearch/runtime/src/main/java/io/quarkus/hibernate/search/orm/elasticsearch/runtime/graal/DisableLoggingFeature.java +++ b/extensions/hibernate-search-orm-elasticsearch/runtime/src/main/java/io/quarkus/hibernate/search/orm/elasticsearch/runtime/graal/DisableLoggingFeature.java @@ -31,10 +31,8 @@ public void beforeAnalysis(BeforeAnalysisAccess access) { public void afterAnalysis(AfterAnalysisAccess access) { for (String category : CATEGORIES) { Level level = categoryMap.remove(category); - if (level != null) { - Logger logger = Logger.getLogger(category); - logger.setLevel(level); - } + Logger logger = Logger.getLogger(category); + logger.setLevel(level); } } diff --git a/extensions/hibernate-validator/runtime/src/main/java/io/quarkus/hibernate/validator/runtime/DisableLoggingFeature.java b/extensions/hibernate-validator/runtime/src/main/java/io/quarkus/hibernate/validator/runtime/DisableLoggingFeature.java index 6d65ddf89463f..64f01c14cfb25 100644 --- a/extensions/hibernate-validator/runtime/src/main/java/io/quarkus/hibernate/validator/runtime/DisableLoggingFeature.java +++ b/extensions/hibernate-validator/runtime/src/main/java/io/quarkus/hibernate/validator/runtime/DisableLoggingFeature.java @@ -32,10 +32,8 @@ public void beforeAnalysis(BeforeAnalysisAccess access) { public void afterAnalysis(AfterAnalysisAccess access) { for (String category : CATEGORIES) { Level level = categoryMap.remove(category); - if (level != null) { - Logger logger = Logger.getLogger(category); - logger.setLevel(level); - } + Logger logger = Logger.getLogger(category); + logger.setLevel(level); } } diff --git a/extensions/infinispan-client/runtime/src/main/java/io/quarkus/infinispan/client/runtime/graal/DisableLoggingFeature.java b/extensions/infinispan-client/runtime/src/main/java/io/quarkus/infinispan/client/runtime/graal/DisableLoggingFeature.java index edb073b1e6320..178a83bc3f6fd 100644 --- a/extensions/infinispan-client/runtime/src/main/java/io/quarkus/infinispan/client/runtime/graal/DisableLoggingFeature.java +++ b/extensions/infinispan-client/runtime/src/main/java/io/quarkus/infinispan/client/runtime/graal/DisableLoggingFeature.java @@ -31,10 +31,8 @@ public void beforeAnalysis(BeforeAnalysisAccess access) { public void afterAnalysis(AfterAnalysisAccess access) { for (String category : CATEGORIES) { Level level = categoryMap.remove(category); - if (level != null) { - Logger logger = Logger.getLogger(category); - logger.setLevel(level); - } + Logger logger = Logger.getLogger(category); + logger.setLevel(level); } } diff --git a/extensions/websockets/client/runtime/src/main/java/io/quarkus/websockets/client/runtime/DisableLoggingFeature.java b/extensions/websockets/client/runtime/src/main/java/io/quarkus/websockets/client/runtime/DisableLoggingFeature.java index 022507620961e..b8e723d990eb4 100644 --- a/extensions/websockets/client/runtime/src/main/java/io/quarkus/websockets/client/runtime/DisableLoggingFeature.java +++ b/extensions/websockets/client/runtime/src/main/java/io/quarkus/websockets/client/runtime/DisableLoggingFeature.java @@ -31,10 +31,8 @@ public void beforeAnalysis(BeforeAnalysisAccess access) { public void afterAnalysis(AfterAnalysisAccess access) { for (String category : CATEGORIES) { Level level = categoryMap.remove(category); - if (level != null) { - Logger logger = Logger.getLogger(category); - logger.setLevel(level); - } + Logger logger = Logger.getLogger(category); + logger.setLevel(level); } }