Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8206888

When appending a byte to a file, 2GB of data are written

    Details

    • Subcomponent:
    • CPU:
      x86_64
    • OS:
      windows_8

      Description

      ADDITIONAL SYSTEM INFORMATION :
      Windows Server 2008 R2 terminal server
      Windows 7 Professional SP 1 as TS client

      A DESCRIPTION OF THE PROBLEM :
      Environment: Terminal Server (Windows RDP) connection, client disk mapped to a drive on a remote server.

      When appending data, even a single byte, to a file which resides on the mapped drive, the JVM writes 2GB of data.

      This issue can be reproduced:
      - either via java.io.FileOutputStream and java.nio.file.Files.write
      - both writing a new and an already existing file
      - both with 32bit and 64bit JVM

      This problem appeared recently, probably due some windows update.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Connect to a remote Windows 8 via RDP.
      Map a local drive to a server disk, for example by issuing the command: net use X: \\TSCLIENT\C
      Run a java program which writes a single byte to a file located in the mapped drive, opening it in append mode.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Only the actually written data is appended to the file, creating it if it doesn't exists.
      ACTUAL -
      2GB of content are skipped before the actual write, resulting in 2GB + 1byte sized file.

      ---------- BEGIN SOURCE ----------
      import java.nio.file.Files;
      import java.nio.file.Paths;
      import java.nio.file.StandardOpenOption;

      public class Append {
      public static void main(String[] args) throws Exception {
      Files.write(Paths.get(args[0]), new byte[] { 'a' }, StandardOpenOption.APPEND, StandardOpenOption.CREATE);
                      // the following code also reproduces the bug
      // FileOutputStream os = new FileOutputStream(new File(args[0]), true);
      // os.write(new byte[] { 'a' });
      // os.flush();
      // os.close();
      }
      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      No known workarounds

      FREQUENCY : always


        Attachments

          Activity

            People

            • Assignee:
              bpb Brian Burkhalter
              Reporter:
              webbuggrp Webbug Group
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated: