wu-sheng commented on a change in pull request #4247: fix thread unsafe problem 
in server-alarm-plugin (#4230)
URL: https://github.com/apache/skywalking/pull/4247#discussion_r368284230
 
 

 ##########
 File path: 
oap-server/server-alarm-plugin/src/main/java/org/apache/skywalking/oap/server/core/alarm/provider/RunningRule.java
 ##########
 @@ -227,18 +221,17 @@ public void moveTo(LocalDateTime current) {
         public void add(Metrics metrics) {
             long bucket = metrics.getTimeBucket();
 
-            LocalDateTime timebucket = 
TIME_BUCKET_FORMATTER.parseLocalDateTime(bucket + "");
-
-            int minutes = Minutes.minutesBetween(timebucket, 
endTime).getMinutes();
-            if (minutes == -1) {
-                this.moveTo(timebucket);
-
-            }
+            LocalDateTime timeBucket = 
TIME_BUCKET_FORMATTER.parseLocalDateTime(bucket + "");
 
-            lock.lock();
+            this.lock.lock();
             try {
+                if (this.endTime == null) {
+                    init();
+                    this.endTime = timeBucket;
 
 Review comment:
   Why add this? End time has been initialized in the constructor. End time 
should never be null. Right?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to