You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by mg...@apache.org on 2023/05/04 18:32:51 UTC

[wicket] branch master updated: [WICKET-7052] Interrupting a task should not be logged as an error (#588)

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

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


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

commit 1fd744a07080159a7ed3dd6e30c40044a7f23ccd
Author: Richard Eckart de Castilho <re...@apache.org>
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
    
    (cherry picked from commit c2574b443c2185fd520a35532782aaeaba1def23)
---
 .../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)
 					{