Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
0650610f
Commit
0650610f
authored
Dec 11, 2015
by
Phillip Webb
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4688 from mnhock/Replace_with_valueOf()
* pr/4688: Prefer valueOf() to create Number values
parents
dc3ead4c
fcf6e5d6
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
14 additions
and
14 deletions
+14
-14
Metric.java
...java/org/springframework/boot/actuate/metrics/Metric.java
+1
-1
InMemoryMetricRepository.java
.../actuate/metrics/repository/InMemoryMetricRepository.java
+1
-1
MetricRegistryMetricReaderTests.java
...tuate/metrics/reader/MetricRegistryMetricReaderTests.java
+2
-2
InMemoryRepositoryTests.java
...rk/boot/actuate/metrics/util/InMemoryRepositoryTests.java
+2
-2
DataSourceInitializerTests.java
...k/boot/autoconfigure/jdbc/DataSourceInitializerTests.java
+6
-6
HibernateJpaAutoConfigurationTests.java
...configure/orm/jpa/HibernateJpaAutoConfigurationTests.java
+2
-2
No files found.
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/Metric.java
View file @
0650610f
...
...
@@ -92,7 +92,7 @@ public class Metric<T extends Number> {
*/
public
Metric
<
Long
>
increment
(
int
amount
)
{
return
new
Metric
<
Long
>(
this
.
getName
(),
new
Long
(
this
.
getValue
().
longValue
()
+
amount
));
Long
.
valueOf
(
this
.
getValue
().
longValue
()
+
amount
));
}
/**
...
...
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/repository/InMemoryMetricRepository.java
View file @
0650610f
...
...
@@ -57,7 +57,7 @@ public class InMemoryMetricRepository implements MetricRepository, MultiMetricRe
metric
.
increment
(
amount
).
getValue
(),
timestamp
);
}
else
{
return
new
Metric
<
Long
>(
metricName
,
new
Long
(
amount
),
timestamp
);
return
new
Metric
<
Long
>(
metricName
,
Long
.
valueOf
(
amount
),
timestamp
);
}
}
});
...
...
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/reader/MetricRegistryMetricReaderTests.java
View file @
0650610f
...
...
@@ -64,12 +64,12 @@ public class MetricRegistryMetricReaderTests {
@Override
public
Number
getValue
()
{
return
new
Integer
(
5
);
return
Integer
.
valueOf
(
5
);
}
});
Metric
<
Integer
>
metric
=
(
Metric
<
Integer
>)
this
.
metricReader
.
findOne
(
"test"
);
assertThat
(
metric
.
getValue
(),
equalTo
(
new
Integer
(
5
)));
assertThat
(
metric
.
getValue
(),
equalTo
(
Integer
.
valueOf
(
5
)));
this
.
metricRegistry
.
remove
(
"test"
);
assertThat
(
this
.
metricReader
.
findOne
(
"test"
),
is
(
nullValue
()));
}
...
...
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/util/InMemoryRepositoryTests.java
View file @
0650610f
/*
* Copyright 2012-201
3
the original author or authors.
* Copyright 2012-201
5
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -127,7 +127,7 @@ public class InMemoryRepositoryTests {
for
(
Future
<
Boolean
>
future
:
all
)
{
assertTrue
(
future
.
get
(
1
,
TimeUnit
.
SECONDS
));
}
assertEquals
(
new
Integer
(
0
),
repository
.
findOne
(
"foo"
));
assertEquals
(
Integer
.
valueOf
(
0
),
repository
.
findOne
(
"foo"
));
}
}
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/DataSourceInitializerTests.java
View file @
0650610f
/*
* Copyright 2013-201
4
the original author or authors.
* Copyright 2013-201
5
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -100,7 +100,7 @@ public class DataSourceInitializerTests {
assertTrue
(
dataSource
instanceof
org
.
apache
.
tomcat
.
jdbc
.
pool
.
DataSource
);
assertNotNull
(
dataSource
);
JdbcOperations
template
=
new
JdbcTemplate
(
dataSource
);
assertEquals
(
new
Integer
(
1
),
assertEquals
(
Integer
.
valueOf
(
1
),
template
.
queryForObject
(
"SELECT COUNT(*) from BAR"
,
Integer
.
class
));
}
...
...
@@ -119,7 +119,7 @@ public class DataSourceInitializerTests {
assertTrue
(
dataSource
instanceof
org
.
apache
.
tomcat
.
jdbc
.
pool
.
DataSource
);
assertNotNull
(
dataSource
);
JdbcOperations
template
=
new
JdbcTemplate
(
dataSource
);
assertEquals
(
new
Integer
(
1
),
assertEquals
(
Integer
.
valueOf
(
1
),
template
.
queryForObject
(
"SELECT COUNT(*) from FOO"
,
Integer
.
class
));
}
...
...
@@ -142,9 +142,9 @@ public class DataSourceInitializerTests {
assertTrue
(
dataSource
instanceof
org
.
apache
.
tomcat
.
jdbc
.
pool
.
DataSource
);
assertNotNull
(
dataSource
);
JdbcOperations
template
=
new
JdbcTemplate
(
dataSource
);
assertEquals
(
new
Integer
(
1
),
assertEquals
(
Integer
.
valueOf
(
1
),
template
.
queryForObject
(
"SELECT COUNT(*) from FOO"
,
Integer
.
class
));
assertEquals
(
new
Integer
(
0
),
assertEquals
(
Integer
.
valueOf
(
0
),
template
.
queryForObject
(
"SELECT COUNT(*) from SPAM"
,
Integer
.
class
));
}
...
...
@@ -165,7 +165,7 @@ public class DataSourceInitializerTests {
assertTrue
(
dataSource
instanceof
org
.
apache
.
tomcat
.
jdbc
.
pool
.
DataSource
);
assertNotNull
(
dataSource
);
JdbcOperations
template
=
new
JdbcTemplate
(
dataSource
);
assertEquals
(
new
Integer
(
2
),
assertEquals
(
Integer
.
valueOf
(
2
),
template
.
queryForObject
(
"SELECT COUNT(*) from BAR"
,
Integer
.
class
));
assertEquals
(
"bar"
,
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
View file @
0650610f
...
...
@@ -67,7 +67,7 @@ public class HibernateJpaAutoConfigurationTests
"spring.datasource.schema:classpath:/ddl.sql"
);
setupTestConfiguration
();
this
.
context
.
refresh
();
assertEquals
(
new
Integer
(
1
),
assertEquals
(
Integer
.
valueOf
(
1
),
new
JdbcTemplate
(
this
.
context
.
getBean
(
DataSource
.
class
))
.
queryForObject
(
"SELECT COUNT(*) from CITY"
,
Integer
.
class
));
}
...
...
@@ -80,7 +80,7 @@ public class HibernateJpaAutoConfigurationTests
"spring.datasource.data:classpath:/city.sql"
);
setupTestConfiguration
();
this
.
context
.
refresh
();
assertEquals
(
new
Integer
(
1
),
assertEquals
(
Integer
.
valueOf
(
1
),
new
JdbcTemplate
(
this
.
context
.
getBean
(
DataSource
.
class
))
.
queryForObject
(
"SELECT COUNT(*) from CITY"
,
Integer
.
class
));
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment