Skip to content

Replace collect(toUnmodifiableList()) with toList() #17303

@AmitKumarDeoghoria

Description

@AmitKumarDeoghoria

From comment : #17259 (comment).
During the JDK 17 upgrade(#17168), IntelliJ has identified 70 instances where collect(Collectors.toUnmodifiableList()) can be simplified to toList() using Java 16+ syntax. This is a JDK 16+ language feature (JEP 269) and should be addressed after the JDK 17 migration.

Before:
List<String> result = stream.collect(Collectors.toUnmodifiableList());

After:

List<String> result = stream.toList();

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions