Skip to content

Commit c7bc40d

Browse files
committed
Ensure Spring LogFactory contains all public methods from Apache LogFactory
Closes gh-30668 (cherry picked from commit 20bbebb)
1 parent 1071778 commit c7bc40d

File tree

2 files changed

+49
-5
lines changed

2 files changed

+49
-5
lines changed

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

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -102,4 +102,47 @@ public Log getInstance(String name) {
102102
return getLog(name);
103103
}
104104

105+
106+
// Just in case some code happens to call uncommon Commons Logging methods...
107+
108+
@Deprecated
109+
public Object getAttribute(String name) {
110+
return null;
111+
}
112+
113+
@Deprecated
114+
public String[] getAttributeNames() {
115+
return new String[0];
116+
}
117+
118+
@Deprecated
119+
public void removeAttribute(String name) {
120+
// do nothing
121+
}
122+
123+
@Deprecated
124+
public void setAttribute(String name, Object value) {
125+
// do nothing
126+
}
127+
128+
@Deprecated
129+
public void release() {
130+
// do nothing
131+
}
132+
133+
@Deprecated
134+
public static void release(ClassLoader classLoader) {
135+
// do nothing
136+
}
137+
138+
@Deprecated
139+
public static void releaseAll() {
140+
// do nothing
141+
}
142+
143+
@Deprecated
144+
public static String objectId(Object o) {
145+
return (o == null ? "null" : o.getClass().getName() + "@" + System.identityHashCode(o));
146+
}
147+
105148
}

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,9 @@ public Log getInstance(String name) {
4747
}
4848

4949

50-
// Just in case some code happens to call uncommon Commons Logging methods...
50+
// Just in case some code happens to rely on Commons Logging attributes...
5151

52+
@Override
5253
public void setAttribute(String name, Object value) {
5354
if (value != null) {
5455
this.attributes.put(name, value);
@@ -58,19 +59,19 @@ public void setAttribute(String name, Object value) {
5859
}
5960
}
6061

62+
@Override
6163
public void removeAttribute(String name) {
6264
this.attributes.remove(name);
6365
}
6466

67+
@Override
6568
public Object getAttribute(String name) {
6669
return this.attributes.get(name);
6770
}
6871

72+
@Override
6973
public String[] getAttributeNames() {
7074
return this.attributes.keySet().toArray(new String[0]);
7175
}
7276

73-
public void release() {
74-
}
75-
7677
}

0 commit comments

Comments
 (0)