Skip to content

Commit c4c941e

Browse files
committed
Document unmodifiable collection usage
1 parent f1e3e2f commit c4c941e

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

log4j-api/src/main/java/org/apache/logging/log4j/status/StatusLogger.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,9 @@ private static void closeListenerSafely(final StatusListener listener) {
506506
* @return a thread-safe read-only collection of buffered events
507507
*/
508508
public List<StatusData> getStatusData() {
509+
// Wrapping the buffer clone with an unmodifiable list.
510+
// By disallowing modifications, we make it clear to the user that mutations will not get propagated.
511+
// `Collections.unmodifiableList(new ArrayList<>(...))` should be replaced with `List.of()` in Java 9+.
509512
return Collections.unmodifiableList(new ArrayList<>(buffer));
510513
}
511514

0 commit comments

Comments
 (0)