You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "Thierry Ygé (JIRA)" <ji...@apache.org> on 2018/11/16 14:21:01 UTC

[jira] [Updated] (SLING-8114) Allow to do polling of code failing on asserts

     [ https://issues.apache.org/jira/browse/SLING-8114?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Thierry Ygé updated SLING-8114:
-------------------------------
    Description: 
Currently if you polling check uses assertions , it will not be retried, this is due to this line

[https://github.com/apache/sling-org-apache-sling-testing-clients/blob/master/src/main/java/org/apache/sling/testing/clients/util/poller/Polling.java#L118]

Which is only catching Exceptions while failing Assertions are an error kind (AssertionError).

It would be nice to handle it so that code wouldn't have to "transform" it to exception.

To reproduce simply use assertion in your polling check and let it fail if a counter is lower than a value. make the polling retries so that at the next retry counter it should pass.

 
{quote}int count = 0;

new Polling(() -> {  count++;   Assert.assertTrue(count == 2);  return true;         }

).poll(2000, 500);
{quote}
Observation: it exist the poll directly as the assert fail already.

Expected: It should have polled until the check pass here.

 

  was:
Currently if you polling check uses assertions , it will not be retried, this is due to this line

[https://github.com/apache/sling-org-apache-sling-testing-clients/blob/master/src/main/java/org/apache/sling/testing/clients/util/poller/Polling.java#L118]

Which is only catching Exceptions while failing Assertions are an error kind (AssertionError).

It would be nice to handle it so that code wouldn't have to "transform" it to exception.

To reproduce simply use assertion in your polling check and let it fail if a counter is lower than a value. make the polling retries so that at the next retry counter it should pass.

 
{quote}int count = 0;

new Polling(() -> {

               count++;

               Assert.assertTrue(count == 2);

               return true;

        }).poll(2000, 500);
{quote}
Observation: it exist the poll directly as the assert fail already.

Expected: It should have polled until the check pass here.

 


> Allow to do polling of code failing on asserts
> ----------------------------------------------
>
>                 Key: SLING-8114
>                 URL: https://issues.apache.org/jira/browse/SLING-8114
>             Project: Sling
>          Issue Type: Improvement
>          Components: Apache Sling Testing Clients
>    Affects Versions: Apache Sling Testing Clients 1.2.0
>            Reporter: Thierry Ygé
>            Priority: Major
>
> Currently if you polling check uses assertions , it will not be retried, this is due to this line
> [https://github.com/apache/sling-org-apache-sling-testing-clients/blob/master/src/main/java/org/apache/sling/testing/clients/util/poller/Polling.java#L118]
> Which is only catching Exceptions while failing Assertions are an error kind (AssertionError).
> It would be nice to handle it so that code wouldn't have to "transform" it to exception.
> To reproduce simply use assertion in your polling check and let it fail if a counter is lower than a value. make the polling retries so that at the next retry counter it should pass.
>  
> {quote}int count = 0;
> new Polling(() -> {  count++;   Assert.assertTrue(count == 2);  return true;         }
> ).poll(2000, 500);
> {quote}
> Observation: it exist the poll directly as the assert fail already.
> Expected: It should have polled until the check pass here.
>  



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