This is an automated email from the ASF dual-hosted git repository. pkarwasz pushed a commit to branch fix/backport-log4j3-api in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git
commit 5d68b0970cb6ba892429dbce5b5b4e4d67cdd00c Author: Piotr P. Karwasz <[email protected]> AuthorDate: Fri Mar 15 10:05:24 2024 +0100 Remove deprecations from functional interfaces --- .../map/UnmodifiableArrayBackedMapTest.java | 30 ++---- .../java/org/apache/logging/log4j/LogBuilder.java | 110 +++++++++++++-------- .../java/org/apache/logging/log4j/LogManager.java | 35 ++++--- .../main/java/org/apache/logging/log4j/Logger.java | 66 +++---------- .../org/apache/logging/log4j/util/BiConsumer.java | 4 +- .../org/apache/logging/log4j/util/LambdaUtil.java | 3 - .../apache/logging/log4j/util/MessageSupplier.java | 4 +- .../org/apache/logging/log4j/util/Supplier.java | 5 +- 8 files changed, 119 insertions(+), 138 deletions(-) diff --git a/log4j-api-test/src/test/java/org/apache/logging/log4j/internal/map/UnmodifiableArrayBackedMapTest.java b/log4j-api-test/src/test/java/org/apache/logging/log4j/internal/map/UnmodifiableArrayBackedMapTest.java index efcee80a15..9652034d70 100644 --- a/log4j-api-test/src/test/java/org/apache/logging/log4j/internal/map/UnmodifiableArrayBackedMapTest.java +++ b/log4j-api-test/src/test/java/org/apache/logging/log4j/internal/map/UnmodifiableArrayBackedMapTest.java @@ -24,6 +24,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.fail; import java.util.ArrayList; +import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; @@ -31,6 +32,7 @@ import java.util.LinkedHashMap; import java.util.LinkedHashSet; import java.util.Map; import java.util.Set; +import org.apache.logging.log4j.util.ReadOnlyStringMap; import org.apache.logging.log4j.util.TriConsumer; import org.junit.jupiter.api.Test; @@ -238,32 +240,18 @@ public class UnmodifiableArrayBackedMapTest { @Test public void testForEachBiConsumer_JavaUtil() { - UnmodifiableArrayBackedMap map = UnmodifiableArrayBackedMap.EMPTY_MAP.copyAndPutAll(getTestParameters()); - Set<String> keys = new HashSet<>(); - java.util.function.BiConsumer<String, String> java_util_action = - new java.util.function.BiConsumer<String, String>() { - @Override - public void accept(String key, String value) { - keys.add(key); - } - }; - map.forEach(java_util_action); + final Map<String, String> map = UnmodifiableArrayBackedMap.EMPTY_MAP.copyAndPutAll(getTestParameters()); + final Collection<String> keys = new HashSet<>(); + map.forEach((key, value) -> keys.add(key)); assertEquals(map.keySet(), keys); } @Test public void testForEachBiConsumer_Log4jUtil() { - UnmodifiableArrayBackedMap map = UnmodifiableArrayBackedMap.EMPTY_MAP.copyAndPutAll(getTestParameters()); - Set<String> keys = new HashSet<>(); - org.apache.logging.log4j.util.BiConsumer<String, String> log4j_util_action = - new org.apache.logging.log4j.util.BiConsumer<String, String>() { - @Override - public void accept(String key, String value) { - keys.add(key); - } - }; - map.forEach(log4j_util_action); - assertEquals(map.keySet(), keys); + final ReadOnlyStringMap map = UnmodifiableArrayBackedMap.EMPTY_MAP.copyAndPutAll(getTestParameters()); + final Collection<String> keys = new HashSet<>(); + map.forEach((key, value) -> keys.add(key)); + assertEquals(map.toMap().keySet(), keys); } @Test diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/LogBuilder.java b/log4j-api/src/main/java/org/apache/logging/log4j/LogBuilder.java index 91d3083e4a..992d287513 100644 --- a/log4j-api/src/main/java/org/apache/logging/log4j/LogBuilder.java +++ b/log4j-api/src/main/java/org/apache/logging/log4j/LogBuilder.java @@ -32,7 +32,7 @@ public interface LogBuilder { * @param marker The Marker to log. * @return The LogBuilder. */ - default LogBuilder withMarker(Marker marker) { + default LogBuilder withMarker(final Marker marker) { return this; } @@ -41,7 +41,7 @@ public interface LogBuilder { * @param throwable The Throwable to log. * @return the LogBuilder. */ - default LogBuilder withThrowable(Throwable throwable) { + default LogBuilder withThrowable(final Throwable throwable) { return this; } @@ -59,7 +59,7 @@ public interface LogBuilder { * @param location The stack trace element to include in the log event. * @return The LogBuilder. */ - default LogBuilder withLocation(StackTraceElement location) { + default LogBuilder withLocation(final StackTraceElement location) { return this; } @@ -67,13 +67,13 @@ public interface LogBuilder { * Causes all the data collected to be logged along with the message. Interface default method does nothing. * @param message The message to log. */ - default void log(CharSequence message) {} + default void log(final CharSequence message) {} /** * Causes all the data collected to be logged along with the message. Interface default method does nothing. * @param message The message to log. */ - default void log(String message) {} + default void log(final String message) {} /** * Logs a message with parameters. Interface default method does nothing. @@ -83,7 +83,7 @@ public interface LogBuilder { * * @see org.apache.logging.log4j.util.Unbox */ - default void log(String message, Object... params) {} + default void log(final String message, final Object... params) {} /** * Causes all the data collected to be logged along with the message and parameters. @@ -91,21 +91,19 @@ public interface LogBuilder { * @param message The message. * @param params Parameters to the message. */ - @SuppressWarnings("deprecation") - default void log(String message, Supplier<?>... params) {} + default void log(final String message, final Supplier<?>... params) {} /** * Causes all the data collected to be logged along with the message. Interface default method does nothing. * @param message The message to log. */ - default void log(Message message) {} + default void log(final Message message) {} /** * Causes all the data collected to be logged along with the message. Interface default method does nothing. * @param messageSupplier The supplier of the message to log. */ - @SuppressWarnings("deprecation") - default void log(Supplier<Message> messageSupplier) {} + default void log(final Supplier<Message> messageSupplier) {} /** * Causes all the data collected to be logged along with the message. @@ -114,7 +112,6 @@ public interface LogBuilder { * @return the message logger or {@code null} if no logging occurred. * @since 2.20 */ - @SuppressWarnings("deprecation") default Message logAndGet(final Supplier<Message> messageSupplier) { return null; } @@ -123,7 +120,7 @@ public interface LogBuilder { * Causes all the data collected to be logged along with the message. Interface default method does nothing. * @param message The message to log. */ - default void log(Object message) {} + default void log(final Object message) {} /** * Logs a message with parameters. Interface default method does nothing. @@ -133,7 +130,7 @@ public interface LogBuilder { * * @see org.apache.logging.log4j.util.Unbox */ - default void log(String message, Object p0) {} + default void log(final String message, final Object p0) {} /** * Logs a message with parameters. Interface default method does nothing. @@ -144,7 +141,7 @@ public interface LogBuilder { * * @see org.apache.logging.log4j.util.Unbox */ - default void log(String message, Object p0, Object p1) {} + default void log(final String message, final Object p0, final Object p1) {} /** * Logs a message with parameters. Interface default method does nothing. @@ -156,7 +153,7 @@ public interface LogBuilder { * * @see org.apache.logging.log4j.util.Unbox */ - default void log(String message, Object p0, Object p1, Object p2) {} + default void log(final String message, final Object p0, final Object p1, final Object p2) {} /** * Logs a message with parameters. Interface default method does nothing. @@ -169,7 +166,7 @@ public interface LogBuilder { * * @see org.apache.logging.log4j.util.Unbox */ - default void log(String message, Object p0, Object p1, Object p2, Object p3) {} + default void log(final String message, final Object p0, final Object p1, final Object p2, final Object p3) {} /** * Logs a message with parameters. Interface default method does nothing. @@ -183,7 +180,13 @@ public interface LogBuilder { * * @see org.apache.logging.log4j.util.Unbox */ - default void log(String message, Object p0, Object p1, Object p2, Object p3, Object p4) {} + default void log( + final String message, + final Object p0, + final Object p1, + final Object p2, + final Object p3, + final Object p4) {} /** * Logs a message with parameters. Interface default method does nothing. @@ -198,7 +201,14 @@ public interface LogBuilder { * * @see org.apache.logging.log4j.util.Unbox */ - default void log(String message, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5) {} + default void log( + final String message, + final Object p0, + final Object p1, + final Object p2, + final Object p3, + final Object p4, + final Object p5) {} /** * Logs a message with parameters. @@ -214,7 +224,15 @@ public interface LogBuilder { * * @see org.apache.logging.log4j.util.Unbox */ - default void log(String message, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5, Object p6) {} + default void log( + final String message, + final Object p0, + final Object p1, + final Object p2, + final Object p3, + final Object p4, + final Object p5, + final Object p6) {} /** * Logs a message with parameters. Interface default method does nothing. @@ -232,7 +250,15 @@ public interface LogBuilder { * @see org.apache.logging.log4j.util.Unbox */ default void log( - String message, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5, Object p6, Object p7) {} + final String message, + final Object p0, + final Object p1, + final Object p2, + final Object p3, + final Object p4, + final Object p5, + final Object p6, + final Object p7) {} /** * Logs a message with parameters. Interface default method does nothing. @@ -251,16 +277,16 @@ public interface LogBuilder { * @see org.apache.logging.log4j.util.Unbox */ default void log( - String message, - Object p0, - Object p1, - Object p2, - Object p3, - Object p4, - Object p5, - Object p6, - Object p7, - Object p8) {} + final String message, + final Object p0, + final Object p1, + final Object p2, + final Object p3, + final Object p4, + final Object p5, + final Object p6, + final Object p7, + final Object p8) {} /** * Logs a message with parameters. Interface default method does nothing. @@ -280,17 +306,17 @@ public interface LogBuilder { * @see org.apache.logging.log4j.util.Unbox */ default void log( - String message, - Object p0, - Object p1, - Object p2, - Object p3, - Object p4, - Object p5, - Object p6, - Object p7, - Object p8, - Object p9) {} + final String message, + final Object p0, + final Object p1, + final Object p2, + final Object p3, + final Object p4, + final Object p5, + final Object p6, + final Object p7, + final Object p8, + final Object p9) {} /** * Causes all the data collected to be logged. Default implementatoin does nothing. diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java b/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java index d7def7ac7e..cdb91c5765 100644 --- a/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java +++ b/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java @@ -41,7 +41,7 @@ import org.apache.logging.log4j.util.Strings; public class LogManager { /** - * Log4j property to set to the fully qualified class name of a custom implementation of + * Log4j's property to set to the fully qualified class name of a custom implementation of * {@link LoggerContextFactory}. * @deprecated Replaced since 2.24.0 with {@value org.apache.logging.log4j.spi.Provider#PROVIDER_PROPERTY_NAME}. */ @@ -49,7 +49,7 @@ public class LogManager { public static final String FACTORY_PROPERTY_NAME = "log4j2.loggerContextFactory"; /** - * The name of the root Logger is {@value #ROOT_LOGGER_NAME}. + * The name of the root Logger. */ public static final String ROOT_LOGGER_NAME = Strings.EMPTY; @@ -315,10 +315,10 @@ public class LogManager { /** * Shutdown using the LoggerContext appropriate for the caller of this method. * This is equivalent to calling {@code LogManager.shutdown(false)}. - * - * This call is synchronous and will block until shut down is complete. - * This may include flushing pending log events over network connections. - * + * <p> + * This call is synchronous and will block until shut down is complete. This may include flushing pending log + * events over network connections. + * </p> * @since 2.6 */ public static void shutdown() { @@ -328,9 +328,10 @@ public class LogManager { /** * Shutdown the logging system if the logging system supports it. * This is equivalent to calling {@code LogManager.shutdown(LogManager.getContext(currentContext))}. - * - * This call is synchronous and will block until shut down is complete. - * This may include flushing pending log events over network connections. + * <p> + * This call is synchronous and will block until shut down is complete. This may include flushing pending log + * events over network connections. + * </p> * * @param currentContext if true a default LoggerContext (may not be the LoggerContext used to create a Logger * for the calling class) will be used. @@ -347,9 +348,10 @@ public class LogManager { /** * Shutdown the logging system if the logging system supports it. * This is equivalent to calling {@code LogManager.shutdown(LogManager.getContext(currentContext))}. - * - * This call is synchronous and will block until shut down is complete. - * This may include flushing pending log events over network connections. + * <p> + * This call is synchronous and will block until shut down is complete. This may include flushing pending log + * events over network connections. + * </p> * * @param currentContext if true a default LoggerContext (may not be the LoggerContext used to create a Logger * for the calling class) will be used. @@ -366,9 +368,10 @@ public class LogManager { /** * Shutdown the logging system if the logging system supports it. - * - * This call is synchronous and will block until shut down is complete. - * This may include flushing pending log events over network connections. + * <p> + * This call is synchronous and will block until shut down is complete. This may include flushing pending log + * events over network connections. + * </p> * * @param context the LoggerContext. * @since 2.6 @@ -461,7 +464,7 @@ public class LogManager { * Short-hand for {@code getLogger(value, StringFormatterMessageFactory.INSTANCE)} * </p> * - * @param value The value's whose class name should be used as the Logger name. + * @param value The value whose class name should be used as the Logger name. * @return The Logger, created with a {@link StringFormatterMessageFactory} * @throws UnsupportedOperationException if {@code value} is {@code null} and the calling class cannot be * determined. diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/Logger.java b/log4j-api/src/main/java/org/apache/logging/log4j/Logger.java index 7dc872e21a..ef461ddfe3 100644 --- a/log4j-api/src/main/java/org/apache/logging/log4j/Logger.java +++ b/log4j-api/src/main/java/org/apache/logging/log4j/Logger.java @@ -200,7 +200,6 @@ public interface Logger { * @param paramSuppliers An array of functions, which when called, produce the desired log message parameters. * @since 2.4 */ - @SuppressWarnings("deprecation") void debug(Marker marker, String message, Supplier<?>... paramSuppliers); /** @@ -222,7 +221,6 @@ public interface Logger { * message factory. * @since 2.4 */ - @SuppressWarnings("deprecation") void debug(Marker marker, Supplier<?> messageSupplier); /** @@ -235,7 +233,6 @@ public interface Logger { * @param throwable A Throwable or null. * @since 2.4 */ - @SuppressWarnings("deprecation") void debug(Marker marker, Supplier<?> messageSupplier, Throwable throwable); /** @@ -329,7 +326,6 @@ public interface Logger { * @param paramSuppliers An array of functions, which when called, produce the desired log message parameters. * @since 2.4 */ - @SuppressWarnings("deprecation") void debug(String message, Supplier<?>... paramSuppliers); /** @@ -348,7 +344,6 @@ public interface Logger { * message factory. * @since 2.4 */ - @SuppressWarnings("deprecation") void debug(Supplier<?> messageSupplier); /** @@ -360,7 +355,6 @@ public interface Logger { * @param throwable the {@code Throwable} to log, including its stack trace. * @since 2.4 */ - @SuppressWarnings("deprecation") void debug(Supplier<?> messageSupplier, Throwable throwable); /** @@ -811,7 +805,6 @@ public interface Logger { * @param paramSuppliers An array of functions, which when called, produce the desired log message parameters. * @since 2.4 */ - @SuppressWarnings("deprecation") void error(Marker marker, String message, Supplier<?>... paramSuppliers); /** @@ -833,7 +826,6 @@ public interface Logger { * message factory. * @since 2.4 */ - @SuppressWarnings("deprecation") void error(Marker marker, Supplier<?> messageSupplier); /** @@ -846,7 +838,6 @@ public interface Logger { * @param throwable A Throwable or null. * @since 2.4 */ - @SuppressWarnings("deprecation") void error(Marker marker, Supplier<?> messageSupplier, Throwable throwable); /** @@ -940,7 +931,6 @@ public interface Logger { * @param paramSuppliers An array of functions, which when called, produce the desired log message parameters. * @since 2.4 */ - @SuppressWarnings("deprecation") void error(String message, Supplier<?>... paramSuppliers); /** @@ -959,7 +949,6 @@ public interface Logger { * message factory. * @since 2.4 */ - @SuppressWarnings("deprecation") void error(Supplier<?> messageSupplier); /** @@ -971,7 +960,6 @@ public interface Logger { * @param throwable the {@code Throwable} to log, including its stack trace. * @since 2.4 */ - @SuppressWarnings("deprecation") void error(Supplier<?> messageSupplier, Throwable throwable); /** @@ -1414,7 +1402,6 @@ public interface Logger { * @param paramSuppliers An array of functions, which when called, produce the desired log message parameters. * @since 2.4 */ - @SuppressWarnings("deprecation") void fatal(Marker marker, String message, Supplier<?>... paramSuppliers); /** @@ -1436,7 +1423,6 @@ public interface Logger { * message factory. * @since 2.4 */ - @SuppressWarnings("deprecation") void fatal(Marker marker, Supplier<?> messageSupplier); /** @@ -1449,7 +1435,6 @@ public interface Logger { * @param throwable A Throwable or null. * @since 2.4 */ - @SuppressWarnings("deprecation") void fatal(Marker marker, Supplier<?> messageSupplier, Throwable throwable); /** @@ -1543,7 +1528,6 @@ public interface Logger { * @param paramSuppliers An array of functions, which when called, produce the desired log message parameters. * @since 2.4 */ - @SuppressWarnings("deprecation") void fatal(String message, Supplier<?>... paramSuppliers); /** @@ -1562,7 +1546,6 @@ public interface Logger { * message factory. * @since 2.4 */ - @SuppressWarnings("deprecation") void fatal(Supplier<?> messageSupplier); /** @@ -1574,7 +1557,6 @@ public interface Logger { * @param throwable the {@code Throwable} to log, including its stack trace. * @since 2.4 */ - @SuppressWarnings("deprecation") void fatal(Supplier<?> messageSupplier, Throwable throwable); /** @@ -1901,12 +1883,13 @@ public interface Logger { /** * Gets the message factory used to convert message Objects and Strings/CharSequences into actual log Messages. - * - * Since version 2.6, Log4j internally uses message factories that implement the {@link MessageFactory2} interface. - * From version 2.6.2, the return type of this method was changed from {@link MessageFactory} to - * {@code <MF extends MessageFactory> MF}. The returned factory will always implement {@link MessageFactory2}, - * but the return type of this method could not be changed to {@link MessageFactory2} without breaking binary - * compatibility. + * <p> + * Since version 2.6, Log4j internally uses message factories that implement the {@link MessageFactory2} + * interface. From version 2.6.2, the return type of this method was changed from {@link MessageFactory} to + * {@code <MF extends MessageFactory> MF}. The returned factory will always implement {@link MessageFactory2}, + * but the return type of this method could not be changed to {@link MessageFactory2} without breaking binary + * compatibility. + * </p> * * @return the message factory, as an instance of {@link MessageFactory2} */ @@ -2030,7 +2013,6 @@ public interface Logger { * @param paramSuppliers An array of functions, which when called, produce the desired log message parameters. * @since 2.4 */ - @SuppressWarnings("deprecation") void info(Marker marker, String message, Supplier<?>... paramSuppliers); /** @@ -2052,7 +2034,6 @@ public interface Logger { * message factory. * @since 2.4 */ - @SuppressWarnings("deprecation") void info(Marker marker, Supplier<?> messageSupplier); /** @@ -2065,7 +2046,6 @@ public interface Logger { * @param throwable A Throwable or null. * @since 2.4 */ - @SuppressWarnings("deprecation") void info(Marker marker, Supplier<?> messageSupplier, Throwable throwable); /** @@ -2159,7 +2139,6 @@ public interface Logger { * @param paramSuppliers An array of functions, which when called, produce the desired log message parameters. * @since 2.4 */ - @SuppressWarnings("deprecation") void info(String message, Supplier<?>... paramSuppliers); /** @@ -2178,7 +2157,6 @@ public interface Logger { * message factory. * @since 2.4 */ - @SuppressWarnings("deprecation") void info(Supplier<?> messageSupplier); /** @@ -2190,7 +2168,6 @@ public interface Logger { * @param throwable the {@code Throwable} to log, including its stack trace. * @since 2.4 */ - @SuppressWarnings("deprecation") void info(Supplier<?> messageSupplier, Throwable throwable); /** @@ -2737,7 +2714,6 @@ public interface Logger { * @param paramSuppliers An array of functions, which when called, produce the desired log message parameters. * @since 2.4 */ - @SuppressWarnings("deprecation") void log(Level level, Marker marker, String message, Supplier<?>... paramSuppliers); /** @@ -2760,7 +2736,6 @@ public interface Logger { * message factory. * @since 2.4 */ - @SuppressWarnings("deprecation") void log(Level level, Marker marker, Supplier<?> messageSupplier); /** @@ -2774,7 +2749,6 @@ public interface Logger { * @param throwable A Throwable or null. * @since 2.4 */ - @SuppressWarnings("deprecation") void log(Level level, Marker marker, Supplier<?> messageSupplier, Throwable throwable); /** @@ -2878,7 +2852,6 @@ public interface Logger { * @param paramSuppliers An array of functions, which when called, produce the desired log message parameters. * @since 2.4 */ - @SuppressWarnings("deprecation") void log(Level level, String message, Supplier<?>... paramSuppliers); /** @@ -2899,7 +2872,6 @@ public interface Logger { * message factory. * @since 2.4 */ - @SuppressWarnings("deprecation") void log(Level level, Supplier<?> messageSupplier); /** @@ -2912,7 +2884,6 @@ public interface Logger { * @param throwable the {@code Throwable} to log, including its stack log. * @since 2.4 */ - @SuppressWarnings("deprecation") void log(Level level, Supplier<?> messageSupplier, Throwable throwable); /** @@ -3435,7 +3406,6 @@ public interface Logger { * @param paramSuppliers An array of functions, which when called, produce the desired log message parameters. * @since 2.4 */ - @SuppressWarnings("deprecation") void trace(Marker marker, String message, Supplier<?>... paramSuppliers); /** @@ -3458,7 +3428,6 @@ public interface Logger { * message factory. * @since 2.4 */ - @SuppressWarnings("deprecation") void trace(Marker marker, Supplier<?> messageSupplier); /** @@ -3471,7 +3440,6 @@ public interface Logger { * @param throwable A Throwable or null. * @since 2.4 */ - @SuppressWarnings("deprecation") void trace(Marker marker, Supplier<?> messageSupplier, Throwable throwable); /** @@ -3567,7 +3535,6 @@ public interface Logger { * @param paramSuppliers An array of functions, which when called, produce the desired log message parameters. * @since 2.4 */ - @SuppressWarnings("deprecation") void trace(String message, Supplier<?>... paramSuppliers); /** @@ -3587,7 +3554,6 @@ public interface Logger { * message factory. * @since 2.4 */ - @SuppressWarnings("deprecation") void trace(Supplier<?> messageSupplier); /** @@ -3599,7 +3565,6 @@ public interface Logger { * @param throwable the {@code Throwable} to log, including its stack trace. * @since 2.4 */ - @SuppressWarnings("deprecation") void trace(Supplier<?> messageSupplier, Throwable throwable); /** @@ -3967,7 +3932,6 @@ public interface Logger { * * @since 2.6 */ - @SuppressWarnings("deprecation") EntryMessage traceEntry(Supplier<?>... paramSuppliers); /** @@ -3986,7 +3950,6 @@ public interface Logger { * * @since 2.6 */ - @SuppressWarnings("deprecation") EntryMessage traceEntry(String format, Supplier<?>... paramSuppliers); /** @@ -4205,7 +4168,6 @@ public interface Logger { * @param paramSuppliers An array of functions, which when called, produce the desired log message parameters. * @since 2.4 */ - @SuppressWarnings("deprecation") void warn(Marker marker, String message, Supplier<?>... paramSuppliers); /** @@ -4227,7 +4189,6 @@ public interface Logger { * message factory. * @since 2.4 */ - @SuppressWarnings("deprecation") void warn(Marker marker, Supplier<?> messageSupplier); /** @@ -4240,7 +4201,6 @@ public interface Logger { * @param throwable A Throwable or null. * @since 2.4 */ - @SuppressWarnings("deprecation") void warn(Marker marker, Supplier<?> messageSupplier, Throwable throwable); /** @@ -4334,7 +4294,6 @@ public interface Logger { * @param paramSuppliers An array of functions, which when called, produce the desired log message parameters. * @since 2.4 */ - @SuppressWarnings("deprecation") void warn(String message, Supplier<?>... paramSuppliers); /** @@ -4353,7 +4312,6 @@ public interface Logger { * message factory. * @since 2.4 */ - @SuppressWarnings("deprecation") void warn(Supplier<?> messageSupplier); /** @@ -4365,7 +4323,6 @@ public interface Logger { * @param throwable the {@code Throwable} to log, including its stack warn. * @since 2.4 */ - @SuppressWarnings("deprecation") void warn(Supplier<?> messageSupplier, Throwable throwable); /** @@ -4695,7 +4652,12 @@ public interface Logger { * @since 2.13.0 */ default void logMessage( - Level level, Marker marker, String fqcn, StackTraceElement location, Message message, Throwable throwable) { + final Level level, + final Marker marker, + final String fqcn, + final StackTraceElement location, + final Message message, + final Throwable throwable) { // noop } @@ -4768,7 +4730,7 @@ public interface Logger { * @return a LogBuilder. * @since 2.13.0 */ - default LogBuilder atLevel(Level level) { + default LogBuilder atLevel(final Level level) { return LogBuilder.NOOP; } } diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/util/BiConsumer.java b/log4j-api/src/main/java/org/apache/logging/log4j/util/BiConsumer.java index 7be09f0431..e7cedb6bb3 100644 --- a/log4j-api/src/main/java/org/apache/logging/log4j/util/BiConsumer.java +++ b/log4j-api/src/main/java/org/apache/logging/log4j/util/BiConsumer.java @@ -24,12 +24,14 @@ package org.apache.logging.log4j.util; * @see ReadOnlyStringMap * @since 2.7 */ -public interface BiConsumer<K, V> { +@FunctionalInterface +public interface BiConsumer<K, V> extends java.util.function.BiConsumer<K, V> { /** * Performs the operation given the specified arguments. * @param k the first input argument * @param v the second input argument */ + @Override void accept(K k, V v); } diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/util/LambdaUtil.java b/log4j-api/src/main/java/org/apache/logging/log4j/util/LambdaUtil.java index bab3171e7f..ef1f3b0b32 100644 --- a/log4j-api/src/main/java/org/apache/logging/log4j/util/LambdaUtil.java +++ b/log4j-api/src/main/java/org/apache/logging/log4j/util/LambdaUtil.java @@ -35,7 +35,6 @@ public final class LambdaUtil { * @return an array containing the results of evaluating the lambda expressions (or {@code null} if the suppliers * array was {@code null} */ - @SuppressWarnings("deprecation") public static Object[] getAll(final Supplier<?>... suppliers) { if (suppliers == null) { return null; @@ -54,7 +53,6 @@ public final class LambdaUtil { * @return the results of evaluating the lambda expression (or {@code null} if the supplier * was {@code null} */ - @SuppressWarnings("deprecation") public static Object get(final Supplier<?> supplier) { if (supplier == null) { return null; @@ -83,7 +81,6 @@ public final class LambdaUtil { * @return the Message resulting from evaluating the lambda expression or the Message created by the factory for * supplied values that are not of type Message */ - @SuppressWarnings("deprecation") public static Message getMessage(final Supplier<?> supplier, final MessageFactory messageFactory) { if (supplier == null) { return null; diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/util/MessageSupplier.java b/log4j-api/src/main/java/org/apache/logging/log4j/util/MessageSupplier.java index 8b13571350..d3776a1a74 100644 --- a/log4j-api/src/main/java/org/apache/logging/log4j/util/MessageSupplier.java +++ b/log4j-api/src/main/java/org/apache/logging/log4j/util/MessageSupplier.java @@ -33,12 +33,14 @@ import org.apache.logging.log4j.message.Message; * * @since 2.4 */ -public interface MessageSupplier { +@FunctionalInterface +public interface MessageSupplier extends Supplier<Message> { /** * Gets a Message. * * @return a Message */ + @Override Message get(); } diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/util/Supplier.java b/log4j-api/src/main/java/org/apache/logging/log4j/util/Supplier.java index aaa4d9b89a..45ad5c667d 100644 --- a/log4j-api/src/main/java/org/apache/logging/log4j/util/Supplier.java +++ b/log4j-api/src/main/java/org/apache/logging/log4j/util/Supplier.java @@ -31,14 +31,15 @@ package org.apache.logging.log4j.util; * * @since 2.4 */ +@FunctionalInterface @InternalApi -@Deprecated -public interface Supplier<T> { +public interface Supplier<T> extends java.util.function.Supplier<T> { /** * Gets a value. * * @return a value */ + @Override T get(); }
