@Test (expected = EOFException.class) @SuppressFBWarnings ("RR_NOT_CHECKED") public void readBufferFromEmpty () throws Exception { final InputStream empty = new NonBlockingByteArrayInputStream ("".getBytes ()); final byte [] buf = new byte [17]; try (final ChunkedInputStream cIS = new ChunkedInputStream (empty)) { cIS.read (buf, 0, buf.length); fail ("An EOFException should have been thrown"); } }
@Override public final int read () throws IOException { if (m_nLeft < 0) return -1; if (m_nLeft == 0) { if (m_bAfterFirstChunk) { HTTPHelper.readTillNexLine (m_aIS); } else { m_bAfterFirstChunk = true; } m_nLeft = HTTPHelper.readChunkLen (m_aIS); if (LOGGER.isDebugEnabled ()) LOGGER.debug ("Read chunk size: " + m_nLeft); if (m_nLeft <= 0) { m_nLeft = -1; return -1; } } m_nLeft--; return super.read (); }
ChunkedInputStream extends FilterInputStream { @Override public final int read () throws IOException { if (m_nLeft < 0) return -1; if (m_nLeft == 0) { if (m_bAfterFirstChunk) { HTTPHelper.readTillNexLine (m_aIS); } else { m_bAfterFirstChunk = true; } m_nLeft = HTTPHelper.readChunkLen (m_aIS); if (LOGGER.isDebugEnabled ()) LOGGER.debug ("Read chunk size: " + m_nLeft); if (m_nLeft <= 0) { m_nLeft = -1; return -1; } } m_nLeft--; return super.read (); } }
ChunkedInputStream extends FilterInputStream { @Override public final int read () throws IOException { if (m_nLeft < 0) return -1; if (m_nLeft == 0) { if (m_bAfterFirstChunk) { HTTPHelper.readTillNexLine (m_aIS); } else { m_bAfterFirstChunk = true; } m_nLeft = HTTPHelper.readChunkLen (m_aIS); if (LOGGER.isDebugEnabled ()) LOGGER.debug ("Read chunk size: " + m_nLeft); if (m_nLeft <= 0) { m_nLeft = -1; return -1; } } m_nLeft--; return super.read (); } ChunkedInputStream(@Nonnull final InputStream aIS); }
ChunkedInputStream extends FilterInputStream { @Override public final int read () throws IOException { if (m_nLeft < 0) return -1; if (m_nLeft == 0) { if (m_bAfterFirstChunk) { HTTPHelper.readTillNexLine (m_aIS); } else { m_bAfterFirstChunk = true; } m_nLeft = HTTPHelper.readChunkLen (m_aIS); if (LOGGER.isDebugEnabled ()) LOGGER.debug ("Read chunk size: " + m_nLeft); if (m_nLeft <= 0) { m_nLeft = -1; return -1; } } m_nLeft--; return super.read (); } ChunkedInputStream(@Nonnull final InputStream aIS); @Override final int read(); @Override final int read(@Nonnull final byte [] aBuf, final int nOffset, final int nLength); }
ChunkedInputStream extends FilterInputStream { @Override public final int read () throws IOException { if (m_nLeft < 0) return -1; if (m_nLeft == 0) { if (m_bAfterFirstChunk) { HTTPHelper.readTillNexLine (m_aIS); } else { m_bAfterFirstChunk = true; } m_nLeft = HTTPHelper.readChunkLen (m_aIS); if (LOGGER.isDebugEnabled ()) LOGGER.debug ("Read chunk size: " + m_nLeft); if (m_nLeft <= 0) { m_nLeft = -1; return -1; } } m_nLeft--; return super.read (); } ChunkedInputStream(@Nonnull final InputStream aIS); @Override final int read(); @Override final int read(@Nonnull final byte [] aBuf, final int nOffset, final int nLength);  }