Skip to content

Commit ffe06dd

Browse files
committedMar 22, 2024
Remove deprecations from functional interfaces
1 parent 9b455b2 commit ffe06dd

File tree

8 files changed

+119
-138
lines changed

8 files changed

+119
-138
lines changed
 

‎log4j-api-test/src/test/java/org/apache/logging/log4j/internal/map/UnmodifiableArrayBackedMapTest.java

+9-21
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,15 @@
2424
import static org.junit.jupiter.api.Assertions.fail;
2525

2626
import java.util.ArrayList;
27+
import java.util.Collection;
2728
import java.util.Collections;
2829
import java.util.HashMap;
2930
import java.util.HashSet;
3031
import java.util.LinkedHashMap;
3132
import java.util.LinkedHashSet;
3233
import java.util.Map;
3334
import java.util.Set;
35+
import org.apache.logging.log4j.util.ReadOnlyStringMap;
3436
import org.apache.logging.log4j.util.TriConsumer;
3537
import org.junit.jupiter.api.Test;
3638

@@ -238,32 +240,18 @@ public void testEqualsWhenOneValueDiffers() {
238240

239241
@Test
240242
public void testForEachBiConsumer_JavaUtil() {
241-
UnmodifiableArrayBackedMap map = UnmodifiableArrayBackedMap.EMPTY_MAP.copyAndPutAll(getTestParameters());
242-
Set<String> keys = new HashSet<>();
243-
java.util.function.BiConsumer<String, String> java_util_action =
244-
new java.util.function.BiConsumer<String, String>() {
245-
@Override
246-
public void accept(String key, String value) {
247-
keys.add(key);
248-
}
249-
};
250-
map.forEach(java_util_action);
243+
final Map<String, String> map = UnmodifiableArrayBackedMap.EMPTY_MAP.copyAndPutAll(getTestParameters());
244+
final Collection<String> keys = new HashSet<>();
245+
map.forEach((key, value) -> keys.add(key));
251246
assertEquals(map.keySet(), keys);
252247
}
253248

254249
@Test
255250
public void testForEachBiConsumer_Log4jUtil() {
256-
UnmodifiableArrayBackedMap map = UnmodifiableArrayBackedMap.EMPTY_MAP.copyAndPutAll(getTestParameters());
257-
Set<String> keys = new HashSet<>();
258-
org.apache.logging.log4j.util.BiConsumer<String, String> log4j_util_action =
259-
new org.apache.logging.log4j.util.BiConsumer<String, String>() {
260-
@Override
261-
public void accept(String key, String value) {
262-
keys.add(key);
263-
}
264-
};
265-
map.forEach(log4j_util_action);
266-
assertEquals(map.keySet(), keys);
251+
final ReadOnlyStringMap map = UnmodifiableArrayBackedMap.EMPTY_MAP.copyAndPutAll(getTestParameters());
252+
final Collection<String> keys = new HashSet<>();
253+
map.forEach((key, value) -> keys.add(key));
254+
assertEquals(map.toMap().keySet(), keys);
267255
}
268256

269257
@Test

‎log4j-api/src/main/java/org/apache/logging/log4j/LogBuilder.java

+68-42
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public interface LogBuilder {
3232
* @param marker The Marker to log.
3333
* @return The LogBuilder.
3434
*/
35-
default LogBuilder withMarker(Marker marker) {
35+
default LogBuilder withMarker(final Marker marker) {
3636
return this;
3737
}
3838

@@ -41,7 +41,7 @@ default LogBuilder withMarker(Marker marker) {
4141
* @param throwable The Throwable to log.
4242
* @return the LogBuilder.
4343
*/
44-
default LogBuilder withThrowable(Throwable throwable) {
44+
default LogBuilder withThrowable(final Throwable throwable) {
4545
return this;
4646
}
4747

@@ -59,21 +59,21 @@ default LogBuilder withLocation() {
5959
* @param location The stack trace element to include in the log event.
6060
* @return The LogBuilder.
6161
*/
62-
default LogBuilder withLocation(StackTraceElement location) {
62+
default LogBuilder withLocation(final StackTraceElement location) {
6363
return this;
6464
}
6565

6666
/**
6767
* Causes all the data collected to be logged along with the message. Interface default method does nothing.
6868
* @param message The message to log.
6969
*/
70-
default void log(CharSequence message) {}
70+
default void log(final CharSequence message) {}
7171

7272
/**
7373
* Causes all the data collected to be logged along with the message. Interface default method does nothing.
7474
* @param message The message to log.
7575
*/
76-
default void log(String message) {}
76+
default void log(final String message) {}
7777

7878
/**
7979
* Logs a message with parameters. Interface default method does nothing.
@@ -83,29 +83,27 @@ default void log(String message) {}
8383
*
8484
* @see org.apache.logging.log4j.util.Unbox
8585
*/
86-
default void log(String message, Object... params) {}
86+
default void log(final String message, final Object... params) {}
8787

8888
/**
8989
* Causes all the data collected to be logged along with the message and parameters.
9090
* Interface default method does nothing.
9191
* @param message The message.
9292
* @param params Parameters to the message.
9393
*/
94-
@SuppressWarnings("deprecation")
95-
default void log(String message, Supplier<?>... params) {}
94+
default void log(final String message, final Supplier<?>... params) {}
9695

9796
/**
9897
* Causes all the data collected to be logged along with the message. Interface default method does nothing.
9998
* @param message The message to log.
10099
*/
101-
default void log(Message message) {}
100+
default void log(final Message message) {}
102101

103102
/**
104103
* Causes all the data collected to be logged along with the message. Interface default method does nothing.
105104
* @param messageSupplier The supplier of the message to log.
106105
*/
107-
@SuppressWarnings("deprecation")
108-
default void log(Supplier<Message> messageSupplier) {}
106+
default void log(final Supplier<Message> messageSupplier) {}
109107

110108
/**
111109
* Causes all the data collected to be logged along with the message.
@@ -114,7 +112,6 @@ default void log(Supplier<Message> messageSupplier) {}
114112
* @return the message logger or {@code null} if no logging occurred.
115113
* @since 2.20
116114
*/
117-
@SuppressWarnings("deprecation")
118115
default Message logAndGet(final Supplier<Message> messageSupplier) {
119116
return null;
120117
}
@@ -123,7 +120,7 @@ default Message logAndGet(final Supplier<Message> messageSupplier) {
123120
* Causes all the data collected to be logged along with the message. Interface default method does nothing.
124121
* @param message The message to log.
125122
*/
126-
default void log(Object message) {}
123+
default void log(final Object message) {}
127124

128125
/**
129126
* Logs a message with parameters. Interface default method does nothing.
@@ -133,7 +130,7 @@ default void log(Object message) {}
133130
*
134131
* @see org.apache.logging.log4j.util.Unbox
135132
*/
136-
default void log(String message, Object p0) {}
133+
default void log(final String message, final Object p0) {}
137134

138135
/**
139136
* Logs a message with parameters. Interface default method does nothing.
@@ -144,7 +141,7 @@ default void log(String message, Object p0) {}
144141
*
145142
* @see org.apache.logging.log4j.util.Unbox
146143
*/
147-
default void log(String message, Object p0, Object p1) {}
144+
default void log(final String message, final Object p0, final Object p1) {}
148145

149146
/**
150147
* Logs a message with parameters. Interface default method does nothing.
@@ -156,7 +153,7 @@ default void log(String message, Object p0, Object p1) {}
156153
*
157154
* @see org.apache.logging.log4j.util.Unbox
158155
*/
159-
default void log(String message, Object p0, Object p1, Object p2) {}
156+
default void log(final String message, final Object p0, final Object p1, final Object p2) {}
160157

161158
/**
162159
* Logs a message with parameters. Interface default method does nothing.
@@ -169,7 +166,7 @@ default void log(String message, Object p0, Object p1, Object p2) {}
169166
*
170167
* @see org.apache.logging.log4j.util.Unbox
171168
*/
172-
default void log(String message, Object p0, Object p1, Object p2, Object p3) {}
169+
default void log(final String message, final Object p0, final Object p1, final Object p2, final Object p3) {}
173170

174171
/**
175172
* Logs a message with parameters. Interface default method does nothing.
@@ -183,7 +180,13 @@ default void log(String message, Object p0, Object p1, Object p2, Object p3) {}
183180
*
184181
* @see org.apache.logging.log4j.util.Unbox
185182
*/
186-
default void log(String message, Object p0, Object p1, Object p2, Object p3, Object p4) {}
183+
default void log(
184+
final String message,
185+
final Object p0,
186+
final Object p1,
187+
final Object p2,
188+
final Object p3,
189+
final Object p4) {}
187190

188191
/**
189192
* Logs a message with parameters. Interface default method does nothing.
@@ -198,7 +201,14 @@ default void log(String message, Object p0, Object p1, Object p2, Object p3, Obj
198201
*
199202
* @see org.apache.logging.log4j.util.Unbox
200203
*/
201-
default void log(String message, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5) {}
204+
default void log(
205+
final String message,
206+
final Object p0,
207+
final Object p1,
208+
final Object p2,
209+
final Object p3,
210+
final Object p4,
211+
final Object p5) {}
202212

203213
/**
204214
* Logs a message with parameters.
@@ -214,7 +224,15 @@ default void log(String message, Object p0, Object p1, Object p2, Object p3, Obj
214224
*
215225
* @see org.apache.logging.log4j.util.Unbox
216226
*/
217-
default void log(String message, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5, Object p6) {}
227+
default void log(
228+
final String message,
229+
final Object p0,
230+
final Object p1,
231+
final Object p2,
232+
final Object p3,
233+
final Object p4,
234+
final Object p5,
235+
final Object p6) {}
218236

219237
/**
220238
* Logs a message with parameters. Interface default method does nothing.
@@ -232,7 +250,15 @@ default void log(String message, Object p0, Object p1, Object p2, Object p3, Obj
232250
* @see org.apache.logging.log4j.util.Unbox
233251
*/
234252
default void log(
235-
String message, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5, Object p6, Object p7) {}
253+
final String message,
254+
final Object p0,
255+
final Object p1,
256+
final Object p2,
257+
final Object p3,
258+
final Object p4,
259+
final Object p5,
260+
final Object p6,
261+
final Object p7) {}
236262

237263
/**
238264
* Logs a message with parameters. Interface default method does nothing.
@@ -251,16 +277,16 @@ default void log(
251277
* @see org.apache.logging.log4j.util.Unbox
252278
*/
253279
default void log(
254-
String message,
255-
Object p0,
256-
Object p1,
257-
Object p2,
258-
Object p3,
259-
Object p4,
260-
Object p5,
261-
Object p6,
262-
Object p7,
263-
Object p8) {}
280+
final String message,
281+
final Object p0,
282+
final Object p1,
283+
final Object p2,
284+
final Object p3,
285+
final Object p4,
286+
final Object p5,
287+
final Object p6,
288+
final Object p7,
289+
final Object p8) {}
264290

265291
/**
266292
* Logs a message with parameters. Interface default method does nothing.
@@ -280,17 +306,17 @@ default void log(
280306
* @see org.apache.logging.log4j.util.Unbox
281307
*/
282308
default void log(
283-
String message,
284-
Object p0,
285-
Object p1,
286-
Object p2,
287-
Object p3,
288-
Object p4,
289-
Object p5,
290-
Object p6,
291-
Object p7,
292-
Object p8,
293-
Object p9) {}
309+
final String message,
310+
final Object p0,
311+
final Object p1,
312+
final Object p2,
313+
final Object p3,
314+
final Object p4,
315+
final Object p5,
316+
final Object p6,
317+
final Object p7,
318+
final Object p8,
319+
final Object p9) {}
294320

295321
/**
296322
* Causes all the data collected to be logged. Default implementatoin does nothing.

‎log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java

+19-16
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,15 @@
4141
public class LogManager {
4242

4343
/**
44-
* Log4j property to set to the fully qualified class name of a custom implementation of
44+
* Log4j's property to set to the fully qualified class name of a custom implementation of
4545
* {@link LoggerContextFactory}.
4646
* @deprecated Replaced since 2.24.0 with {@value org.apache.logging.log4j.spi.Provider#PROVIDER_PROPERTY_NAME}.
4747
*/
4848
@Deprecated
4949
public static final String FACTORY_PROPERTY_NAME = "log4j2.loggerContextFactory";
5050

5151
/**
52-
* The name of the root Logger is {@value #ROOT_LOGGER_NAME}.
52+
* The name of the root Logger.
5353
*/
5454
public static final String ROOT_LOGGER_NAME = Strings.EMPTY;
5555

@@ -315,10 +315,10 @@ protected static LoggerContext getContext(
315315
/**
316316
* Shutdown using the LoggerContext appropriate for the caller of this method.
317317
* This is equivalent to calling {@code LogManager.shutdown(false)}.
318-
*
319-
* This call is synchronous and will block until shut down is complete.
320-
* This may include flushing pending log events over network connections.
321-
*
318+
* <p>
319+
* This call is synchronous and will block until shut down is complete. This may include flushing pending log
320+
* events over network connections.
321+
* </p>
322322
* @since 2.6
323323
*/
324324
public static void shutdown() {
@@ -328,9 +328,10 @@ public static void shutdown() {
328328
/**
329329
* Shutdown the logging system if the logging system supports it.
330330
* This is equivalent to calling {@code LogManager.shutdown(LogManager.getContext(currentContext))}.
331-
*
332-
* This call is synchronous and will block until shut down is complete.
333-
* This may include flushing pending log events over network connections.
331+
* <p>
332+
* This call is synchronous and will block until shut down is complete. This may include flushing pending log
333+
* events over network connections.
334+
* </p>
334335
*
335336
* @param currentContext if true a default LoggerContext (may not be the LoggerContext used to create a Logger
336337
* for the calling class) will be used.
@@ -347,9 +348,10 @@ public static void shutdown(final boolean currentContext) {
347348
/**
348349
* Shutdown the logging system if the logging system supports it.
349350
* This is equivalent to calling {@code LogManager.shutdown(LogManager.getContext(currentContext))}.
350-
*
351-
* This call is synchronous and will block until shut down is complete.
352-
* This may include flushing pending log events over network connections.
351+
* <p>
352+
* This call is synchronous and will block until shut down is complete. This may include flushing pending log
353+
* events over network connections.
354+
* </p>
353355
*
354356
* @param currentContext if true a default LoggerContext (may not be the LoggerContext used to create a Logger
355357
* for the calling class) will be used.
@@ -366,9 +368,10 @@ public static void shutdown(final boolean currentContext, final boolean allConte
366368

367369
/**
368370
* Shutdown the logging system if the logging system supports it.
369-
*
370-
* This call is synchronous and will block until shut down is complete.
371-
* This may include flushing pending log events over network connections.
371+
* <p>
372+
* This call is synchronous and will block until shut down is complete. This may include flushing pending log
373+
* events over network connections.
374+
* </p>
372375
*
373376
* @param context the LoggerContext.
374377
* @since 2.6
@@ -461,7 +464,7 @@ public static Logger getFormatterLogger(final Class<?> clazz) {
461464
* Short-hand for {@code getLogger(value, StringFormatterMessageFactory.INSTANCE)}
462465
* </p>
463466
*
464-
* @param value The value's whose class name should be used as the Logger name.
467+
* @param value The value whose class name should be used as the Logger name.
465468
* @return The Logger, created with a {@link StringFormatterMessageFactory}
466469
* @throws UnsupportedOperationException if {@code value} is {@code null} and the calling class cannot be
467470
* determined.

‎log4j-api/src/main/java/org/apache/logging/log4j/Logger.java

+14-52
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,6 @@ public interface Logger {
200200
* @param paramSuppliers An array of functions, which when called, produce the desired log message parameters.
201201
* @since 2.4
202202
*/
203-
@SuppressWarnings("deprecation")
204203
void debug(Marker marker, String message, Supplier<?>... paramSuppliers);
205204

206205
/**
@@ -222,7 +221,6 @@ public interface Logger {
222221
* message factory.
223222
* @since 2.4
224223
*/
225-
@SuppressWarnings("deprecation")
226224
void debug(Marker marker, Supplier<?> messageSupplier);
227225

228226
/**
@@ -235,7 +233,6 @@ public interface Logger {
235233
* @param throwable A Throwable or null.
236234
* @since 2.4
237235
*/
238-
@SuppressWarnings("deprecation")
239236
void debug(Marker marker, Supplier<?> messageSupplier, Throwable throwable);
240237

241238
/**
@@ -329,7 +326,6 @@ public interface Logger {
329326
* @param paramSuppliers An array of functions, which when called, produce the desired log message parameters.
330327
* @since 2.4
331328
*/
332-
@SuppressWarnings("deprecation")
333329
void debug(String message, Supplier<?>... paramSuppliers);
334330

335331
/**
@@ -348,7 +344,6 @@ public interface Logger {
348344
* message factory.
349345
* @since 2.4
350346
*/
351-
@SuppressWarnings("deprecation")
352347
void debug(Supplier<?> messageSupplier);
353348

354349
/**
@@ -360,7 +355,6 @@ public interface Logger {
360355
* @param throwable the {@code Throwable} to log, including its stack trace.
361356
* @since 2.4
362357
*/
363-
@SuppressWarnings("deprecation")
364358
void debug(Supplier<?> messageSupplier, Throwable throwable);
365359

366360
/**
@@ -811,7 +805,6 @@ void debug(
811805
* @param paramSuppliers An array of functions, which when called, produce the desired log message parameters.
812806
* @since 2.4
813807
*/
814-
@SuppressWarnings("deprecation")
815808
void error(Marker marker, String message, Supplier<?>... paramSuppliers);
816809

817810
/**
@@ -833,7 +826,6 @@ void debug(
833826
* message factory.
834827
* @since 2.4
835828
*/
836-
@SuppressWarnings("deprecation")
837829
void error(Marker marker, Supplier<?> messageSupplier);
838830

839831
/**
@@ -846,7 +838,6 @@ void debug(
846838
* @param throwable A Throwable or null.
847839
* @since 2.4
848840
*/
849-
@SuppressWarnings("deprecation")
850841
void error(Marker marker, Supplier<?> messageSupplier, Throwable throwable);
851842

852843
/**
@@ -940,7 +931,6 @@ void debug(
940931
* @param paramSuppliers An array of functions, which when called, produce the desired log message parameters.
941932
* @since 2.4
942933
*/
943-
@SuppressWarnings("deprecation")
944934
void error(String message, Supplier<?>... paramSuppliers);
945935

946936
/**
@@ -959,7 +949,6 @@ void debug(
959949
* message factory.
960950
* @since 2.4
961951
*/
962-
@SuppressWarnings("deprecation")
963952
void error(Supplier<?> messageSupplier);
964953

965954
/**
@@ -971,7 +960,6 @@ void debug(
971960
* @param throwable the {@code Throwable} to log, including its stack trace.
972961
* @since 2.4
973962
*/
974-
@SuppressWarnings("deprecation")
975963
void error(Supplier<?> messageSupplier, Throwable throwable);
976964

977965
/**
@@ -1414,7 +1402,6 @@ void error(
14141402
* @param paramSuppliers An array of functions, which when called, produce the desired log message parameters.
14151403
* @since 2.4
14161404
*/
1417-
@SuppressWarnings("deprecation")
14181405
void fatal(Marker marker, String message, Supplier<?>... paramSuppliers);
14191406

14201407
/**
@@ -1436,7 +1423,6 @@ void error(
14361423
* message factory.
14371424
* @since 2.4
14381425
*/
1439-
@SuppressWarnings("deprecation")
14401426
void fatal(Marker marker, Supplier<?> messageSupplier);
14411427

14421428
/**
@@ -1449,7 +1435,6 @@ void error(
14491435
* @param throwable A Throwable or null.
14501436
* @since 2.4
14511437
*/
1452-
@SuppressWarnings("deprecation")
14531438
void fatal(Marker marker, Supplier<?> messageSupplier, Throwable throwable);
14541439

14551440
/**
@@ -1543,7 +1528,6 @@ void error(
15431528
* @param paramSuppliers An array of functions, which when called, produce the desired log message parameters.
15441529
* @since 2.4
15451530
*/
1546-
@SuppressWarnings("deprecation")
15471531
void fatal(String message, Supplier<?>... paramSuppliers);
15481532

15491533
/**
@@ -1562,7 +1546,6 @@ void error(
15621546
* message factory.
15631547
* @since 2.4
15641548
*/
1565-
@SuppressWarnings("deprecation")
15661549
void fatal(Supplier<?> messageSupplier);
15671550

15681551
/**
@@ -1574,7 +1557,6 @@ void error(
15741557
* @param throwable the {@code Throwable} to log, including its stack trace.
15751558
* @since 2.4
15761559
*/
1577-
@SuppressWarnings("deprecation")
15781560
void fatal(Supplier<?> messageSupplier, Throwable throwable);
15791561

15801562
/**
@@ -1901,12 +1883,13 @@ void fatal(
19011883

19021884
/**
19031885
* Gets the message factory used to convert message Objects and Strings/CharSequences into actual log Messages.
1904-
*
1905-
* Since version 2.6, Log4j internally uses message factories that implement the {@link MessageFactory2} interface.
1906-
* From version 2.6.2, the return type of this method was changed from {@link MessageFactory} to
1907-
* {@code <MF extends MessageFactory> MF}. The returned factory will always implement {@link MessageFactory2},
1908-
* but the return type of this method could not be changed to {@link MessageFactory2} without breaking binary
1909-
* compatibility.
1886+
* <p>
1887+
* Since version 2.6, Log4j internally uses message factories that implement the {@link MessageFactory2}
1888+
* interface. From version 2.6.2, the return type of this method was changed from {@link MessageFactory} to
1889+
* {@code <MF extends MessageFactory> MF}. The returned factory will always implement {@link MessageFactory2},
1890+
* but the return type of this method could not be changed to {@link MessageFactory2} without breaking binary
1891+
* compatibility.
1892+
* </p>
19101893
*
19111894
* @return the message factory, as an instance of {@link MessageFactory2}
19121895
*/
@@ -2030,7 +2013,6 @@ void fatal(
20302013
* @param paramSuppliers An array of functions, which when called, produce the desired log message parameters.
20312014
* @since 2.4
20322015
*/
2033-
@SuppressWarnings("deprecation")
20342016
void info(Marker marker, String message, Supplier<?>... paramSuppliers);
20352017

20362018
/**
@@ -2052,7 +2034,6 @@ void fatal(
20522034
* message factory.
20532035
* @since 2.4
20542036
*/
2055-
@SuppressWarnings("deprecation")
20562037
void info(Marker marker, Supplier<?> messageSupplier);
20572038

20582039
/**
@@ -2065,7 +2046,6 @@ void fatal(
20652046
* @param throwable A Throwable or null.
20662047
* @since 2.4
20672048
*/
2068-
@SuppressWarnings("deprecation")
20692049
void info(Marker marker, Supplier<?> messageSupplier, Throwable throwable);
20702050

20712051
/**
@@ -2159,7 +2139,6 @@ void fatal(
21592139
* @param paramSuppliers An array of functions, which when called, produce the desired log message parameters.
21602140
* @since 2.4
21612141
*/
2162-
@SuppressWarnings("deprecation")
21632142
void info(String message, Supplier<?>... paramSuppliers);
21642143

21652144
/**
@@ -2178,7 +2157,6 @@ void fatal(
21782157
* message factory.
21792158
* @since 2.4
21802159
*/
2181-
@SuppressWarnings("deprecation")
21822160
void info(Supplier<?> messageSupplier);
21832161

21842162
/**
@@ -2190,7 +2168,6 @@ void fatal(
21902168
* @param throwable the {@code Throwable} to log, including its stack trace.
21912169
* @since 2.4
21922170
*/
2193-
@SuppressWarnings("deprecation")
21942171
void info(Supplier<?> messageSupplier, Throwable throwable);
21952172

21962173
/**
@@ -2737,7 +2714,6 @@ void info(
27372714
* @param paramSuppliers An array of functions, which when called, produce the desired log message parameters.
27382715
* @since 2.4
27392716
*/
2740-
@SuppressWarnings("deprecation")
27412717
void log(Level level, Marker marker, String message, Supplier<?>... paramSuppliers);
27422718

27432719
/**
@@ -2760,7 +2736,6 @@ void info(
27602736
* message factory.
27612737
* @since 2.4
27622738
*/
2763-
@SuppressWarnings("deprecation")
27642739
void log(Level level, Marker marker, Supplier<?> messageSupplier);
27652740

27662741
/**
@@ -2774,7 +2749,6 @@ void info(
27742749
* @param throwable A Throwable or null.
27752750
* @since 2.4
27762751
*/
2777-
@SuppressWarnings("deprecation")
27782752
void log(Level level, Marker marker, Supplier<?> messageSupplier, Throwable throwable);
27792753

27802754
/**
@@ -2878,7 +2852,6 @@ void info(
28782852
* @param paramSuppliers An array of functions, which when called, produce the desired log message parameters.
28792853
* @since 2.4
28802854
*/
2881-
@SuppressWarnings("deprecation")
28822855
void log(Level level, String message, Supplier<?>... paramSuppliers);
28832856

28842857
/**
@@ -2899,7 +2872,6 @@ void info(
28992872
* message factory.
29002873
* @since 2.4
29012874
*/
2902-
@SuppressWarnings("deprecation")
29032875
void log(Level level, Supplier<?> messageSupplier);
29042876

29052877
/**
@@ -2912,7 +2884,6 @@ void info(
29122884
* @param throwable the {@code Throwable} to log, including its stack log.
29132885
* @since 2.4
29142886
*/
2915-
@SuppressWarnings("deprecation")
29162887
void log(Level level, Supplier<?> messageSupplier, Throwable throwable);
29172888

29182889
/**
@@ -3435,7 +3406,6 @@ void log(
34353406
* @param paramSuppliers An array of functions, which when called, produce the desired log message parameters.
34363407
* @since 2.4
34373408
*/
3438-
@SuppressWarnings("deprecation")
34393409
void trace(Marker marker, String message, Supplier<?>... paramSuppliers);
34403410

34413411
/**
@@ -3458,7 +3428,6 @@ void log(
34583428
* message factory.
34593429
* @since 2.4
34603430
*/
3461-
@SuppressWarnings("deprecation")
34623431
void trace(Marker marker, Supplier<?> messageSupplier);
34633432

34643433
/**
@@ -3471,7 +3440,6 @@ void log(
34713440
* @param throwable A Throwable or null.
34723441
* @since 2.4
34733442
*/
3474-
@SuppressWarnings("deprecation")
34753443
void trace(Marker marker, Supplier<?> messageSupplier, Throwable throwable);
34763444

34773445
/**
@@ -3567,7 +3535,6 @@ void log(
35673535
* @param paramSuppliers An array of functions, which when called, produce the desired log message parameters.
35683536
* @since 2.4
35693537
*/
3570-
@SuppressWarnings("deprecation")
35713538
void trace(String message, Supplier<?>... paramSuppliers);
35723539

35733540
/**
@@ -3587,7 +3554,6 @@ void log(
35873554
* message factory.
35883555
* @since 2.4
35893556
*/
3590-
@SuppressWarnings("deprecation")
35913557
void trace(Supplier<?> messageSupplier);
35923558

35933559
/**
@@ -3599,7 +3565,6 @@ void log(
35993565
* @param throwable the {@code Throwable} to log, including its stack trace.
36003566
* @since 2.4
36013567
*/
3602-
@SuppressWarnings("deprecation")
36033568
void trace(Supplier<?> messageSupplier, Throwable throwable);
36043569

36053570
/**
@@ -3967,7 +3932,6 @@ void trace(
39673932
*
39683933
* @since 2.6
39693934
*/
3970-
@SuppressWarnings("deprecation")
39713935
EntryMessage traceEntry(Supplier<?>... paramSuppliers);
39723936

39733937
/**
@@ -3986,7 +3950,6 @@ void trace(
39863950
*
39873951
* @since 2.6
39883952
*/
3989-
@SuppressWarnings("deprecation")
39903953
EntryMessage traceEntry(String format, Supplier<?>... paramSuppliers);
39913954

39923955
/**
@@ -4205,7 +4168,6 @@ void trace(
42054168
* @param paramSuppliers An array of functions, which when called, produce the desired log message parameters.
42064169
* @since 2.4
42074170
*/
4208-
@SuppressWarnings("deprecation")
42094171
void warn(Marker marker, String message, Supplier<?>... paramSuppliers);
42104172

42114173
/**
@@ -4227,7 +4189,6 @@ void trace(
42274189
* message factory.
42284190
* @since 2.4
42294191
*/
4230-
@SuppressWarnings("deprecation")
42314192
void warn(Marker marker, Supplier<?> messageSupplier);
42324193

42334194
/**
@@ -4240,7 +4201,6 @@ void trace(
42404201
* @param throwable A Throwable or null.
42414202
* @since 2.4
42424203
*/
4243-
@SuppressWarnings("deprecation")
42444204
void warn(Marker marker, Supplier<?> messageSupplier, Throwable throwable);
42454205

42464206
/**
@@ -4334,7 +4294,6 @@ void trace(
43344294
* @param paramSuppliers An array of functions, which when called, produce the desired log message parameters.
43354295
* @since 2.4
43364296
*/
4337-
@SuppressWarnings("deprecation")
43384297
void warn(String message, Supplier<?>... paramSuppliers);
43394298

43404299
/**
@@ -4353,7 +4312,6 @@ void trace(
43534312
* message factory.
43544313
* @since 2.4
43554314
*/
4356-
@SuppressWarnings("deprecation")
43574315
void warn(Supplier<?> messageSupplier);
43584316

43594317
/**
@@ -4365,7 +4323,6 @@ void trace(
43654323
* @param throwable the {@code Throwable} to log, including its stack warn.
43664324
* @since 2.4
43674325
*/
4368-
@SuppressWarnings("deprecation")
43694326
void warn(Supplier<?> messageSupplier, Throwable throwable);
43704327

43714328
/**
@@ -4695,7 +4652,12 @@ void warn(
46954652
* @since 2.13.0
46964653
*/
46974654
default void logMessage(
4698-
Level level, Marker marker, String fqcn, StackTraceElement location, Message message, Throwable throwable) {
4655+
final Level level,
4656+
final Marker marker,
4657+
final String fqcn,
4658+
final StackTraceElement location,
4659+
final Message message,
4660+
final Throwable throwable) {
46994661
// noop
47004662
}
47014663

@@ -4768,7 +4730,7 @@ default LogBuilder always() {
47684730
* @return a LogBuilder.
47694731
* @since 2.13.0
47704732
*/
4771-
default LogBuilder atLevel(Level level) {
4733+
default LogBuilder atLevel(final Level level) {
47724734
return LogBuilder.NOOP;
47734735
}
47744736
}

‎log4j-api/src/main/java/org/apache/logging/log4j/util/BiConsumer.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,14 @@
2424
* @see ReadOnlyStringMap
2525
* @since 2.7
2626
*/
27-
public interface BiConsumer<K, V> {
27+
@FunctionalInterface
28+
public interface BiConsumer<K, V> extends java.util.function.BiConsumer<K, V> {
2829

2930
/**
3031
* Performs the operation given the specified arguments.
3132
* @param k the first input argument
3233
* @param v the second input argument
3334
*/
35+
@Override
3436
void accept(K k, V v);
3537
}

‎log4j-api/src/main/java/org/apache/logging/log4j/util/LambdaUtil.java

-3
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ private LambdaUtil() {}
3535
* @return an array containing the results of evaluating the lambda expressions (or {@code null} if the suppliers
3636
* array was {@code null}
3737
*/
38-
@SuppressWarnings("deprecation")
3938
public static Object[] getAll(final Supplier<?>... suppliers) {
4039
if (suppliers == null) {
4140
return null;
@@ -54,7 +53,6 @@ public static Object[] getAll(final Supplier<?>... suppliers) {
5453
* @return the results of evaluating the lambda expression (or {@code null} if the supplier
5554
* was {@code null}
5655
*/
57-
@SuppressWarnings("deprecation")
5856
public static Object get(final Supplier<?> supplier) {
5957
if (supplier == null) {
6058
return null;
@@ -83,7 +81,6 @@ public static Message get(final MessageSupplier supplier) {
8381
* @return the Message resulting from evaluating the lambda expression or the Message created by the factory for
8482
* supplied values that are not of type Message
8583
*/
86-
@SuppressWarnings("deprecation")
8784
public static Message getMessage(final Supplier<?> supplier, final MessageFactory messageFactory) {
8885
if (supplier == null) {
8986
return null;

‎log4j-api/src/main/java/org/apache/logging/log4j/util/MessageSupplier.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,14 @@
3333
*
3434
* @since 2.4
3535
*/
36-
public interface MessageSupplier {
36+
@FunctionalInterface
37+
public interface MessageSupplier extends Supplier<Message> {
3738

3839
/**
3940
* Gets a Message.
4041
*
4142
* @return a Message
4243
*/
44+
@Override
4345
Message get();
4446
}

‎log4j-api/src/main/java/org/apache/logging/log4j/util/Supplier.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,15 @@
3131
*
3232
* @since 2.4
3333
*/
34+
@FunctionalInterface
3435
@InternalApi
35-
@Deprecated
36-
public interface Supplier<T> {
36+
public interface Supplier<T> extends java.util.function.Supplier<T> {
Has conversations. Original line has conversations.
3737

3838
/**
3939
* Gets a value.
4040
*
4141
* @return a value
4242
*/
43+
@Override
4344
T get();
4445
}

0 commit comments

Comments
 (0)
Please sign in to comment.