From bd69fa0635500f49e481c39f438a8932f55d321e Mon Sep 17 00:00:00 2001 From: Daniel Fuchs Date: Mon, 12 Oct 2015 20:13:22 +0200 Subject: [PATCH] 8033661: readConfiguration does not cleanly reinitialize the logging system Two new updateConfiguration methods have been added to LogManager: call updateConfiguration to update a configuration *after* the LogManager is initialized. Reviewed-by: mchung --- .../classes/java/util/logging/LogManager.java | 872 ++++++++++++++++-- .../HandlersOnComplexResetUpdate.java | 548 +++++++++++ .../HandlersOnComplexUpdate.java | 547 +++++++++++ ...SimpleUpdateConfigWithInputStreamTest.java | 685 ++++++++++++++ .../SimpleUpdateConfigurationTest.java | 720 +++++++++++++++ .../UpdateConfigurationTest.java | 608 ++++++++++++ 6 files changed, 3892 insertions(+), 88 deletions(-) create mode 100644 jdk/test/java/util/logging/LogManager/Configuration/updateConfiguration/HandlersOnComplexResetUpdate.java create mode 100644 jdk/test/java/util/logging/LogManager/Configuration/updateConfiguration/HandlersOnComplexUpdate.java create mode 100644 jdk/test/java/util/logging/LogManager/Configuration/updateConfiguration/SimpleUpdateConfigWithInputStreamTest.java create mode 100644 jdk/test/java/util/logging/LogManager/Configuration/updateConfiguration/SimpleUpdateConfigurationTest.java create mode 100644 jdk/test/java/util/logging/LogManager/Configuration/updateConfiguration/UpdateConfigurationTest.java diff --git a/jdk/src/java.logging/share/classes/java/util/logging/LogManager.java b/jdk/src/java.logging/share/classes/java/util/logging/LogManager.java index 110fca4d366..0ccb7f8fe97 100644 --- a/jdk/src/java.logging/share/classes/java/util/logging/LogManager.java +++ b/jdk/src/java.logging/share/classes/java/util/logging/LogManager.java @@ -32,8 +32,14 @@ import java.security.*; import java.lang.ref.ReferenceQueue; import java.lang.ref.WeakReference; import java.util.concurrent.ConcurrentHashMap; +import java.nio.file.Paths; import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.locks.ReentrantLock; +import java.util.function.BiFunction; +import java.util.function.Function; +import java.util.function.Predicate; +import java.util.stream.Collectors; +import java.util.stream.Stream; import jdk.internal.misc.JavaAWTAccess; import jdk.internal.misc.SharedSecrets; import sun.misc.ManagedLocalsThread; @@ -57,37 +63,28 @@ import sun.misc.ManagedLocalsThread; *

* At startup the LogManager class is located using the * java.util.logging.manager system property. + * + *

LogManager Configuration

+ * + * A LogManager initializes the logging configuration via + * the {@link #readConfiguration()} method during LogManager initialization. + * By default, LogManager default configuration is used. + * The logging configuration read by LogManager must be in the + * {@linkplain Properties properties file} format. *

* The LogManager defines two optional system properties that allow control over - * the initial configuration: + * the initial configuration, as specified in the {@link #readConfiguration()} + * method: *

- * These two properties may be specified on the command line to the "java" + *

+ * These two system properties may be specified on the command line to the "java" * command, or as system property definitions passed to JNI_CreateJavaVM. *

- * If the "java.util.logging.config.class" property is set, then the - * property value is treated as a class name. The given class will be - * loaded, an object will be instantiated, and that object's constructor - * is responsible for reading in the initial configuration. (That object - * may use other system properties to control its configuration.) The - * alternate configuration class can use {@code readConfiguration(InputStream)} - * to define properties in the LogManager. - *

- * If "java.util.logging.config.class" property is not set, - * then the "java.util.logging.config.file" system property can be used - * to specify a properties file (in java.util.Properties format). The - * initial logging configuration will be read from this file. - *

- * If neither of these properties is defined then the LogManager uses its - * default configuration. The default configuration is typically loaded from the - * properties file "{@code conf/logging.properties}" in the Java installation - * directory. - *

- * The properties for loggers and Handlers will have names starting - * with the dot-separated name for the handler or logger. - *

+ * The {@linkplain Properties properties} for loggers and Handlers will have + * names starting with the dot-separated name for the handler or logger.
* The global logging properties may include: *