From 617e8f773fca9fe8a38b9016b852b357cc127cff Mon Sep 17 00:00:00 2001 From: rusefi Date: Sat, 25 Jul 2020 14:45:29 -0400 Subject: [PATCH] better way to handle timeout? --- .../com/rusefi/binaryprotocol/IncomingDataBuffer.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/java_console/io/src/main/java/com/rusefi/binaryprotocol/IncomingDataBuffer.java b/java_console/io/src/main/java/com/rusefi/binaryprotocol/IncomingDataBuffer.java index cd722680ff..63f729726e 100644 --- a/java_console/io/src/main/java/com/rusefi/binaryprotocol/IncomingDataBuffer.java +++ b/java_console/io/src/main/java/com/rusefi/binaryprotocol/IncomingDataBuffer.java @@ -172,28 +172,28 @@ public class IncomingDataBuffer { public byte readByte(int timeoutMs) throws IOException { boolean isTimeout = waitForBytes(timeoutMs, loggingPrefix + "readByte", System.currentTimeMillis(), 1); if (isTimeout) - throw new IOException("Timeout in readByte"); + throw new EOFException("Timeout in readByte"); return (byte) getByte(); } public int readInt() throws EOFException { boolean isTimeout = waitForBytes(loggingPrefix + "readInt", System.currentTimeMillis(), 4); if (isTimeout) - throw new IllegalStateException("Timeout in readByte"); + throw new EOFException("Timeout in readByte"); return swap32(getInt()); } public short readShort() throws EOFException { boolean isTimeout = waitForBytes(loggingPrefix + "readShort", System.currentTimeMillis(), 2); if (isTimeout) - throw new IllegalStateException("Timeout in readShort"); + throw new EOFException("Timeout in readShort"); return (short) swap16(getShort()); } - public int read(byte[] packet) { + public int read(byte[] packet) throws EOFException { boolean isTimeout = waitForBytes(loggingPrefix + "read", System.currentTimeMillis(), packet.length); if (isTimeout) - throw new IllegalStateException("Timeout while waiting " + packet.length); + throw new EOFException("Timeout while waiting " + packet.length); getData(packet); return packet.length; }