[ 
https://issues.apache.org/jira/browse/SLING-8374?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16826811#comment-16826811
 ] 

Timothee Maret commented on SLING-8374:
---------------------------------------

Thanks [~akrainiouk]! I commented on the two cases reported below.

Case 1. The reasoning is based on an incorrect premise. 
[MessagingException|https://github.com/apache/sling-org-apache-sling-distribution-journal-messages/blob/6830b0388a62d4294c3890d6764d23e6302bf3b9/src/main/java/org/apache/sling/distribution/journal/MessagingException.java#L21]
 extends from {{java.lang.RuntimeException}} which extends from 
{{java.lang.Exception}}. The catch block in 
[timedSendStoredStatus|https://github.com/apache/sling-org-apache-sling-distribution-journal/blob/master/src/main/java/org/apache/sling/distribution/journal/impl/subscriber/DistributionSubscriber.java#L663]
 catches {{MessagingException}} exceptions.

Case 2. Good point, we could catch {{java.lang.Throwable}} such that the 
metrics count all errors. However we should then re-throw all 
{{java.lang.Error}} exceptions instead of only the 
{{java.lang.VirtualMachineError}} exceptions.

> Missing out exceptions in catch clause in DistributionSubscriber class
> ----------------------------------------------------------------------
>
>                 Key: SLING-8374
>                 URL: https://issues.apache.org/jira/browse/SLING-8374
>             Project: Sling
>          Issue Type: Bug
>          Components: Content Distribution
>    Affects Versions: Content Distribution Journal Core 0.1.0
>            Reporter: Alexei Krainiouk
>            Priority: Major
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> There are two cases when catch clause is not catching necessary exceptions.
>  #  in 
> [DistributionSubscriber.timedSendStoredStatus|https://github.com/apache/sling-org-apache-sling-distribution-journal/blob/master/src/main/java/org/apache/sling/distribution/journal/impl/subscriber/DistributionSubscriber.java#L663]
>  method. Apparently the intent is to catch an exception thrown by 
> sendStatusMessage() method which in turn triggered by 
> [sender.send()|https://github.com/apache/sling-org-apache-sling-distribution-journal/blob/master/src/main/java/org/apache/sling/distribution/journal/impl/subscriber/DistributionSubscriber.java#L690]
>  invocation. However sender.send() method throws MessagingException which 
> subclasses RuntimeError rather then Exception. As a result the exception is 
> never caught.
>  # in 
> [DistributionSubscriber.importPackage|https://github.com/apache/sling-org-apache-sling-distribution-journal/blob/master/src/main/java/org/apache/sling/distribution/journal/impl/subscriber/DistributionSubscriber.java#L690]
>  method. catch (Exception e) should be replaced with catch (Throwable e) in 
> order to count all possible errors in failedPackageImports metric.
> This pull request provides fixes for above issues: 
> [https://github.com/apache/sling-org-apache-sling-distribution-journal/pull/3]



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to