Visitar URL original
java/non-null-boxed-variable - false positive · Issue #7539 · github/codeql · GitHub
The Wayback Machine - https://web.archive.org/web/20260602021956/https://github.com/github/codeql/issues/7539
Skip to content

java/non-null-boxed-variable - false positive #7539

@jake-at-work

Description

@jake-at-work

While java/non-null-boxed-variable correctly indicates that a non-null is boxed it should ignore this case where the boxed version is used in more than one method call that requires a boxed type to avoid repeatedly auto-boxing the value.

The variable 'bucketId' is only assigned values of primitive type and is never 'null', but it is declared with the boxed type 'Integer'.

https://lgtm.com/projects/g/apache/geode/snapshot/984d32fd85b8d794a18b7c52e528efe2c70c83a5/files/geode-core/src/main/java/org/apache/geode/internal/cache/PartitionedRegionDataStore.java?sort=name&dir=ASC&mode=heatmap#L1387

Notice that the value is used as a key to both get and remove values from localBucket2RegionMap. If the value was of type int the effective result would potentially be multiple invocations to Integer.valueOf(int). In the case where bucketId is greater than the max Integer box cache this would result in transient duplicate allocations of the boxed Integer type.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions