Skip to content

Commit 3c4bbd8

Browse files
authored
4.x silence jersey warnings (#9613)
* Remove jersey wadl logging setting * Configure jersey: disable wadl feature. Disable DATASOURCE provider default * Allow configuration of DATASOURCE provider suppression for tck test * Use system properties to control datasource provider suppression * Change property name to disableDataSourceProvider, check MP config and sys props
1 parent 7d9e03d commit 3c4bbd8

File tree

4 files changed

+19
-6
lines changed

4 files changed

+19
-6
lines changed

archetypes/archetypes/src/main/archetype/mp/common/files/src/main/resources/logging.properties.mustache

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@ java.util.logging.SimpleFormatter.format=%1$tY.%1$tm.%1$td %1$tH:%1$tM:%1$tS %4$
2020
# Quiet Weld
2121
org.jboss.level=WARNING
2222

23-
# Quiet Jersey wadl support
24-
org.glassfish.jersey.server.wadl.level=SEVERE
25-
2623
# Component specific log levels
2724
#io.helidon.config.level=INFO
2825
#io.helidon.security.level=INFO

microprofile/server/src/main/java/io/helidon/microprofile/server/JaxRsService.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2022, 2024 Oracle and/or its affiliates.
2+
* Copyright (c) 2022, 2025 Oracle and/or its affiliates.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -66,6 +66,7 @@
6666
import org.glassfish.jersey.server.ContainerRequest;
6767
import org.glassfish.jersey.server.ContainerResponse;
6868
import org.glassfish.jersey.server.ResourceConfig;
69+
import org.glassfish.jersey.server.ServerProperties;
6970
import org.glassfish.jersey.server.spi.Container;
7071
import org.glassfish.jersey.server.spi.ContainerResponseWriter;
7172

@@ -74,6 +75,7 @@ class JaxRsService implements HttpService {
7475
* If set to {@code "true"}, Jersey will ignore responses in exceptions.
7576
*/
7677
static final String IGNORE_EXCEPTION_RESPONSE = "jersey.config.client.ignoreExceptionResponse";
78+
static final String DISABLE_DATASOURCE_PROVIDER = "jersey.config.server.disableDataSourceProvider";
7779

7880
private static final System.Logger LOGGER = System.getLogger(JaxRsService.class.getName());
7981
private static final Type REQUEST_TYPE = (new GenericType<Ref<ServerRequest>>() { }).getType();
@@ -96,12 +98,25 @@ private JaxRsService(ResourceConfig resourceConfig,
9698

9799
static JaxRsService create(ResourceConfig resourceConfig, InjectionManager injectionManager) {
98100

101+
Config config = ConfigProvider.getConfig();
102+
103+
// Silence warnings from Jersey by disabling the default data source provider. See 9019.
104+
// To pass TCK we support a system property to control whether or not we disable the default provider
105+
// We also support the property via MicroProfile config in case a user wants to control the property.
106+
boolean disableDatasourceProvider = config.getOptionalValue(DISABLE_DATASOURCE_PROVIDER, Boolean.class)
107+
.orElseGet(() -> Boolean.parseBoolean(System.getProperty(DISABLE_DATASOURCE_PROVIDER, "true")));
108+
if (!resourceConfig.hasProperty(CommonProperties.PROVIDER_DEFAULT_DISABLE) && disableDatasourceProvider) {
109+
resourceConfig.addProperties(Map.of(CommonProperties.PROVIDER_DEFAULT_DISABLE, "DATASOURCE"));
110+
}
111+
if (!resourceConfig.hasProperty(ServerProperties.WADL_FEATURE_DISABLE)) {
112+
resourceConfig.addProperties(Map.of(ServerProperties.WADL_FEATURE_DISABLE, "true"));
113+
}
114+
99115
InjectionManager ij = injectionManager == null ? null : new InjectionManagerWrapper(injectionManager, resourceConfig);
100116
ApplicationHandler appHandler = new ApplicationHandler(resourceConfig,
101117
new WebServerBinder(),
102118
ij);
103119
Container container = new HelidonJerseyContainer(appHandler);
104-
Config config = ConfigProvider.getConfig();
105120

106121
// This configuration via system properties is for the Jersey Client API. Any
107122
// response in an exception will be mapped to an empty one to prevent data leaks

microprofile/tests/tck/tck-restful/tck-restful-test/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@
125125
<webServerHost>localhost</webServerHost>
126126
<webServerPort>8080</webServerPort>
127127
<jersey.config.client.ignoreExceptionResponse>false</jersey.config.client.ignoreExceptionResponse>
128+
<jersey.config.server.disableDataSourceProvider>false</jersey.config.server.disableDataSourceProvider>
128129
<jersey.config.allowSystemPropertiesProvider>true</jersey.config.allowSystemPropertiesProvider>
129130
<org.jboss.weld.bootstrap.concurrentDeployment>false</org.jboss.weld.bootstrap.concurrentDeployment>
130131
<org.jboss.weld.construction.relaxed>false</org.jboss.weld.construction.relaxed>

microprofile/tests/tck/tck-restful/tck-restful-test/src/test/resources/META-INF/microprofile-config.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2023 Oracle and/or its affiliates.
2+
# Copyright (c) 2023, 2025 Oracle and/or its affiliates.
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");
55
# you may not use this file except in compliance with the License.

0 commit comments

Comments
 (0)