Skip to content

Commit 20bbebb

Browse files
committed
Ensure Spring LogFactory contains all public methods from Apache LogFactory
Closes gh-30668
1 parent 26f0065 commit 20bbebb

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
@@ -53,8 +53,9 @@ public Log getInstance(String name) {
5353
}
5454

5555

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

58+
@Override
5859
public void setAttribute(String name, Object value) {
5960
if (value != null) {
6061
this.attributes.put(name, value);
@@ -64,19 +65,19 @@ public void setAttribute(String name, Object value) {
6465
}
6566
}
6667

68+
@Override
6769
public void removeAttribute(String name) {
6870
this.attributes.remove(name);
6971
}
7072

73+
@Override
7174
public Object getAttribute(String name) {
7275
return this.attributes.get(name);
7376
}
7477

78+
@Override
7579
public String[] getAttributeNames() {
7680
return this.attributes.keySet().toArray(new String[0]);
7781
}
7882

79-
public void release() {
80-
}
81-
8283
}

0 commit comments

Comments
 (0)