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

(spec) Console.readPassword() should open up new input stream buffer

    XMLWordPrintable

    Details

    • Type: Enhancement
    • Status: Open
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: 6, 7
    • Fix Version/s: None
    • Component/s: core-libs
    • Labels:
    • Subcomponent:
    • Understanding:
      Cause Known
    • CPU:
      generic, x86
    • OS:
      generic, os_x

      Description

      Console.readPassword() should always look for new input stream buffer.
      Here the Console.readPassword(), reads the input stream 'Java' which is visible in the Input Stream Buffer 'Hello Java', left after reading 'Hello' with reader.read(char[],0,5) method and its not allowing the user to enter the password.
        Console readPassword methods should not read the input stream left in the input stream buffer.It should allow the user to enter the characters in invisible mode.

      see the version,code and Result.
      <version>
      C:\work>java -version
      java version "1.6.0-auto"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.6.0-auto-284)
      Java HotSpot(TM) Client VM (build 1.6.0-ea-b56, mixed mode)
      </version>

      <code>
      import java.io.*;
      class TestConsole5 {
      public static void main(String[] args) {

      Console con =System.console();
      String s1=null;
      char un[]=new char[20];
      char pw[]=new char[20];
      try{
      if (con != null) {
      Reader reader = con.reader();
      con.printf("user name: ");
      reader.read(un,0,5);
      con.flush();
      con.printf("Password : ");
      pw=con.readPassword();
      con.printf("%nuser name : %s %n", new String(un) );
        con.printf("password : %s ", new String(pw));

      }
      }catch(IOException e){
      e.printStackTrace();
      }
      }
      }
      </code>
      <Result>
      C:\work>java TestConsole5
      user name: HelloJava
      Password :

      user name : Hello
      password : Java
      </Result>
      SQE failing testcase: java_io/Console/TestConsole7
      Another SQE test also affected: java_io/Console/TestConsole1

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              sherman Xueming Shen
              Reporter:
              rgutupalsunw Rajendra Gutupalli (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Imported:
                Indexed: