--- old/src/java.base/share/classes/sun/net/NetworkServer.java 2017-12-22 15:05:52.000000000 -0800 +++ new/src/java.base/share/classes/sun/net/NetworkServer.java 2017-12-22 15:05:51.000000000 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1995, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,6 +27,7 @@ import java.io.*; import java.net.Socket; import java.net.ServerSocket; +import jdk.internal.io.IOSupport; /** * This is the base class for network servers. To define a new type @@ -117,13 +118,9 @@ server just echoes it's input. It is invoked in it's own private thread. */ public void serviceRequest() throws IOException { - byte buf[] = new byte[300]; - int n; clientOutput.print("Echo server " + getClass().getName() + "\n"); clientOutput.flush(); - while ((n = clientInput.read(buf, 0, buf.length)) >= 0) { - clientOutput.write(buf, 0, n); - } + IOSupport.copy(clientInput, clientOutput, 300); } public static void main(String argv[]) {