Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4.x silence jersey warnings #9613

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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, 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.
Expand Down