Browse Source

Ensure Spring LogFactory contains all public methods from Apache LogFactory

Closes gh-30668
pull/30724/head
Juergen Hoeller 1 year ago
parent
commit
20bbebb299
  1. 45
      spring-jcl/src/main/java/org/apache/commons/logging/LogFactory.java
  2. 9
      spring-jcl/src/main/java/org/apache/commons/logging/LogFactoryService.java

45
spring-jcl/src/main/java/org/apache/commons/logging/LogFactory.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -102,4 +102,47 @@ public abstract class LogFactory { @@ -102,4 +102,47 @@ public abstract class LogFactory {
return getLog(name);
}
// Just in case some code happens to call uncommon Commons Logging methods...
@Deprecated
public Object getAttribute(String name) {
return null;
}
@Deprecated
public String[] getAttributeNames() {
return new String[0];
}
@Deprecated
public void removeAttribute(String name) {
// do nothing
}
@Deprecated
public void setAttribute(String name, Object value) {
// do nothing
}
@Deprecated
public void release() {
// do nothing
}
@Deprecated
public static void release(ClassLoader classLoader) {
// do nothing
}
@Deprecated
public static void releaseAll() {
// do nothing
}
@Deprecated
public static String objectId(Object o) {
return (o == null ? "null" : o.getClass().getName() + "@" + System.identityHashCode(o));
}
}

9
spring-jcl/src/main/java/org/apache/commons/logging/LogFactoryService.java

@ -53,8 +53,9 @@ public class LogFactoryService extends LogFactory { @@ -53,8 +53,9 @@ public class LogFactoryService extends LogFactory {
}
// Just in case some code happens to call uncommon Commons Logging methods...
// Just in case some code happens to rely on Commons Logging attributes...
@Override
public void setAttribute(String name, Object value) {
if (value != null) {
this.attributes.put(name, value);
@ -64,19 +65,19 @@ public class LogFactoryService extends LogFactory { @@ -64,19 +65,19 @@ public class LogFactoryService extends LogFactory {
}
}
@Override
public void removeAttribute(String name) {
this.attributes.remove(name);
}
@Override
public Object getAttribute(String name) {
return this.attributes.get(name);
}
@Override
public String[] getAttributeNames() {
return this.attributes.keySet().toArray(new String[0]);
}
public void release() {
}
}

Loading…
Cancel
Save