Skip to content

Commit 0650610

Browse files
committed
Merge pull request #4688 from mnhock/Replace_with_valueOf()
* pr/4688: Prefer valueOf() to create Number values
2 parents dc3ead4 + fcf6e5d commit 0650610

File tree

6 files changed

+14
-14
lines changed

6 files changed

+14
-14
lines changed

spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/Metric.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public String toString() {
9292
*/
9393
public Metric<Long> increment(int amount) {
9494
return new Metric<Long>(this.getName(),
95-
new Long(this.getValue().longValue() + amount));
95+
Long.valueOf(this.getValue().longValue() + amount));
9696
}
9797

9898
/**

spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/repository/InMemoryMetricRepository.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public Metric<?> modify(Metric<?> current) {
5757
metric.increment(amount).getValue(), timestamp);
5858
}
5959
else {
60-
return new Metric<Long>(metricName, new Long(amount), timestamp);
60+
return new Metric<Long>(metricName, Long.valueOf(amount), timestamp);
6161
}
6262
}
6363
});

spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/reader/MetricRegistryMetricReaderTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,12 @@ public void numberGauge() {
6464

6565
@Override
6666
public Number getValue() {
67-
return new Integer(5);
67+
return Integer.valueOf(5);
6868
}
6969

7070
});
7171
Metric<Integer> metric = (Metric<Integer>) this.metricReader.findOne("test");
72-
assertThat(metric.getValue(), equalTo(new Integer(5)));
72+
assertThat(metric.getValue(), equalTo(Integer.valueOf(5)));
7373
this.metricRegistry.remove("test");
7474
assertThat(this.metricReader.findOne("test"), is(nullValue()));
7575
}

spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/util/InMemoryRepositoryTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2013 the original author or authors.
2+
* Copyright 2012-2015 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -127,7 +127,7 @@ public Integer modify(Integer current) {
127127
for (Future<Boolean> future : all) {
128128
assertTrue(future.get(1, TimeUnit.SECONDS));
129129
}
130-
assertEquals(new Integer(0), repository.findOne("foo"));
130+
assertEquals(Integer.valueOf(0), repository.findOne("foo"));
131131
}
132132

133133
}

spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/DataSourceInitializerTests.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2013-2014 the original author or authors.
2+
* Copyright 2013-2015 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -100,7 +100,7 @@ public void testDataSourceInitialized() throws Exception {
100100
assertTrue(dataSource instanceof org.apache.tomcat.jdbc.pool.DataSource);
101101
assertNotNull(dataSource);
102102
JdbcOperations template = new JdbcTemplate(dataSource);
103-
assertEquals(new Integer(1),
103+
assertEquals(Integer.valueOf(1),
104104
template.queryForObject("SELECT COUNT(*) from BAR", Integer.class));
105105
}
106106

@@ -119,7 +119,7 @@ public void testDataSourceInitializedWithExplicitScript() throws Exception {
119119
assertTrue(dataSource instanceof org.apache.tomcat.jdbc.pool.DataSource);
120120
assertNotNull(dataSource);
121121
JdbcOperations template = new JdbcTemplate(dataSource);
122-
assertEquals(new Integer(1),
122+
assertEquals(Integer.valueOf(1),
123123
template.queryForObject("SELECT COUNT(*) from FOO", Integer.class));
124124
}
125125

@@ -142,9 +142,9 @@ public void testDataSourceInitializedWithMultipleScripts() throws Exception {
142142
assertTrue(dataSource instanceof org.apache.tomcat.jdbc.pool.DataSource);
143143
assertNotNull(dataSource);
144144
JdbcOperations template = new JdbcTemplate(dataSource);
145-
assertEquals(new Integer(1),
145+
assertEquals(Integer.valueOf(1),
146146
template.queryForObject("SELECT COUNT(*) from FOO", Integer.class));
147-
assertEquals(new Integer(0),
147+
assertEquals(Integer.valueOf(0),
148148
template.queryForObject("SELECT COUNT(*) from SPAM", Integer.class));
149149
}
150150

@@ -165,7 +165,7 @@ public void testDataSourceInitializedWithExplicitSqlScriptEncoding()
165165
assertTrue(dataSource instanceof org.apache.tomcat.jdbc.pool.DataSource);
166166
assertNotNull(dataSource);
167167
JdbcOperations template = new JdbcTemplate(dataSource);
168-
assertEquals(new Integer(2),
168+
assertEquals(Integer.valueOf(2),
169169
template.queryForObject("SELECT COUNT(*) from BAR", Integer.class));
170170
assertEquals("bar",
171171
template.queryForObject("SELECT name from BAR WHERE id=1", String.class));

spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfigurationTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public void testDataScriptWithMissingDdl() throws Exception {
6767
"spring.datasource.schema:classpath:/ddl.sql");
6868
setupTestConfiguration();
6969
this.context.refresh();
70-
assertEquals(new Integer(1),
70+
assertEquals(Integer.valueOf(1),
7171
new JdbcTemplate(this.context.getBean(DataSource.class))
7272
.queryForObject("SELECT COUNT(*) from CITY", Integer.class));
7373
}
@@ -80,7 +80,7 @@ public void testDataScript() throws Exception {
8080
"spring.datasource.data:classpath:/city.sql");
8181
setupTestConfiguration();
8282
this.context.refresh();
83-
assertEquals(new Integer(1),
83+
assertEquals(Integer.valueOf(1),
8484
new JdbcTemplate(this.context.getBean(DataSource.class))
8585
.queryForObject("SELECT COUNT(*) from CITY", Integer.class));
8686
}

0 commit comments

Comments
 (0)