From 2d6da1341eba8b5a40a043ad9ce83894be4cc4b5 Mon Sep 17 00:00:00 2001 From: Joe Di Pol Date: Wed, 18 Dec 2024 16:22:56 -0800 Subject: [PATCH 1/6] Remove jersey wadl logging setting --- .../files/src/main/resources/logging.properties.mustache | 3 --- 1 file changed, 3 deletions(-) diff --git a/archetypes/archetypes/src/main/archetype/mp/common/files/src/main/resources/logging.properties.mustache b/archetypes/archetypes/src/main/archetype/mp/common/files/src/main/resources/logging.properties.mustache index dac99e33461..40e77eff6ea 100644 --- a/archetypes/archetypes/src/main/archetype/mp/common/files/src/main/resources/logging.properties.mustache +++ b/archetypes/archetypes/src/main/archetype/mp/common/files/src/main/resources/logging.properties.mustache @@ -20,9 +20,6 @@ java.util.logging.SimpleFormatter.format=%1$tY.%1$tm.%1$td %1$tH:%1$tM:%1$tS %4$ # Quiet Weld org.jboss.level=WARNING -# Quiet Jersey wadl support -org.glassfish.jersey.server.wadl.level=SEVERE - # Component specific log levels #io.helidon.config.level=INFO #io.helidon.security.level=INFO From be56db78af71b8a8a20016565d80d16d3d2150be Mon Sep 17 00:00:00 2001 From: Joe Di Pol Date: Wed, 18 Dec 2024 16:23:23 -0800 Subject: [PATCH 2/6] Configure jersey: disable wadl feature. Disable DATASOURCE provider default --- .../io/helidon/microprofile/server/JaxRsService.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/microprofile/server/src/main/java/io/helidon/microprofile/server/JaxRsService.java b/microprofile/server/src/main/java/io/helidon/microprofile/server/JaxRsService.java index 5acf12c4a75..bab420231b1 100644 --- a/microprofile/server/src/main/java/io/helidon/microprofile/server/JaxRsService.java +++ b/microprofile/server/src/main/java/io/helidon/microprofile/server/JaxRsService.java @@ -66,6 +66,7 @@ import org.glassfish.jersey.server.ContainerRequest; import org.glassfish.jersey.server.ContainerResponse; import org.glassfish.jersey.server.ResourceConfig; +import org.glassfish.jersey.server.ServerProperties; import org.glassfish.jersey.server.spi.Container; import org.glassfish.jersey.server.spi.ContainerResponseWriter; @@ -96,6 +97,14 @@ private JaxRsService(ResourceConfig resourceConfig, static JaxRsService create(ResourceConfig resourceConfig, InjectionManager injectionManager) { + // Silence warnings from Jersey. See 9019 + if (!resourceConfig.hasProperty(CommonProperties.PROVIDER_DEFAULT_DISABLE)) { + resourceConfig.addProperties(Map.of(CommonProperties.PROVIDER_DEFAULT_DISABLE, "DATASOURCE")); + } + if (!resourceConfig.hasProperty(ServerProperties.WADL_FEATURE_DISABLE)) { + resourceConfig.addProperties(Map.of(ServerProperties.WADL_FEATURE_DISABLE, "true")); + } + InjectionManager ij = injectionManager == null ? null : new InjectionManagerWrapper(injectionManager, resourceConfig); ApplicationHandler appHandler = new ApplicationHandler(resourceConfig, new WebServerBinder(), From a72065db0056a9ecb3d7d7ffb1269f01ee5e1cf7 Mon Sep 17 00:00:00 2001 From: Joe Di Pol Date: Wed, 18 Dec 2024 17:16:19 -0800 Subject: [PATCH 3/6] Allow configuration of DATASOURCE provider suppression for tck test --- .../io/helidon/microprofile/server/JaxRsService.java | 9 ++++++--- .../resources/META-INF/microprofile-config.properties | 1 + 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/microprofile/server/src/main/java/io/helidon/microprofile/server/JaxRsService.java b/microprofile/server/src/main/java/io/helidon/microprofile/server/JaxRsService.java index bab420231b1..54e0145acd5 100644 --- a/microprofile/server/src/main/java/io/helidon/microprofile/server/JaxRsService.java +++ b/microprofile/server/src/main/java/io/helidon/microprofile/server/JaxRsService.java @@ -75,6 +75,7 @@ class JaxRsService implements HttpService { * If set to {@code "true"}, Jersey will ignore responses in exceptions. */ static final String IGNORE_EXCEPTION_RESPONSE = "jersey.config.client.ignoreExceptionResponse"; + static final String SUPPRESS_DATASOURCE_PROVIDER = "jersey.config.server.suppressDataSourceProvider"; private static final System.Logger LOGGER = System.getLogger(JaxRsService.class.getName()); private static final Type REQUEST_TYPE = (new GenericType>() { }).getType(); @@ -97,8 +98,11 @@ private JaxRsService(ResourceConfig resourceConfig, static JaxRsService create(ResourceConfig resourceConfig, InjectionManager injectionManager) { - // Silence warnings from Jersey. See 9019 - if (!resourceConfig.hasProperty(CommonProperties.PROVIDER_DEFAULT_DISABLE)) { + Config config = ConfigProvider.getConfig(); + + // Silence warnings from Jersey. See 9019. Allow overriding to pass tck + Boolean suppressDatasourceProvider = config.getOptionalValue(SUPPRESS_DATASOURCE_PROVIDER, Boolean.class).orElse(true); + if (!resourceConfig.hasProperty(CommonProperties.PROVIDER_DEFAULT_DISABLE) && suppressDatasourceProvider) { resourceConfig.addProperties(Map.of(CommonProperties.PROVIDER_DEFAULT_DISABLE, "DATASOURCE")); } if (!resourceConfig.hasProperty(ServerProperties.WADL_FEATURE_DISABLE)) { @@ -110,7 +114,6 @@ static JaxRsService create(ResourceConfig resourceConfig, InjectionManager injec new WebServerBinder(), ij); Container container = new HelidonJerseyContainer(appHandler); - Config config = ConfigProvider.getConfig(); // This configuration via system properties is for the Jersey Client API. Any // response in an exception will be mapped to an empty one to prevent data leaks diff --git a/microprofile/tests/tck/tck-restful/tck-restful-test/src/test/resources/META-INF/microprofile-config.properties b/microprofile/tests/tck/tck-restful/tck-restful-test/src/test/resources/META-INF/microprofile-config.properties index 82d86a2bd88..43ab42c5fee 100644 --- a/microprofile/tests/tck/tck-restful/tck-restful-test/src/test/resources/META-INF/microprofile-config.properties +++ b/microprofile/tests/tck/tck-restful/tck-restful-test/src/test/resources/META-INF/microprofile-config.properties @@ -15,3 +15,4 @@ # jersey.config.client.ignoreExceptionResponse=false +jersey.config.server.suppressDataSourceProvider=false From eb393b56428140057da8716ebba732de6428fd25 Mon Sep 17 00:00:00 2001 From: Joe Di Pol Date: Thu, 19 Dec 2024 08:31:40 -0800 Subject: [PATCH 4/6] Fix copyright --- .../src/test/resources/META-INF/microprofile-config.properties | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/microprofile/tests/tck/tck-restful/tck-restful-test/src/test/resources/META-INF/microprofile-config.properties b/microprofile/tests/tck/tck-restful/tck-restful-test/src/test/resources/META-INF/microprofile-config.properties index 43ab42c5fee..39f69790b03 100644 --- a/microprofile/tests/tck/tck-restful/tck-restful-test/src/test/resources/META-INF/microprofile-config.properties +++ b/microprofile/tests/tck/tck-restful/tck-restful-test/src/test/resources/META-INF/microprofile-config.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2023 Oracle and/or its affiliates. +# Copyright (c) 2023, 2024 Oracle and/or its affiliates. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -16,3 +16,4 @@ jersey.config.client.ignoreExceptionResponse=false jersey.config.server.suppressDataSourceProvider=false + From f47f42fd93522f2eff654e230c39da8858e75cfc Mon Sep 17 00:00:00 2001 From: Joe Di Pol Date: Thu, 19 Dec 2024 12:28:23 -0800 Subject: [PATCH 5/6] Use system properties to control datasource provider suppression --- .../java/io/helidon/microprofile/server/JaxRsService.java | 5 ++--- microprofile/tests/tck/tck-restful/tck-restful-test/pom.xml | 1 + .../test/resources/META-INF/microprofile-config.properties | 2 -- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/microprofile/server/src/main/java/io/helidon/microprofile/server/JaxRsService.java b/microprofile/server/src/main/java/io/helidon/microprofile/server/JaxRsService.java index 54e0145acd5..8bcfc477331 100644 --- a/microprofile/server/src/main/java/io/helidon/microprofile/server/JaxRsService.java +++ b/microprofile/server/src/main/java/io/helidon/microprofile/server/JaxRsService.java @@ -98,10 +98,8 @@ private JaxRsService(ResourceConfig resourceConfig, static JaxRsService create(ResourceConfig resourceConfig, InjectionManager injectionManager) { - Config config = ConfigProvider.getConfig(); - // Silence warnings from Jersey. See 9019. Allow overriding to pass tck - Boolean suppressDatasourceProvider = config.getOptionalValue(SUPPRESS_DATASOURCE_PROVIDER, Boolean.class).orElse(true); + boolean suppressDatasourceProvider = Boolean.parseBoolean(System.getProperty(SUPPRESS_DATASOURCE_PROVIDER, "true")); if (!resourceConfig.hasProperty(CommonProperties.PROVIDER_DEFAULT_DISABLE) && suppressDatasourceProvider) { resourceConfig.addProperties(Map.of(CommonProperties.PROVIDER_DEFAULT_DISABLE, "DATASOURCE")); } @@ -114,6 +112,7 @@ static JaxRsService create(ResourceConfig resourceConfig, InjectionManager injec new WebServerBinder(), ij); Container container = new HelidonJerseyContainer(appHandler); + Config config = ConfigProvider.getConfig(); // This configuration via system properties is for the Jersey Client API. Any // response in an exception will be mapped to an empty one to prevent data leaks diff --git a/microprofile/tests/tck/tck-restful/tck-restful-test/pom.xml b/microprofile/tests/tck/tck-restful/tck-restful-test/pom.xml index 2128082717a..443237d1aba 100644 --- a/microprofile/tests/tck/tck-restful/tck-restful-test/pom.xml +++ b/microprofile/tests/tck/tck-restful/tck-restful-test/pom.xml @@ -125,6 +125,7 @@ localhost 8080 false + false true false false diff --git a/microprofile/tests/tck/tck-restful/tck-restful-test/src/test/resources/META-INF/microprofile-config.properties b/microprofile/tests/tck/tck-restful/tck-restful-test/src/test/resources/META-INF/microprofile-config.properties index 39f69790b03..5d1380d785d 100644 --- a/microprofile/tests/tck/tck-restful/tck-restful-test/src/test/resources/META-INF/microprofile-config.properties +++ b/microprofile/tests/tck/tck-restful/tck-restful-test/src/test/resources/META-INF/microprofile-config.properties @@ -15,5 +15,3 @@ # jersey.config.client.ignoreExceptionResponse=false -jersey.config.server.suppressDataSourceProvider=false - From 0691090626e9dfc651b21cd9c1b844059312e521 Mon Sep 17 00:00:00 2001 From: Joe Di Pol Date: Mon, 23 Dec 2024 15:52:58 -0800 Subject: [PATCH 6/6] Change property name to disableDataSourceProvider, check MP config and sys props --- .../helidon/microprofile/server/JaxRsService.java | 14 +++++++++----- .../tests/tck/tck-restful/tck-restful-test/pom.xml | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/microprofile/server/src/main/java/io/helidon/microprofile/server/JaxRsService.java b/microprofile/server/src/main/java/io/helidon/microprofile/server/JaxRsService.java index 8bcfc477331..99ac98b1990 100644 --- a/microprofile/server/src/main/java/io/helidon/microprofile/server/JaxRsService.java +++ b/microprofile/server/src/main/java/io/helidon/microprofile/server/JaxRsService.java @@ -75,7 +75,7 @@ class JaxRsService implements HttpService { * If set to {@code "true"}, Jersey will ignore responses in exceptions. */ static final String IGNORE_EXCEPTION_RESPONSE = "jersey.config.client.ignoreExceptionResponse"; - static final String SUPPRESS_DATASOURCE_PROVIDER = "jersey.config.server.suppressDataSourceProvider"; + static final String DISABLE_DATASOURCE_PROVIDER = "jersey.config.server.disableDataSourceProvider"; private static final System.Logger LOGGER = System.getLogger(JaxRsService.class.getName()); private static final Type REQUEST_TYPE = (new GenericType>() { }).getType(); @@ -98,9 +98,14 @@ private JaxRsService(ResourceConfig resourceConfig, static JaxRsService create(ResourceConfig resourceConfig, InjectionManager injectionManager) { - // Silence warnings from Jersey. See 9019. Allow overriding to pass tck - boolean suppressDatasourceProvider = Boolean.parseBoolean(System.getProperty(SUPPRESS_DATASOURCE_PROVIDER, "true")); - if (!resourceConfig.hasProperty(CommonProperties.PROVIDER_DEFAULT_DISABLE) && suppressDatasourceProvider) { + Config config = ConfigProvider.getConfig(); + + // Silence warnings from Jersey by disabling the default data source provider. See 9019. + // To pass TCK we support a system property to control whether or not we disable the default provider + // We also support the property via MicroProfile config in case a user wants to control the property. + boolean disableDatasourceProvider = config.getOptionalValue(DISABLE_DATASOURCE_PROVIDER, Boolean.class) + .orElseGet(() -> Boolean.parseBoolean(System.getProperty(DISABLE_DATASOURCE_PROVIDER, "true"))); + if (!resourceConfig.hasProperty(CommonProperties.PROVIDER_DEFAULT_DISABLE) && disableDatasourceProvider) { resourceConfig.addProperties(Map.of(CommonProperties.PROVIDER_DEFAULT_DISABLE, "DATASOURCE")); } if (!resourceConfig.hasProperty(ServerProperties.WADL_FEATURE_DISABLE)) { @@ -112,7 +117,6 @@ static JaxRsService create(ResourceConfig resourceConfig, InjectionManager injec new WebServerBinder(), ij); Container container = new HelidonJerseyContainer(appHandler); - Config config = ConfigProvider.getConfig(); // This configuration via system properties is for the Jersey Client API. Any // response in an exception will be mapped to an empty one to prevent data leaks diff --git a/microprofile/tests/tck/tck-restful/tck-restful-test/pom.xml b/microprofile/tests/tck/tck-restful/tck-restful-test/pom.xml index 443237d1aba..874d2705de4 100644 --- a/microprofile/tests/tck/tck-restful/tck-restful-test/pom.xml +++ b/microprofile/tests/tck/tck-restful/tck-restful-test/pom.xml @@ -125,7 +125,7 @@ localhost 8080 false - false + false true false false