/** * Sets the delegate of {@code timeout} to {@link Timeout#NONE} and resets its underlying timeout * to the default configuration. Use this to avoid unexpected sharing of timeouts between pooled * connections. */ void detachTimeout(ForwardingTimeout timeout) { Timeout oldDelegate = timeout.delegate(); timeout.setDelegate(Timeout.NONE); oldDelegate.clearDeadline(); oldDelegate.clearTimeout(); }
/** * Sets the delegate of {@code timeout} to {@link Timeout#NONE} and resets its underlying timeout * to the default configuration. Use this to avoid unexpected sharing of timeouts between pooled * connections. */ void detachTimeout(ForwardingTimeout timeout) { Timeout oldDelegate = timeout.delegate(); timeout.setDelegate(Timeout.NONE); oldDelegate.clearDeadline(); oldDelegate.clearTimeout(); }
/** * Reads until {@code in} is exhausted or the deadline has been reached. This is careful to not * extend the deadline if one exists already. */ public static boolean skipAll(Source source, int duration, TimeUnit timeUnit) throws IOException { long now = System.nanoTime(); long originalDuration = source.timeout().hasDeadline() ? source.timeout().deadlineNanoTime() - now : Long.MAX_VALUE; source.timeout().deadlineNanoTime(now + Math.min(originalDuration, timeUnit.toNanos(duration))); try { Buffer skipBuffer = new Buffer(); while (source.read(skipBuffer, 8192) != -1) { skipBuffer.clear(); } return true; // Success! The source has been exhausted. } catch (InterruptedIOException e) { return false; // We ran out of time before exhausting the source. } finally { if (originalDuration == Long.MAX_VALUE) { source.timeout().clearDeadline(); } else { source.timeout().deadlineNanoTime(now + originalDuration); } } }
/** * Reads until {@code in} is exhausted or the deadline has been reached. This is careful to not * extend the deadline if one exists already. */ public static boolean skipAll(Source source, int duration, TimeUnit timeUnit) throws IOException { long now = System.nanoTime(); long originalDuration = source.timeout().hasDeadline() ? source.timeout().deadlineNanoTime() - now : Long.MAX_VALUE; source.timeout().deadlineNanoTime(now + Math.min(originalDuration, timeUnit.toNanos(duration))); try { Buffer skipBuffer = new Buffer(); while (source.read(skipBuffer, 8192) != -1) { skipBuffer.clear(); } return true; // Success! The source has been exhausted. } catch (InterruptedIOException e) { return false; // We ran out of time before exhausting the source. } finally { if (originalDuration == Long.MAX_VALUE) { source.timeout().clearDeadline(); } else { source.timeout().deadlineNanoTime(now + originalDuration); } } }
@Override public Timeout clearDeadline() { return delegate.clearDeadline(); }
/** * Sets the delegate of {@code timeout} to {@link Timeout#NONE} and resets its underlying timeout * to the default configuration. Use this to avoid unexpected sharing of timeouts between pooled * connections. */ private void detachTimeout(ForwardingTimeout timeout) { Timeout oldDelegate = timeout.delegate(); timeout.setDelegate(Timeout.NONE); oldDelegate.clearDeadline(); oldDelegate.clearTimeout(); }
/** * Sets the delegate of {@code timeout} to {@link Timeout#NONE} and resets its underlying timeout * to the default configuration. Use this to avoid unexpected sharing of timeouts between pooled * connections. */ void detachTimeout(ForwardingTimeout timeout) { Timeout oldDelegate = timeout.delegate(); timeout.setDelegate(Timeout.NONE); oldDelegate.clearDeadline(); oldDelegate.clearTimeout(); }
/** * Sets the delegate of {@code timeout} to {@link Timeout#NONE} and resets its underlying timeout * to the default configuration. Use this to avoid unexpected sharing of timeouts between pooled * connections. */ private void detachTimeout(ForwardingTimeout timeout) { Timeout oldDelegate = timeout.delegate(); timeout.setDelegate(Timeout.NONE); oldDelegate.clearDeadline(); oldDelegate.clearTimeout(); }
/** * Sets the delegate of {@code timeout} to {@link Timeout#NONE} and resets its underlying timeout * to the default configuration. Use this to avoid unexpected sharing of timeouts between pooled * connections. */ private void detachTimeout(ForwardingTimeout timeout) { Timeout oldDelegate = timeout.delegate(); timeout.setDelegate(Timeout.NONE); oldDelegate.clearDeadline(); oldDelegate.clearTimeout(); }
/** * Sets the delegate of {@code timeout} to {@link Timeout#NONE} and resets its underlying timeout * to the default configuration. Use this to avoid unexpected sharing of timeouts between pooled * connections. */ void detachTimeout(ForwardingTimeout timeout) { Timeout oldDelegate = timeout.delegate(); timeout.setDelegate(Timeout.NONE); oldDelegate.clearDeadline(); oldDelegate.clearTimeout(); }
/** * Reads until {@code in} is exhausted or the deadline has been reached. This is careful to not * extend the deadline if one exists already. */ public static boolean skipAll(Source source, int duration, TimeUnit timeUnit) throws IOException { long now = System.nanoTime(); long originalDuration = source.timeout().hasDeadline() ? source.timeout().deadlineNanoTime() - now : Long.MAX_VALUE; source.timeout().deadlineNanoTime(now + Math.min(originalDuration, timeUnit.toNanos(duration))); try { Buffer skipBuffer = new Buffer(); while (source.read(skipBuffer, 2048) != -1) { skipBuffer.clear(); } return true; // Success! The source has been exhausted. } catch (InterruptedIOException e) { return false; // We ran out of time before exhausting the source. } finally { if (originalDuration == Long.MAX_VALUE) { source.timeout().clearDeadline(); } else { source.timeout().deadlineNanoTime(now + originalDuration); } } }
/** * Reads until {@code in} is exhausted or the deadline has been reached. This is careful to not * extend the deadline if one exists already. */ public static boolean skipAll(Source source, int duration, TimeUnit timeUnit) throws IOException { long now = System.nanoTime(); long originalDuration = source.timeout().hasDeadline() ? source.timeout().deadlineNanoTime() - now : Long.MAX_VALUE; source.timeout().deadlineNanoTime(now + Math.min(originalDuration, timeUnit.toNanos(duration))); try { Buffer skipBuffer = new Buffer(); while (source.read(skipBuffer, 2048) != -1) { skipBuffer.clear(); } return true; // Success! The source has been exhausted. } catch (InterruptedIOException e) { return false; // We ran out of time before exhausting the source. } finally { if (originalDuration == Long.MAX_VALUE) { source.timeout().clearDeadline(); } else { source.timeout().deadlineNanoTime(now + originalDuration); } } }
/** * Reads until {@code in} is exhausted or the deadline has been reached. This is careful to not * extend the deadline if one exists already. */ public static boolean skipAll(Source source, int duration, TimeUnit timeUnit) throws IOException { long now = System.nanoTime(); long originalDuration = source.timeout().hasDeadline() ? source.timeout().deadlineNanoTime() - now : Long.MAX_VALUE; source.timeout().deadlineNanoTime(now + Math.min(originalDuration, timeUnit.toNanos(duration))); try { Buffer skipBuffer = new Buffer(); while (source.read(skipBuffer, 8192) != -1) { skipBuffer.clear(); } return true; // Success! The source has been exhausted. } catch (InterruptedIOException e) { return false; // We ran out of time before exhausting the source. } finally { if (originalDuration == Long.MAX_VALUE) { source.timeout().clearDeadline(); } else { source.timeout().deadlineNanoTime(now + originalDuration); } } }
/** * Reads until {@code in} is exhausted or the deadline has been reached. This is careful to not * extend the deadline if one exists already. */ public static boolean skipAll(Source source, int duration, TimeUnit timeUnit) throws IOException { long now = System.nanoTime(); long originalDuration = source.timeout().hasDeadline() ? source.timeout().deadlineNanoTime() - now : Long.MAX_VALUE; source.timeout().deadlineNanoTime(now + Math.min(originalDuration, timeUnit.toNanos(duration))); try { Buffer skipBuffer = new Buffer(); while (source.read(skipBuffer, 8192) != -1) { skipBuffer.clear(); } return true; // Success! The source has been exhausted. } catch (InterruptedIOException e) { return false; // We ran out of time before exhausting the source. } finally { if (originalDuration == Long.MAX_VALUE) { source.timeout().clearDeadline(); } else { source.timeout().deadlineNanoTime(now + originalDuration); } } }
/** * Reads until {@code in} is exhausted or the deadline has been reached. This is careful to not * extend the deadline if one exists already. */ public static boolean skipAll(Source source, int duration, TimeUnit timeUnit) throws IOException { long now = System.nanoTime(); long originalDuration = source.timeout().hasDeadline() ? source.timeout().deadlineNanoTime() - now : Long.MAX_VALUE; source.timeout().deadlineNanoTime(now + Math.min(originalDuration, timeUnit.toNanos(duration))); try { Buffer skipBuffer = new Buffer(); while (source.read(skipBuffer, 8192) != -1) { skipBuffer.clear(); } return true; // Success! The source has been exhausted. } catch (InterruptedIOException e) { return false; // We ran out of time before exhausting the source. } finally { if (originalDuration == Long.MAX_VALUE) { source.timeout().clearDeadline(); } else { source.timeout().deadlineNanoTime(now + originalDuration); } } }
/** * Reads until {@code in} is exhausted or the deadline has been reached. This is careful to not * extend the deadline if one exists already. */ public static boolean skipAll(Source source, int duration, TimeUnit timeUnit) throws IOException { long now = System.nanoTime(); long originalDuration = source.timeout().hasDeadline() ? source.timeout().deadlineNanoTime() - now : Long.MAX_VALUE; source.timeout().deadlineNanoTime(now + Math.min(originalDuration, timeUnit.toNanos(duration))); try { Buffer skipBuffer = new Buffer(); while (source.read(skipBuffer, 2048) != -1) { skipBuffer.clear(); } return true; // Success! The source has been exhausted. } catch (InterruptedIOException e) { return false; // We ran out of time before exhausting the source. } finally { if (originalDuration == Long.MAX_VALUE) { source.timeout().clearDeadline(); } else { source.timeout().deadlineNanoTime(now + originalDuration); } } }