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
c29d2b1b
Commit
c29d2b1b
authored
Nov 04, 2013
by
Dave Syer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove a small race condition
parent
894940d7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
10 deletions
+11
-10
InMemoryMetricRepository.java
...mework/boot/actuate/metrics/InMemoryMetricRepository.java
+11
-10
No files found.
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/InMemoryMetricRepository.java
View file @
c29d2b1b
...
@@ -35,22 +35,23 @@ public class InMemoryMetricRepository implements MetricRepository {
...
@@ -35,22 +35,23 @@ public class InMemoryMetricRepository implements MetricRepository {
@Override
@Override
public
void
increment
(
String
metricName
,
int
amount
,
Date
timestamp
)
{
public
void
increment
(
String
metricName
,
int
amount
,
Date
timestamp
)
{
Measurement
current
=
this
.
metrics
.
get
(
metricName
);
Object
lock
=
this
.
locks
.
putIfAbsent
(
metricName
,
new
Object
());
if
(
current
!=
null
)
{
if
(
lock
==
null
)
{
Object
lock
=
this
.
locks
.
putIfAbsent
(
metricName
,
new
Object
());
lock
=
this
.
locks
.
get
(
metricName
);
if
(
lock
==
null
)
{
}
lock
=
this
.
locks
.
get
(
metricName
);
synchronized
(
lock
)
{
}
Measurement
current
=
this
.
metrics
.
get
(
metricName
);
synchronized
(
lock
)
{
if
(
current
!=
null
)
{
current
=
this
.
metrics
.
get
(
metricName
);
Metric
metric
=
current
.
getMetric
();
Metric
metric
=
current
.
getMetric
();
this
.
metrics
.
replace
(
metricName
,
current
,
new
Measurement
(
timestamp
,
this
.
metrics
.
replace
(
metricName
,
current
,
new
Measurement
(
timestamp
,
metric
.
increment
(
amount
)));
metric
.
increment
(
amount
)));
return
;
return
;
}
}
else
{
this
.
metrics
.
putIfAbsent
(
metricName
,
new
Measurement
(
timestamp
,
new
Metric
(
metricName
,
amount
)));
}
}
}
this
.
metrics
.
putIfAbsent
(
metricName
,
new
Measurement
(
timestamp
,
new
Metric
(
metricName
,
amount
)));
}
}
@Override
@Override
...
...
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