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

java.sql.ClientInfoException: the reason is not initialized properly if cause is not null

XMLWordPrintable

    • b63
    • generic
    • generic

      Constuctor public ClientInfoException(Properties failedProperties, Throwable cause) does not properly initialize the Reason if cause is not null. The spec says:
      ...
      The reason is initialized to null if cause==null or to cause.toString() if cause!=null and the vendor code is initialized to 0.
      ...

      In fact, the getMessage() returns null reason even the cause is not null. See example below:

      import java.sql.ClientInfoException;
      import java.util.Properties;

      /
      public class Test {
          
          /** Creates a new instance of Test */

          
          public static void main(String[] argv) {
              final Throwable cause = new Throwable();
              final ClientInfoException e = new ClientInfoException(new Properties(),
                              cause);
              System.out.println("Returned: " + e.getMessage());
              // The reason is initialized to null if cause==null or to
              //cause.toString() if cause!=null and the vendor code is
              //initialized to 0.
              System.out.println("Expected: " + cause.toString());
          }
      }

      run-single:
      Returned: null
      Expected: java.lang.Throwable

            ahandasunw Amit Handa (Inactive)
            agavrilosunw Alexey Gavrilov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: