Skip to content

Commit

Permalink
Deprecate org.apache.commons.logging.LogSource.jdk14IsAvailable
Browse files Browse the repository at this point in the history
  • Loading branch information
garydgregory committed May 11, 2024
1 parent f60da7b commit e377509
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/changes/changes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ The <action> type attribute can be add,update,fix,remove.
<release version="1.3.2" date="2024-05-11" description="This is a feature and maintenance release. Java 8 or later is required.">
<action dev="ggregory" issue="LOGGING-190" type="fix" due-to="Hannes Wellmann, Gary Gregory, Johan Compagner">Add OSGi metadata to enable Service Loader Mediator #234.</action>
<action dev="ggregory" issue="LOGGING-191" type="fix" due-to="Hannes Wellmann, Gary Gregory, Johan Compagner">Apache commons logging shows 1.4 as latest release instead of 1.3.1.</action>
<action dev="ggregory" type="fix" due-to="Gary Gregory">Deprecate org.apache.commons.logging.LogSource.jdk14IsAvailable.</action>
<!-- UPDATE -->
<action dev="ggregory" type="update" due-to="Dependabot">Bump org.apache.commons:commons-parent from 67 to 69 #240.</action>
<action dev="ggregory" type="update" due-to="Dependabot">Bump org.slf4j:slf4j-api from 2.0.12 to 2.0.13 #248.</action>
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/org/apache/commons/logging/LogSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {
Expand All @@ -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 {
Expand Down
28 changes: 28 additions & 0 deletions src/test/java/org/apache/commons/logging/LogSourceTest.java
Original file line number Diff line number Diff line change
@@ -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);
}
}

0 comments on commit e377509

Please sign in to comment.