Skip to content

Use Integer.parseInt instead of Integer.valueOf for primitive int #25456

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -416,11 +416,11 @@ protected void testConditionalCacheUpdate(CacheableService<?> service) {
Integer three = 3;

Cache cache = this.cm.getCache("testCache");
assertThat((int) Integer.valueOf(service.conditionalUpdate(one).toString())).isEqualTo((int) one);
assertThat(Integer.parseInt(service.conditionalUpdate(one).toString())).isEqualTo((int) one);
assertThat(cache.get(one)).isNull();

assertThat((int) Integer.valueOf(service.conditionalUpdate(three).toString())).isEqualTo((int) three);
assertThat((int) Integer.valueOf(cache.get(three).get().toString())).isEqualTo((int) three);
assertThat(Integer.parseInt(service.conditionalUpdate(three).toString())).isEqualTo((int) three);
assertThat(Integer.parseInt(cache.get(three).get().toString())).isEqualTo((int) three);
}

protected void testMultiCache(CacheableService<?> service) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ static class BeanConditionConfig {

@Bean
public Bar bar() {
return new Bar(Boolean.valueOf(env.getProperty("bar.enabled")));
return new Bar(Boolean.parseBoolean(env.getProperty("bar.enabled")));
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -411,11 +411,11 @@ protected void testConditionalCacheUpdate(CacheableService<?> service) {
Integer three = 3;

Cache cache = this.cm.getCache("testCache");
assertThat((int) Integer.valueOf(service.conditionalUpdate(one).toString())).isEqualTo((int) one);
assertThat(Integer.parseInt(service.conditionalUpdate(one).toString())).isEqualTo((int) one);
assertThat(cache.get(one)).isNull();

assertThat((int) Integer.valueOf(service.conditionalUpdate(three).toString())).isEqualTo((int) three);
assertThat((int) Integer.valueOf(cache.get(three).get().toString())).isEqualTo((int) three);
assertThat(Integer.parseInt(service.conditionalUpdate(three).toString())).isEqualTo((int) three);
assertThat(Integer.parseInt(cache.get(three).get().toString())).isEqualTo((int) three);
}

protected void testMultiCache(CacheableService<?> service) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void enableIndentingSunnyDay() throws Exception {
void enableIndentingSunnyDayWithCustomKosherIndentAmount() throws Exception {
final String indentAmountProperty = "10";
Transformer transformer = new StubTransformer();
TransformerUtils.enableIndenting(transformer, Integer.valueOf(indentAmountProperty));
TransformerUtils.enableIndenting(transformer, Integer.parseInt(indentAmountProperty));
String indent = transformer.getOutputProperty(OutputKeys.INDENT);
assertThat(indent).isNotNull();
assertThat(indent).isEqualTo("yes");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class SockJsUrlInfoTests {
@Test
public void serverId() throws Exception {
SockJsUrlInfo info = new SockJsUrlInfo(new URI("https://example.com"));
int serverId = Integer.valueOf(info.getServerId());
int serverId = Integer.parseInt(info.getServerId());
assertThat(serverId >= 0 && serverId < 1000).as("Invalid serverId: " + serverId).isTrue();
}

Expand Down