@Override public AssemblerEvent take() { try { if (closed) return null; final int cloneIndex; synchronized (this) { if (closed) return null; else { // Here -1 can't be returned form the real stream // (only because of EOF) // because IOUtil.decodeZigZag32(-1) == -2_147_483_648 cloneIndex = readRawVarint32(is, -1); if (cloneIndex == -1) { closed = true; is.close(); return null; } } } long readId = IOUtil.readRawVarint64(is, -1); assert readId != -1; // )) previousReadId = readId += previousReadId; return new AssemblerEvent(counter++, readId, decodeZigZag32(cloneIndex)); } catch (IOException e) { throw new RuntimeException(e); } }
@Override public synchronized void close() { if (closed) return; try { is.close(); } catch (IOException e) { throw new RuntimeException(e); } }