From c7bc40d3ba323a94e8c43b1cd8f61de90b4f9e1f Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Wed, 21 Jun 2023 09:47:16 +0200 Subject: [PATCH] Ensure Spring LogFactory contains all public methods from Apache LogFactory Closes gh-30668 (cherry picked from commit 20bbebb29921815ec11ec4dc289419d50a5cd319) --- .../apache/commons/logging/LogFactory.java | 45 ++++++++++++++++++- .../commons/logging/LogFactoryService.java | 9 ++-- 2 files changed, 49 insertions(+), 5 deletions(-) diff --git a/spring-jcl/src/main/java/org/apache/commons/logging/LogFactory.java b/spring-jcl/src/main/java/org/apache/commons/logging/LogFactory.java index 0600afc8aa2c..e67eb5a4342a 100644 --- a/spring-jcl/src/main/java/org/apache/commons/logging/LogFactory.java +++ b/spring-jcl/src/main/java/org/apache/commons/logging/LogFactory.java @@ -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 Log getInstance(String name) { 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)); + } + } diff --git a/spring-jcl/src/main/java/org/apache/commons/logging/LogFactoryService.java b/spring-jcl/src/main/java/org/apache/commons/logging/LogFactoryService.java index ef82eb90c777..dc997af5256d 100644 --- a/spring-jcl/src/main/java/org/apache/commons/logging/LogFactoryService.java +++ b/spring-jcl/src/main/java/org/apache/commons/logging/LogFactoryService.java @@ -47,8 +47,9 @@ public Log getInstance(String name) { } - // 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); @@ -58,19 +59,19 @@ public void setAttribute(String name, Object value) { } } + @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() { - } - }