private void sendMessage(HttpMethodCall method) { StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace(); String methodName = ""; // getStackTrace()<-sendMessage()<-"actual caller" if (stackTraceElements.length >= 3) { methodName = stackTraceElements[2].getMethodName(); } Response response = null; try { response = method.call(); if (response.getStatus() != 200) { logger.verbose("'" + methodName + "' notification handler returned an error: " + response.getStatusInfo()); } else { logger.verbose("'" + methodName + "' succeeded: " + response); } } catch (RuntimeException e) { logger.log("'" + methodName + "' Server request failed: " + e.getMessage()); if (this.throwExceptions) { throw e; } } finally { if (response != null) { response.close(); } } }
protected Response sendLongRequest(HttpMethodCall method, String name) throws EyesException { // Adding the long request headers int maxDelay = 10000; int delay = 2000; // milliseconds Response response; while (true) { response = method.call(); if (response.getStatus() != 202) { return response; } // Since we haven't read the entity, We must release the response // or the connection stays open (meaning it'll get stuck after two // requests). response.close(); // Waiting a delay logger.verbose(String.format( "%s: Still running... Retrying in %d ms", name, delay)); try { Thread.sleep(delay); } catch (InterruptedException e) { throw new EyesException("Long request interrupted!", e); } // increasing the delay delay = Math.min(maxDelay, (int) Math.floor(delay * 1.5)); } }
protected Response sendLongRequest(HttpMethodCall method, String name) throws EyesException { // Adding the long request headers int maxDelay = 10000; int delay = 2000; // milliseconds Response response; while (true) { response = method.call(); if (response.getStatus() != 202) { return response; } // Since we haven't read the entity, We must release the response // or the connection stays open (meaning it'll get stuck after two // requests). response.close(); // Waiting a delay logger.verbose(String.format( "%s: Still running... Retrying in %d ms", name, delay)); try { Thread.sleep(delay); } catch (InterruptedException e) { throw new EyesException("Long request interrupted!", e); } // increasing the delay delay = Math.min(maxDelay, (int) Math.floor(delay * 1.5)); } }
protected Response sendLongRequest(HttpMethodCall method, String name) throws EyesException { // Adding the long request headers int maxDelay = 10000; int delay = 2000; // milliseconds Response response; while (true) { response = method.call(); if (response.getStatus() != 202) { return response; } // Since we haven't read the entity, We must release the response // or the connection stays open (meaning it'll get stuck after two // requests). response.close(); // Waiting a delay logger.verbose(String.format( "%s: Still running... Retrying in %d ms", name, delay)); try { Thread.sleep(delay); } catch (InterruptedException e) { throw new EyesException("Long request interrupted!", e); } // increasing the delay delay = Math.min(maxDelay, (int) Math.floor(delay * 1.5)); } }
private void sendMessage(HttpMethodCall method) { StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace(); String methodName = ""; // getStackTrace()<-sendMessage()<-"actual caller" if (stackTraceElements.length >= 3) { methodName = stackTraceElements[2].getMethodName(); } ClientResponse response = null; try { response = method.call(); if (response.getStatus() != 200) { logger.verbose("'" + methodName + "' notification handler returned an error: " + response.getStatusInfo()); } else { logger.verbose("'" + methodName + "' succeeded: " + response); } } catch (RuntimeException e) { logger.log("'" + methodName + "' Server request failed: " + e.getMessage()); if (this.throwExceptions) { throw e; } } finally { if (response != null) { response.close(); } } }
private void sendMessage(HttpMethodCall method) { StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace(); String methodName = ""; // getStackTrace()<-sendMessage()<-"actual caller" if (stackTraceElements.length >= 3) { methodName = stackTraceElements[2].getMethodName(); } Response response = null; try { response = method.call(); if (response.getStatus() != 200) { logger.verbose("'" + methodName + "' notification handler returned an error: " + response.getStatusInfo()); } else { logger.verbose("'" + methodName + "' succeeded: " + response); } } catch (RuntimeException e) { logger.log("'" + methodName + "' Server request failed: " + e.getMessage()); if (this.throwExceptions) { throw e; } } finally { if (response != null) { response.close(); } } }
private void sendMessage(HttpMethodCall method) { StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace(); String methodName = ""; // getStackTrace()<-sendMessage()<-"actual caller" if (stackTraceElements.length >= 3) { methodName = stackTraceElements[2].getMethodName(); } Response response = null; try { response = method.call(); if (response.getStatus() != 200) { logger.verbose("'" + methodName + "' notification handler returned an error: " + response.getStatusInfo()); } else { logger.verbose("'" + methodName + "' succeeded: " + response); } } catch (RuntimeException e) { logger.log("'" + methodName + "' Server request failed: " + e.getMessage()); if (this.throwExceptions) { throw e; } } finally { if (response != null) { response.close(); } } }
protected ClientResponse sendLongRequest(HttpMethodCall method, String name) throws EyesException { // Adding the long request headers int maxDelay = 10000; int delay = 2000; // milliseconds ClientResponse response; while (true) { response = method.call(); if (response.getStatus() != 202) { return response; } // Since we haven't read the entity, We must release the response // or the connection stays open (meaning it'll get stuck after two // requests). response.close(); // Waiting a delay logger.verbose(String.format( "%s: Still running... Retrying in %d ms", name, delay)); try { Thread.sleep(delay); } catch (InterruptedException e) { throw new EyesException("Long request interrupted!", e); } // increasing the delay delay = Math.min(maxDelay, (int) Math.floor(delay * 1.5)); } }
protected ClientResponse sendLongRequest(HttpMethodCall method, String name) throws EyesException { // Adding the long request headers int maxDelay = 10000; int delay = 2000; // milliseconds ClientResponse response; while (true) { response = method.call(); if (response.getStatus() != 202) { return response; } // Since we haven't read the entity, We must release the response // or the connection stays open (meaning it'll get stuck after two // requests). response.close(); // Waiting a delay logger.verbose(String.format( "%s: Still running... Retrying in %d ms", name, delay)); try { Thread.sleep(delay); } catch (InterruptedException e) { throw new EyesException("Long request interrupted!", e); } // increasing the delay delay = Math.min(maxDelay, (int) Math.floor(delay * 1.5)); } }