response.getOutputStream.flush() throws ClientAbortException

   response.setContentLength(size);
   response.setHeader("Connection", "Close");
   try {

        OutputStream os = response.getOutputStream();
        byte[] bytes = new byte[2048];
        int count = bais.read(bytes);
        while (count > 0) {
            os.write(bytes, 0, count);
            count = bais.read(bytes);
        }
        os.flush();   // this line throws ClientAbortException
    } catch (Exception e) {

    } finally {
        // Do I need to close os here
    }

In what all situations, we will get the above error ClientAbortException: java.net.SocketException: Connection reset

Note: Mine is a server program and my server sends RST signal to the clinet at that point while submitting the response.