Uploaded image for project: 'NetBeans'
  1. NetBeans
  2. NETBEANS-4617

stdout not flushed to console until new line

    XMLWordPrintableJSON

Details

    Description

      Similar (if not completely same) with: https://github.com/JetBrains/intellij-community/commit/707cf1427f66beb24faa5b8193217e52a8bb85d1 issue. In IntelliJ IDEA case, a fix has been published for version 2020.1. Can be used as reference.

      Basically, printf() and print() does not work until a newline, not even System.out.flush() will work. This only happens on Gradle projects, and when running through the IDE (does not happen to Maven/Ant). This does not happen to println() because it prints new line.

      Quite a breaking stuff, impossible to accept user input on the same line through the console.

      As an example to demonstrate the issue:

      public static void main(String[] args) {
              Scanner in = new Scanner(System.in);
              
              System.out.print("Please enter ABC: ");
              in.next();
              System.out.printf("DEF: ");
              in.next();
              System.out.println("GHI: ");
              in.next();
          }
      

      Output:

      JAVA_HOME="C:\Program Files\AdoptOpenJDK\jdk-14.0.1.7-hotspot"
      cd C:\repo\test-cli; ./gradlew --configure-on-demand -PrunClassName=Transaction.Transaction -x check runSingle
      Configuration on demand is an incubating feature.
      > Task :compileJava UP-TO-DATE
      > Task :processResources NO-SOURCE
      > Task :classes UP-TO-DATE> Task :runSingle
      ABC
      DEF
      Please enter ABC: DEF: GHI: 
      GHI
      
      BUILD SUCCESSFUL in 17s
      2 actionable tasks: 1 executed, 1 up-to-date
      

      A fix would be very appreciated, thank you.

       

      Attachments

        Issue Links

          Activity

            People

              lkishalmi Laszlo Kishalmi
              temPerAture Operaxis
              Votes:
              1 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 1h 20m
                  1h 20m