diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 14fbec0..f9701d9 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -46,6 +46,7 @@ The type attribute can be add,update,fix,remove. Add OSGi metadata to enable Service Loader Mediator #234. Apache commons logging shows 1.4 as latest release instead of 1.3.1. + Deprecate org.apache.commons.logging.LogSource.jdk14IsAvailable. Bump org.apache.commons:commons-parent from 67 to 69 #240. Bump org.slf4j:slf4j-api from 2.0.12 to 2.0.13 #248. diff --git a/src/main/java/org/apache/commons/logging/LogSource.java b/src/main/java/org/apache/commons/logging/LogSource.java index c594ab6..586573f 100644 --- a/src/main/java/org/apache/commons/logging/LogSource.java +++ b/src/main/java/org/apache/commons/logging/LogSource.java @@ -61,8 +61,13 @@ public class LogSource { /** Is Log4j available (in the current classpath) */ static protected boolean log4jIsAvailable; - /** Is JDK 1.4 logging available */ - static protected boolean jdk14IsAvailable; + /** + * Is JDK 1.4 logging available, always true. + * + * @deprecated Java 8 is the baseline and includes JUL. + */ + @Deprecated + static protected boolean jdk14IsAvailable = true; /** Constructor for current log class */ static protected Constructor logImplctor; @@ -77,9 +82,6 @@ public class LogSource { // Is Log4J Available? log4jIsAvailable = isClassForName("org.apache.log4j.Logger"); - // Is JDK 1.4 Logging Available? - jdk14IsAvailable = isClassForName("org.apache.commons.logging.impl.Jdk14Logger"); - // Set the default Log implementation String name = null; try { @@ -104,10 +106,8 @@ public class LogSource { try { if (log4jIsAvailable) { setLogImplementation("org.apache.commons.logging.impl.Log4JLogger"); - } else if (jdk14IsAvailable) { - setLogImplementation("org.apache.commons.logging.impl.Jdk14Logger"); } else { - setLogImplementation("org.apache.commons.logging.impl.NoOpLog"); + setLogImplementation("org.apache.commons.logging.impl.Jdk14Logger"); } } catch (final Throwable t) { try { diff --git a/src/test/java/org/apache/commons/logging/LogSourceTest.java b/src/test/java/org/apache/commons/logging/LogSourceTest.java new file mode 100644 index 0000000..cb572e2 --- /dev/null +++ b/src/test/java/org/apache/commons/logging/LogSourceTest.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.commons.logging; + +import static org.junit.jupiter.api.Assertions.assertTrue; + +public class LogSourceTest { + + @SuppressWarnings("deprecation") + public void testJdk14IsAvailable() throws Exception { + assertTrue(LogSource.jdk14IsAvailable); + } +}