@Test public void test() throws Exception { ByteArrayInputStream inputStream = new ByteArrayInputStream("abcde".getBytes(Charsets.UTF_8)); MeteredInputStream meteredInputStream = MeteredInputStream.builder().in(inputStream).updateFrequency(1).build(); Limiter limiter = new CountBasedLimiter(4); InputStream throttled = new ThrottledInputStream(meteredInputStream, limiter, meteredInputStream); try { String output = IOUtils.toString(throttled, Charsets.UTF_8); Assert.fail(); } catch (RuntimeException re) { } meteredInputStream.reset(); limiter = new CountBasedLimiter(5); throttled = new ThrottledInputStream(meteredInputStream, limiter, meteredInputStream); Assert.assertEquals(IOUtils.toString(throttled, Charsets.UTF_8), "abcde"); }
@Override public synchronized void reset() throws IOException { super.reset(); this.prevCount = this.meter.getBytesProcessedMeter().getCount(); }
ThrottledInputStream extends FilterInputStream { @Override public synchronized void reset() throws IOException { super.reset(); this.prevCount = this.meter.getBytesProcessedMeter().getCount(); } }
ThrottledInputStream extends FilterInputStream { @Override public synchronized void reset() throws IOException { super.reset(); this.prevCount = this.meter.getBytesProcessedMeter().getCount(); } ThrottledInputStream(InputStream in, Limiter limiter, MeteredInputStream meter); }
ThrottledInputStream extends FilterInputStream { @Override public synchronized void reset() throws IOException { super.reset(); this.prevCount = this.meter.getBytesProcessedMeter().getCount(); } ThrottledInputStream(InputStream in, Limiter limiter, MeteredInputStream meter); @Override int read(); @Override int read(byte[] b); @Override int read(byte[] b, int off, int len); @Override synchronized void reset(); }
ThrottledInputStream extends FilterInputStream { @Override public synchronized void reset() throws IOException { super.reset(); this.prevCount = this.meter.getBytesProcessedMeter().getCount(); } ThrottledInputStream(InputStream in, Limiter limiter, MeteredInputStream meter); @Override int read(); @Override int read(byte[] b); @Override int read(byte[] b, int off, int len); @Override synchronized void reset();  }