From a72065db0056a9ecb3d7d7ffb1269f01ee5e1cf7 Mon Sep 17 00:00:00 2001 From: Joe Di Pol Date: Wed, 18 Dec 2024 17:16:19 -0800 Subject: [PATCH] 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