Skip to content

Commit

Permalink
4.x: Use System.Logger instead of JUL where applicable #7792
Browse files Browse the repository at this point in the history
Signed-off-by: Jorge Bescos Gascon <jorge.bescos.gascon@oracle.com>
  • Loading branch information
jbescos committed May 23, 2024
1 parent e0a91cb commit 7ef9851
Show file tree
Hide file tree
Showing 68 changed files with 218 additions and 254 deletions.
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;

}
3 changes: 2 additions & 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 All @@ -24,6 +24,7 @@
requires io.helidon.builder.api;
requires io.helidon.common.context;
requires java.management;
requires java.logging;

requires transitive io.helidon.common.config;
requires transitive io.helidon.common;
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
4 changes: 2 additions & 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,7 @@
requires io.grpc.stub;
requires io.helidon.common.media.type;
requires io.helidon.common;
requires java.logging;


requires static java.annotation;

Expand Down
4 changes: 2 additions & 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,7 @@
module io.helidon.config.hocon {

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

requires typesafe.config;

requires static io.helidon.common.features.api;
Expand Down
4 changes: 2 additions & 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,7 @@
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
4 changes: 2 additions & 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,7 @@
*/
module io.helidon.cors {

requires java.logging;

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

Expand Down
4 changes: 2 additions & 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,7 @@
)
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
1 change: 1 addition & 0 deletions helidon/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
// this is required due to a bug in JDK (see Main for details and link)
requires java.logging;


requires io.helidon.common;
requires io.helidon.logging.common;

Expand Down
Loading

0 comments on commit 7ef9851

Please sign in to comment.