I have a process that uses RestTemplate to call getForObject. This task is submitted to an executor service. I allow the process x seconds of run time before attempting to cancel it. However when I call Future.cancel(true) and the task is waiting in the getForObject method, the thread / task is not cancelled.
I have tested the code such that if I put a Thread.sleep in place of the getForObject I get an InterruptedException. However, when the task is inside getForObject not interruption occurrs. In face the method does not return until the Restful invocation is complete.
Is there a way to cancel the rest call?
I saw this post cancel abort interrupt a spring android resttemplate request but the only proposed solution seems to be a kludge.
RestTemplatein my project. How did you end up solving this problem? Since I don't see authors ofRestTemplateprovided this capability as of now. I am also calling cancel on my future but RestTemplate doesn't throw InterruptedException at all. - john