Skip to content

Avoid unnecessary char[] allocation in NamedParameterUtils [SPR-11042] #15670

@spring-projects-issues

Description

@spring-projects-issues

Philippe Marschall opened SPR-11042 and commented

Overview

NamedParameterUtils.substituteNamedParameters() uses the following pattern:

stringBuilder.append(str.substring(start, end));

This wasn’t such an issue in HotSpot up to Java 7 Update 6, because even though it would allocate an unnecessary String, it would not allocate a new char[]. This all changed with 7u6 when String#substring started allocating a new char[] (it always did on J9).

Proposed Solution

Luckily this can easily be solved with the following pattern:

stringBuilder.append(str, start, end);

Affects: 3.2.4

Metadata

Metadata

Assignees

Labels

in: dataIssues in data modules (jdbc, orm, oxm, tx)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions