Skip to content

Two public static final constants in Constants.java are backed by a plain ArrayList, making them silently mutable. #470

@rrobetti

Description

@rrobetti

Affected file
ojp-jdbc-driver/src/main/java/org/openjproxy/jdbc/Constants.java

Java
public static final List EMPTY_PARAMETERS_LIST = new ArrayList<>();
public static final List EMPTY_OBJECT_LIST = new ArrayList<>();
Problem
Any caller can call .add() or .clear() on these lists and corrupt the shared state for all other callers. The intent is clearly to provide an immutable empty list.

Expected fix
Replace both with immutable equivalents:

Java
public static final List EMPTY_PARAMETERS_LIST = Collections.emptyList();
public static final List EMPTY_OBJECT_LIST = Collections.emptyList();
Or, since the project compiles to Java 11+:

Java
public static final List EMPTY_PARAMETERS_LIST = List.of();
public static final List EMPTY_OBJECT_LIST = List.of();

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions