Source:
public void run() { try { while (true) { LOGGER.finest("reading frame"); int framelen; try { framelen = dis.readInt(); } catch (EOFException x) { handleClose(); break; } catch (IOException x) { if (x.getCause() instanceof TimeoutException) { LOGGER.log(Level.FINE, "ignoring idle timeout, perhaps from Jetty", x); continue; } else { throw x; } } if (framelen < 0) { throw new IOException("corrupt stream: negative frame length"); } byte b = dis.readByte(); if (b < 0) { throw new IOException("corrupt stream: negative operation code"); } if (b >= Op.values().length) { LOGGER.log(Level.WARNING, "unknown operation #{0}: {1}", new Object[] {b, HexDump.toHex(flightRecorder.getRecord())}); IOUtils.skipFully(dis, framelen); continue; } Op op = Op.values()[b]; long start = cis.getByteCount(); LOGGER.log(Level.FINEST, "handling frame with {0} of length {1}", new Object[] {op, framelen}); boolean handled = handle(op, framelen); if (handled) { long actuallyRead = cis.getByteCount() - start; if (actuallyRead != framelen) { throw new IOException("corrupt stream: expected to read " + framelen + " bytes from " + op + " but read " + actuallyRead); } } else { LOGGER.log(Level.WARNING, "unexpected {0}: {1}", new Object[] {op, HexDump.toHex(flightRecorder.getRecord())}); IOUtils.skipFully(dis, framelen); } } } catch (ClosedChannelException x) { LOGGER.log(Level.FINE, null, x); handleClose(); } catch (IOException x) { LOGGER.log(Level.WARNING, null, flightRecorder.analyzeCrash(x, "broken stream")); } catch (ReadPendingException x) { LOGGER.log(Level.FINE, null, x); handleClose(); } }

Target:
public void run() { try { while (true) { LOGGER.finest("reading frame"); int framelen; try { framelen = dis.readInt(); } catch (EOFException x) { handleClose(); break; } catch (IOException x) { if (x.getCause() instanceof TimeoutException) { LOGGER.log(Level.FINE, "ignoring idle timeout, perhaps from Jetty", x); continue; } else { throw x; } } if (framelen < 0) { throw new IOException("corrupt stream: negative frame length"); } byte b = dis.readByte(); if (b < 0) { throw new IOException("corrupt stream: negative operation code"); } if (b >= Op.values().length) { LOGGER.log(Level.WARNING, "unknown operation #{0}: {1}", new Object[] {b, HexDump.toHex(flightRecorder.getRecord())}); IOUtils.skipFully(dis, framelen); continue; } Op op = Op.values()[b]; long start = cis.getByteCount(); LOGGER.log(Level.FINEST, "handling frame with {0} of length {1}", new Object[] {op, framelen}); boolean handled = handle(op, framelen); if (handled) { long actuallyRead = cis.getByteCount() - start; if (actuallyRead != framelen) { throw new IOException("corrupt stream: expected to read " + framelen + " bytes from " + op + " but read " + actuallyRead); } } else { LOGGER.log(Level.WARNING, "unexpected {0}: {1}", new Object[] {op, HexDump.toHex(flightRecorder.getRecord())}); IOUtils.skipFully(dis, framelen); } } } catch (ClosedChannelException x) { LOGGER.log(Level.FINE, null, x); handleClose(); } catch (IOException x) { LOGGER.log(Level.WARNING, null, flightRecorder.analyzeCrash(x, "broken stream")); } catch (ReadPendingException x) { LOGGER.log(Level.FINE, null, x); handleClose(); } catch (RuntimeException x) { LOGGER.log(Level.WARNING, null, x); handleClose(); } }