Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Override
- public boolean matchesSafely(Callable action) {
- T callResult;
- boolean matched = false;
- StopWatch timer = new StopWatch();
- timer.start();
- try {
- while (timer.getTime() <= maxWaitTime) {
- try {
- callResult = (T) action.call();
- matched = callResultMatcher.matches(callResult);
- if (matched) {
- return matched;
- }
- } catch (Exception e) {
- log.warning("An error occurred while calling an action: " + e.getMessage());
- }
- try {
- Thread.sleep(checkInterval);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
- } finally {
- timer.stop();
- }
- return matched;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement