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

The java.lang.Integer.getInteger does not work with null parameter

XMLWordPrintable

    • sparc
    • solaris_2.5



      Name: saf@russia Date: 08/27/96


        
      This bug was found by St.Petersburg Java SQE team (by Alexander Kuzmin).

      The java.lang.Integer.getInteger(String), getInteger(String,int),
      getInteger(String,Integer) methods does not work properly with
      the first parameter according to the Java language specification.

      The Java Language specification
      ( Version 1.0,August 1996)
      says the following (please see item 20.7.21, 20.7.22, 20.7.23):

      getInteger(String) for simple example :
      " public static Integer getInteger(String nm)

      The first argument is treated as the name of a system property to be
      obtained as if by the method System.getProperty (§20.18.9).
      The string value of this property is then interpreted as an integer
      value and an Integer object representing this value is returned.
      If there is no property of the specified name, or if the property
      does not have the correct numeric format, then null is returned.
      In other words, this method returns an Integer object equal to the
      value of:

      getInteger(nm, null)

       "

       The case if nm is null not implemented.
       Function getInteger(String) does not check the situation
       with null parameter. Other functions also.

      ------------------------Examples of getInteger------------------------

       It is need to catch NullPointerException to control this situation.



      // test IntegerGt0014: Try to read null
         Status IntegerGt0014() throws java.io.IOException {
            Integer b1;
             try {
             b1=Integer.getInteger(null);
             } catch( NullPointerException e){
               return Status.failed("IntegerGt0014: getInteger failed"); }
                 if ( (b1==null) ) {
               return Status.passed("IntegerGt0014: OKAY");
            }
            return Status.failed("IntegerGt0014: getInteger failed");


         }
      -----------------------------------------------------------------------
          

            mmcclosksunw Michael Mccloskey (Inactive)
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: