You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@activemq.apache.org by "Matthew Stratton (JIRA)" <ji...@apache.org> on 2018/07/23 12:46:00 UTC

[jira] [Comment Edited] (AMQ-7017) ProducerBrokerExchange.getPercentageBlocked() throws ArithmeticException (divide by zero)

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

Matthew Stratton edited comment on AMQ-7017 at 7/23/18 12:45 PM:
-----------------------------------------------------------------

Perhaps, but I think it may just be an extreme edge case.

The plugin I wrote[1] logs message information for audit purposes and happens before authentication even happens to ensure we get information regardless of the outcome of the operation. It is including percentage blocked regardless of send count or block count. The unit test for the plugin instantiates a new broker and a new connection to that broker, so the first time this plugin fires on the connection, the send count is zero. If I move the log statement to after calling `super.send(producerExchange, messageSend);` the test does not throw the ArithmeticException. There are plenty of ways to work around it in the plugin.

[1]- [https://gist.github.com/macgregor/c108f1ca5051e6d9b08ab388d17d0126]


was (Author: mstratto):
Perhaps, but I think it may just be an extreme edge case.

The plugin I wrote[1] logs message information for audit purposes and happens before authentication even happens to ensure we get information regardless of the outcome of the operation. It is including percentage blocked regardless of send count. The unit test for the plugin instantiates a new broker and a new connection to that broker, so the first time this plugin fires on the connection, the send count is zero. If I move the log statement to after calling `super.send(producerExchange, messageSend);` the test does not throw the ArithmeticException. There are plenty of ways to work around it in the plugin.

[1]- https://gist.github.com/macgregor/c108f1ca5051e6d9b08ab388d17d0126

> ProducerBrokerExchange.getPercentageBlocked() throws ArithmeticException (divide by zero)
> -----------------------------------------------------------------------------------------
>
>                 Key: AMQ-7017
>                 URL: https://issues.apache.org/jira/browse/AMQ-7017
>             Project: ActiveMQ
>          Issue Type: Bug
>          Components: Broker
>    Affects Versions: 5.15.4
>            Reporter: Matthew Stratton
>            Priority: Trivial
>              Labels: patch
>         Attachments: fix-producer-exchange-divide-by-zero.txt
>
>
> I found this when testing a broker plugin for tracking messages sent (including some stats like getPercentageBlocked). When there have been no blocked messages an ArithmeticException is thrown due to an unchecked divide by zero. 
> I fixed it and added a couple unit tests.



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