@Test public void testGetMessageLengthThrowsNullPointerException() throws Throwable { ASCIIChannel aSCIIChannel = new ASCIIChannel(new Base1Packager()); try { aSCIIChannel.getMessageLength(); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { if (isJavaVersionAtMost(JAVA_14)) { assertNull(ex.getMessage(), "ex.getMessage()"); } else { assertEquals("Cannot invoke \"java.io.DataInputStream.readFully(byte[], int, int)\" because \"this.serverIn\" is null", ex.getMessage(), "ex.getMessage()"); } } }
protected int getMessageLength() throws IOException, ISOException { int l = 0; byte[] b = new byte[lengthDigits]; while (l == 0) { serverIn.readFully(b, 0, lengthDigits); try { if ((l=Integer.parseInt(new String(b))) == 0) { serverOut.write(b); serverOut.flush(); } } catch (NumberFormatException e) { throw new ISOException ("Invalid message length "+new String(b)); } } return l; }
ASCIIChannel extends BaseChannel { protected int getMessageLength() throws IOException, ISOException { int l = 0; byte[] b = new byte[lengthDigits]; while (l == 0) { serverIn.readFully(b, 0, lengthDigits); try { if ((l=Integer.parseInt(new String(b))) == 0) { serverOut.write(b); serverOut.flush(); } } catch (NumberFormatException e) { throw new ISOException ("Invalid message length "+new String(b)); } } return l; } }
ASCIIChannel extends BaseChannel { protected int getMessageLength() throws IOException, ISOException { int l = 0; byte[] b = new byte[lengthDigits]; while (l == 0) { serverIn.readFully(b, 0, lengthDigits); try { if ((l=Integer.parseInt(new String(b))) == 0) { serverOut.write(b); serverOut.flush(); } } catch (NumberFormatException e) { throw new ISOException ("Invalid message length "+new String(b)); } } return l; } ASCIIChannel();  ASCIIChannel(String host, int port, ISOPackager p);  ASCIIChannel(ISOPackager p);  ASCIIChannel(ISOPackager p, ServerSocket serverSocket); }
ASCIIChannel extends BaseChannel { protected int getMessageLength() throws IOException, ISOException { int l = 0; byte[] b = new byte[lengthDigits]; while (l == 0) { serverIn.readFully(b, 0, lengthDigits); try { if ((l=Integer.parseInt(new String(b))) == 0) { serverOut.write(b); serverOut.flush(); } } catch (NumberFormatException e) { throw new ISOException ("Invalid message length "+new String(b)); } } return l; } ASCIIChannel();  ASCIIChannel(String host, int port, ISOPackager p);  ASCIIChannel(ISOPackager p);  ASCIIChannel(ISOPackager p, ServerSocket serverSocket); void setLengthDigits(int len); int getLengthDigits(); @Override void setConfiguration(Configuration cfg); }
ASCIIChannel extends BaseChannel { protected int getMessageLength() throws IOException, ISOException { int l = 0; byte[] b = new byte[lengthDigits]; while (l == 0) { serverIn.readFully(b, 0, lengthDigits); try { if ((l=Integer.parseInt(new String(b))) == 0) { serverOut.write(b); serverOut.flush(); } } catch (NumberFormatException e) { throw new ISOException ("Invalid message length "+new String(b)); } } return l; } ASCIIChannel();  ASCIIChannel(String host, int port, ISOPackager p);  ASCIIChannel(ISOPackager p);  ASCIIChannel(ISOPackager p, ServerSocket serverSocket); void setLengthDigits(int len); int getLengthDigits(); @Override void setConfiguration(Configuration cfg);  }