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.
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.
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
getandremovevalues fromlocalBucket2RegionMap. If the value was of typeintthe effective result would potentially be multiple invocations toInteger.valueOf(int). In the case wherebucketIdis greater than the maxIntegerbox cache this would result in transient duplicate allocations of the boxedIntegertype.