Code Monkey home page Code Monkey logo

Comments (7)

jhalterman avatar jhalterman commented on May 20, 2024

@leozilla Just pushed a fix for this. This issue has to do with performing an execution on via .future specifically where the resulting CompletableFuture cancellation was not propagated to the associated FailsafeFuture which would stop continued execution. Maybe you can give this a try and let me know if it resolves your problem. I pushed a test case here:

https://github.com/jhalterman/failsafe/blob/732746b013bb93f3d3d29ac3f026af19ef3cc532/src/test/java/net/jodah/failsafe/issues/Issue52.java#L36-L59

from failsafe.

leozilla avatar leozilla commented on May 20, 2024

Ah, thanks!
I did not expect this to be a bug otherwise I would have tried to fix it myself.
Anyway I try your fix now and let you know how it worked out.

from failsafe.

jhalterman avatar jhalterman commented on May 20, 2024

You should be able to just pull master and mvn package to give it a try. Tnx.

from failsafe.

jhalterman avatar jhalterman commented on May 20, 2024

Going to close this now ahead of the next release. @leozilla if the fix ends up not looking good on your end, feel free to re-open.

from failsafe.

jhalterman avatar jhalterman commented on May 20, 2024

Released 0.9.3 with this fix.

from failsafe.

leozilla avatar leozilla commented on May 20, 2024

Sorry for the delay, it works for me.
Just one more minor thing.
The test ExecutionTest#shouldSupportMaxDuration() breaks randomly on windows with oracle jdk 1.8.0_91
Reason seems to be the Thread.sleep is exactly as long as the max duration.

Fails

public void shouldSupportMaxDuration() throws Exception {
    Execution exec = new Execution(new RetryPolicy().withMaxDuration(100, TimeUnit.MILLISECONDS));
    assertTrue(exec.canRetryOn(e));
    assertTrue(exec.canRetryOn(e));
    Thread.sleep(100); // <--
    assertFalse(exec.canRetryOn(e));
    assertTrue(exec.isComplete());
  }

Succeeds (although still a little ugly)

public void shouldSupportMaxDuration() throws Exception {
    Execution exec = new Execution(new RetryPolicy().withMaxDuration(100, TimeUnit.MILLISECONDS));
    assertTrue(exec.canRetryOn(e));
    assertTrue(exec.canRetryOn(e));
    Thread.sleep(105); // <--
    assertFalse(exec.canRetryOn(e));
    assertTrue(exec.isComplete());
  }

Should I provide a fix/PR for it?

from failsafe.

jhalterman avatar jhalterman commented on May 20, 2024

Yea, that would be a good change. PR welcome :)

from failsafe.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.