For anyone who doesn't like none of the solutions posted above like me then you can simply implement a timer yourself and stop the request execution by throwing a runtime exception. Something like below:
try
{
timer.schedule(new TimerTask() {
@Override
public void run() {
timer.cancel();
}
}, /* specify time of the requst */ 1000);
}
catch(Exception e)
{
throw new RuntimeException("the request is taking longer than usual");
}
or preferably use the java guava timeLimiter here