This is an automated email from the ASF dual-hosted git repository.

mgrigorov pushed a commit to branch wicket-9.x
in repository https://gitbox.apache.org/repos/asf/wicket.git


The following commit(s) were added to refs/heads/wicket-9.x by this push:
     new c2574b443c [WICKET-7052] Interrupting a task should not be logged as 
an error (#588)
c2574b443c is described below

commit c2574b443c2185fd520a35532782aaeaba1def23
Author: Richard Eckart de Castilho <[email protected]>
AuthorDate: Thu May 4 20:30:26 2023 +0200

    [WICKET-7052] Interrupting a task should not be logged as an error (#588)
    
    - Do not log an error if a task is interrupted while sleeping
    - Do log a trace message when the task has been stopped
---
 .../src/main/java/org/apache/wicket/util/thread/Task.java     | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/wicket-util/src/main/java/org/apache/wicket/util/thread/Task.java 
b/wicket-util/src/main/java/org/apache/wicket/util/thread/Task.java
index 577ad203dc..194b98eb2a 100755
--- a/wicket-util/src/main/java/org/apache/wicket/util/thread/Task.java
+++ b/wicket-util/src/main/java/org/apache/wicket/util/thread/Task.java
@@ -145,13 +145,18 @@ public final class Task
                                                        Instant nextExecution = 
startOfPeriod.plus(frequency);
                                                        
                                                        Duration 
timeToNextExecution = Duration.between(Instant.now(), nextExecution);
-                                   
+
                                                        if 
(!timeToNextExecution.isNegative())
                                                        {
-                                                               
Thread.sleep(timeToNextExecution.toMillis());
+                                                               try {
+                                                                       
Thread.sleep(timeToNextExecution.toMillis());
+                                                               }
+                                                               catch 
(InterruptedException e) {
+                                                                       
Thread.currentThread().interrupt();
+                                                               }
                                                        }
-                                                       
                                                }
+                                               log.trace("Task '{}' stopped", 
name);
                                        }
                                        catch (Exception x)
                                        {

Reply via email to