Skip to content

[Bug] Replace Long.valueOf() with Long.parseLong() to avoid unnecessary boxing #14471

@cxhello

Description

@cxhello

Background

Follow-up to #14469 (SpotBugs check enforcement). This addresses the DM_BOXED_PRIMITIVE_FOR_PARSING pattern — using Long.valueOf(s) where Long.parseLong(s) should be used, causing unnecessary boxing/unboxing.

Affected locations (4 occurrences)

File Line Current code
client/.../CacheData.java L70 Long.valueOf(notifyTimeouts)
plugin/control/.../RateCounter.java L87 Long.valueOf(Long.valueOf(substring) / 60 * 60 + "000")
plugin/control/.../RateCounter.java L99 Long.valueOf(substring + "000")
plugin/control/.../RateCounter.java L111 Long.valueOf(Long.valueOf(substring) / (60 * 60) * (60 * 60) + "000")

Fix

Replace all Long.valueOf() with Long.parseLong(). Pure API substitution, semantically equivalent.

After fixing, the DM_BOXED_PRIMITIVE_FOR_PARSING exclusion in style/spotbugs-exclude.xml should be removed so that future occurrences are caught by CI.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions