[
https://issues.apache.org/jira/browse/SLING-13105?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18058091#comment-18058091
]
Joerg Hoh edited comment on SLING-13105 at 2/12/26 9:58 AM:
------------------------------------------------------------
Indeed, the problem is just when a different thread is interrupted, something
like
{noformat}
backgroundThread.interrupt();
{noformat}
as shown in SLING-4477.
If the *current thread* is interrupted, there will never be a problem. For that
{noformat}
Thread.currentThread().interrupt();
{noformat}
is not problematic. And for that we might want to update the Oak documentation
(https://jackrabbit.apache.org/oak/docs/dos_and_donts.html#Don.27t_use_Thread.interrupt.28.29)
was (Author: joerghoh):
Indeed, the problem is just when a different thread is interrupted, something
like
{noformat}
backgroundThread.interrupt();
{noformat}
as shown in SLING-4477.
If the *current thread* is interrupted, there will never be a problem. For that
{noformat}
Thread.currentThread().interrupt();
{noformat}
is not problematic.
> Review all occurrences of InterruptedException
> ----------------------------------------------
>
> Key: SLING-13105
> URL: https://issues.apache.org/jira/browse/SLING-13105
> Project: Sling
> Issue Type: Improvement
> Components: Content Distribution
> Affects Versions: Content Distribution Journal Core 0.5.0
> Reporter: Joerg Hoh
> Priority: Major
>
> I see a few occurrences of ThreadInterruptedExceptions being thrown and
> handled by Thread.interrupt(), although in
> [DistributionJournal.deactivate()|https://github.com/apache/sling-org-apache-sling-distribution-journal/blob/4ff1af58dff42e97e6f58793472b84163a086d32/src/main/java/org/apache/sling/distribution/journal/impl/subscriber/DistributionSubscriber.java#L228-L234]
> states this:
> {noformat}
> /*
> * Note that we don't interrupt blocking calls using
> Thread.interrupt()
> * because interrupts can stop the Apache Oak repository.
> *
> * See SLING-9340, OAK-2609 and
> * https://jackrabbit.apache.org/oak/docs/dos_and_donts.html
> */
> {noformat}
> We should review all instances of this and find a way to handle these cases
> better.
> {noformat}
> $ grep -ri ".interrupt()" src/main/java
> src/main/java/org/apache/sling/distribution/journal/impl/publisher/QueueCacheSeeder.java:
> Thread.currentThread().interrupt();
> src/main/java/org/apache/sling/distribution/journal/impl/publisher/QueueCacheSeeder.java:
> Thread.currentThread().interrupt();
> src/main/java/org/apache/sling/distribution/journal/impl/publisher/DistributionPublisher.java:
> Thread.currentThread().interrupt();
> src/main/java/org/apache/sling/distribution/journal/impl/subscriber/DistributionSubscriber.java:
> * Note that we don't interrupt blocking calls using
> Thread.interrupt()
> src/main/java/org/apache/sling/distribution/journal/impl/subscriber/DistributionSubscriber.java:
> Thread.currentThread().interrupt();
> src/main/java/org/apache/sling/distribution/journal/shared/Delay.java:
> Thread.currentThread().interrupt();
> src/main/java/org/apache/sling/distribution/journal/shared/ExponentialBackOff.java:
> Thread.currentThread().interrupt();
> src/main/java/org/apache/sling/distribution/journal/bookkeeper/BookKeeper.java:
> Thread.currentThread().interrupt();
> src/main/java/org/apache/sling/distribution/journal/queue/impl/PubQueueProviderImpl.java:
> Thread.currentThread().interrupt();
> {noformat}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)