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: Use System.Logger instead of JUL where applicable #7792 #8791

Merged
merged 4 commits into from
May 29, 2024
Merged
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
5 changes: 1 addition & 4 deletions common/common/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2023 Oracle and/or its affiliates.
* Copyright (c) 2017, 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 All @@ -19,9 +19,6 @@
*/
module io.helidon.common {

// used only by LogConfig
requires java.logging;

exports io.helidon.common;

}
12 changes: 12 additions & 0 deletions common/configurable/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,18 @@
</path>
</annotationProcessorPaths>
</configuration>
<executions>
<execution>
<id>default-testCompile</id>
<configuration>
<!-- We use JUL from tests, need this for compilation -->
<compilerArgs>
<compilerArg>--add-modules</compilerArg>
<compilerArg>java.logging</compilerArg>
</compilerArgs>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>io.helidon.config</groupId>
Expand Down
2 changes: 1 addition & 1 deletion common/configurable/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2023 Oracle and/or its affiliates.
* Copyright (c) 2018, 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
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, 2022 Oracle and/or its affiliates.
* Copyright (c) 2019, 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
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2022 Oracle and/or its affiliates.
* Copyright (c) 2017, 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 All @@ -22,8 +22,6 @@
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.Optional;
import java.util.logging.Level;
import java.util.logging.Logger;

import io.helidon.common.media.type.MediaType;
import io.helidon.common.media.type.MediaTypes;
Expand Down Expand Up @@ -51,7 +49,7 @@
public class EtcdConfigSource extends AbstractConfigSource
implements PollableSource<Long>, WatchableSource<EtcdEndpoint>, ParsableSource {

private static final Logger LOGGER = Logger.getLogger(EtcdConfigSource.class.getName());
private static final System.Logger LOGGER = System.getLogger(EtcdConfigSource.class.getName());

private final EtcdEndpoint endpoint;
private final List<EtcdEndpoint> endpoints;
Expand Down Expand Up @@ -119,7 +117,7 @@ public Optional<Content> load() throws ConfigException {
try {
content = etcdClient().get(endpoint.key());
} catch (EtcdClientException e) {
LOGGER.log(Level.FINEST, "Get operation threw an exception.", e);
LOGGER.log(System.Logger.Level.TRACE, "Get operation threw an exception.", e);
throw new ConfigException(String.format("Could not get data for key '%s'", endpoint.key()), e);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2020 Oracle and/or its affiliates.
* Copyright (c) 2017, 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 All @@ -19,8 +19,6 @@
import java.util.concurrent.Flow;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Consumer;
import java.util.logging.Level;
import java.util.logging.Logger;

import io.helidon.config.Config;
import io.helidon.config.etcd.EtcdConfigSourceBuilder.EtcdEndpoint;
Expand All @@ -34,7 +32,7 @@
*/
public class EtcdWatcher implements ChangeWatcher<EtcdEndpoint> {

private static final Logger LOGGER = Logger.getLogger(EtcdWatcher.class.getName());
private static final System.Logger LOGGER = System.getLogger(EtcdWatcher.class.getName());

private final AtomicBoolean started = new AtomicBoolean();

Expand Down Expand Up @@ -80,7 +78,7 @@ public void start(EtcdEndpoint endpoint, Consumer<ChangeEvent<EtcdEndpoint>> lis
Flow.Publisher<Long> watchPublisher = etcdClient().watch(endpoint.key());
watchPublisher.subscribe(new EtcdWatchSubscriber(listener, endpoint));
} catch (EtcdClientException ex) {
LOGGER.log(Level.WARNING, String.format("Subscription on watching on '%s' key has failed. "
LOGGER.log(System.Logger.Level.WARNING, String.format("Subscription on watching on '%s' key has failed. "
+ "Watching by '%s' polling strategy will not start.",
EtcdWatcher.this.endpoint.key(),
EtcdWatcher.this), ex);
Expand All @@ -96,7 +94,7 @@ public void stop() {
try {
this.etcdClient.close();
} catch (EtcdClientException e) {
LOGGER.log(Level.FINE, "Faield to close etcd client", e);
LOGGER.log(System.Logger.Level.TRACE, "Faield to close etcd client", e);
}
}

Expand Down Expand Up @@ -142,7 +140,7 @@ public void onNext(Long item) {

@Override
public void onError(Throwable throwable) {
LOGGER.log(Level.WARNING,
LOGGER.log(System.Logger.Level.WARNING,
String.format(
"Watching on '%s' key has failed. Watching will not continue. ",
endpoint.key()),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2023 Oracle and/or its affiliates.
* Copyright (c) 2017, 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 All @@ -25,8 +25,6 @@
import java.util.concurrent.SubmissionPublisher;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.logging.Level;
import java.util.logging.Logger;

import io.helidon.config.etcd.internal.client.EtcdClient;
import io.helidon.config.etcd.internal.client.EtcdClientException;
Expand All @@ -45,7 +43,7 @@

public class EtcdV2Client implements EtcdClient {

private static final Logger LOGGER = Logger.getLogger(EtcdV2Client.class.getName());
private static final System.Logger LOGGER = System.getLogger(EtcdV2Client.class.getName());

private final Map<String, SubmissionPublisher<Long>> publishers = new ConcurrentHashMap<>();
private final mousio.etcd4j.EtcdClient etcd;
Expand Down Expand Up @@ -150,7 +148,7 @@ public void onResponse(ResponsePromise<EtcdKeysResponse> responsePromise) {
publisher.submit(modifiedIndex);
waitForChange(modifiedIndex + 1);
} catch (Exception e) {
LOGGER.log(Level.CONFIG, "Cannot read changed value.", e);
LOGGER.log(System.Logger.Level.INFO, "Cannot read changed value.", e);
}

}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2021 Oracle and/or its affiliates.
* Copyright (c) 2017, 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 All @@ -23,8 +23,6 @@
import java.util.concurrent.Flow;
import java.util.concurrent.SubmissionPublisher;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.logging.Logger;

import io.helidon.config.etcd.internal.client.EtcdClient;
import io.helidon.config.etcd.internal.client.EtcdClientException;
Expand All @@ -48,7 +46,7 @@
*/
public class EtcdV3Client implements EtcdClient {

private static final Logger LOGGER = Logger.getLogger(EtcdV3Client.class.getName());
private static final System.Logger LOGGER = System.getLogger(EtcdV3Client.class.getName());

private final Map<String, SubmissionPublisher<Long>> publishers = new ConcurrentHashMap<>();

Expand Down Expand Up @@ -148,7 +146,7 @@ public void close() throws EtcdClientException {
try {
channel.awaitTermination(1, TimeUnit.SECONDS);
} catch (InterruptedException e) {
LOGGER.log(Level.CONFIG, "Error closing gRPC channel, reason: " + e.getLocalizedMessage(), e);
LOGGER.log(System.Logger.Level.INFO, "Error closing gRPC channel, reason: " + e.getLocalizedMessage(), e);
} finally {
channel.shutdown();
}
Expand Down
3 changes: 1 addition & 2 deletions config/etcd/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2023 Oracle and/or its affiliates.
* Copyright (c) 2017, 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 Expand Up @@ -29,7 +29,6 @@
requires io.grpc.stub;
requires io.helidon.common.media.type;
requires io.helidon.common;
requires java.logging;

requires static java.annotation;

Expand Down
3 changes: 1 addition & 2 deletions config/hocon/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2023 Oracle and/or its affiliates.
* Copyright (c) 2017, 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 Expand Up @@ -29,7 +29,6 @@
module io.helidon.config.hocon {

requires io.helidon.common;
requires java.logging;
requires typesafe.config;

requires static io.helidon.common.features.api;
Expand Down
3 changes: 1 addition & 2 deletions config/yaml/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2023 Oracle and/or its affiliates.
* Copyright (c) 2017, 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 Expand Up @@ -28,7 +28,6 @@
module io.helidon.config.yaml {

requires io.helidon.common;
requires java.logging;
requires org.yaml.snakeyaml;

requires static io.helidon.common.features.api;
Expand Down
3 changes: 1 addition & 2 deletions cors/src/main/java/io/helidon/cors/Aggregator.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import java.util.Optional;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Supplier;
import java.util.logging.Logger;

import io.helidon.common.config.Config;
import io.helidon.common.config.ConfigValue;
Expand Down Expand Up @@ -53,7 +52,7 @@ public class Aggregator {
*/
public static final String PATHLESS_KEY = "{+}";

private static final Logger LOGGER = Logger.getLogger(Aggregator.class.getName());
private static final System.Logger LOGGER = System.getLogger(Aggregator.class.getName());

// Records paths and configs added via addCrossOriginConfig
private final List<CrossOriginConfigMatchable> crossOriginConfigMatchables = new ArrayList<>();
Expand Down
6 changes: 3 additions & 3 deletions cors/src/main/java/io/helidon/cors/CorsSupportHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import java.util.StringTokenizer;
import java.util.function.BiFunction;
import java.util.function.Supplier;
import java.util.logging.Logger;

import io.helidon.common.config.Config;
import io.helidon.common.uri.UriInfo;
Expand Down Expand Up @@ -59,7 +58,7 @@ public class CorsSupportHelper<Q, R> {
static final String METHOD_NOT_IN_ALLOWED_LIST = "CORS method is not in allowed list";
static final String HEADERS_NOT_IN_ALLOWED_LIST = "CORS headers not in allowed list";

static final Logger LOGGER = Logger.getLogger(CorsSupportHelper.class.getName());
static final System.Logger LOGGER = System.getLogger(CorsSupportHelper.class.getName());

static final String OPAQUE_ORIGIN = "null"; // browsers might send this as Origin header if origin info is untrusted

Expand Down Expand Up @@ -240,7 +239,8 @@ public CorsSupportHelper<Q, R> build() {

CorsSupportHelper<Q, R> result = new CorsSupportHelper<>(this);

LOGGER.config(() -> String.format("CorsSupportHelper configured as: %s", result.toString()));
LOGGER.log(System.Logger.Level.INFO,
() -> String.format("CorsSupportHelper configured as: %s", result.toString()));

return result;
}
Expand Down
10 changes: 4 additions & 6 deletions cors/src/main/java/io/helidon/cors/LogHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
import java.util.StringJoiner;
import java.util.function.BiConsumer;
import java.util.function.Function;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.stream.Collectors;

import io.helidon.cors.CorsSupportHelper.RequestType;
Expand All @@ -36,8 +34,8 @@

class LogHelper {

static final Level DECISION_LEVEL = Level.FINE;
static final Level DETAILED_DECISION_LEVEL = Level.FINER;
static final System.Logger.Level DECISION_LEVEL = System.Logger.Level.TRACE;
static final System.Logger.Level DETAILED_DECISION_LEVEL = System.Logger.Level.TRACE;

private LogHelper() {
}
Expand Down Expand Up @@ -177,11 +175,11 @@ static <T> void logInferRequestType(RequestType result,

static class MatcherChecks<T> {
private final Map<CrossOriginConfig, MatcherCheck> checks;
private final Logger logger;
private final System.Logger logger;
private final boolean isLoggable;
private final Function<T, CrossOriginConfig> getter;

MatcherChecks(Logger logger, Function<T, CrossOriginConfig> getter) {
MatcherChecks(System.Logger logger, Function<T, CrossOriginConfig> getter) {
this.logger = logger;
isLoggable = logger.isLoggable(DETAILED_DECISION_LEVEL);
this.getter = getter;
Expand Down
3 changes: 1 addition & 2 deletions cors/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, 2023 Oracle and/or its affiliates.
* Copyright (c) 2022, 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 All @@ -19,7 +19,6 @@
*/
module io.helidon.cors {

requires java.logging;
requires io.helidon.http;
requires io.helidon.common.config;

Expand Down
3 changes: 1 addition & 2 deletions dbclient/dbclient/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, 2023 Oracle and/or its affiliates.
* Copyright (c) 2019, 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 Expand Up @@ -31,7 +31,6 @@
)
module io.helidon.dbclient {

requires java.logging;
requires java.sql;

requires static io.helidon.common.features.api;
Expand Down
4 changes: 2 additions & 2 deletions dbclient/jsonp/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, 2023 Oracle and/or its affiliates.
* Copyright (c) 2019, 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 Expand Up @@ -29,7 +29,7 @@

requires io.helidon.dbclient;
requires jakarta.json;
requires java.logging;

requires static io.helidon.common.features.api;

exports io.helidon.dbclient.jsonp;
Expand Down
Loading