Skip to content

Commit

Permalink
4.x silence jersey warnings (#9613)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
barchetta authored Jan 7, 2025
1 parent 7d9e03d commit 3c4bbd8
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, 2024 Oracle and/or its affiliates.
* Copyright (c) 2022, 2025 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.
Expand Down Expand Up @@ -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;

Expand All @@ -74,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 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<Ref<ServerRequest>>() { }).getType();
Expand All @@ -96,12 +98,25 @@ private JaxRsService(ResourceConfig resourceConfig,

static JaxRsService create(ResourceConfig resourceConfig, InjectionManager injectionManager) {

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)) {
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(),
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@
<webServerHost>localhost</webServerHost>
<webServerPort>8080</webServerPort>
<jersey.config.client.ignoreExceptionResponse>false</jersey.config.client.ignoreExceptionResponse>
<jersey.config.server.disableDataSourceProvider>false</jersey.config.server.disableDataSourceProvider>
<jersey.config.allowSystemPropertiesProvider>true</jersey.config.allowSystemPropertiesProvider>
<org.jboss.weld.bootstrap.concurrentDeployment>false</org.jboss.weld.bootstrap.concurrentDeployment>
<org.jboss.weld.construction.relaxed>false</org.jboss.weld.construction.relaxed>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2023 Oracle and/or its affiliates.
# Copyright (c) 2023, 2025 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.
Expand Down

0 comments on commit 3c4bbd8

Please sign in to comment.