JDK-8282724 : Add constructors taking a cause to JSSE exceptions
  • Type: CSR
  • Component: security-libs
  • Sub-Component: javax.net.ssl
  • Priority: P4
  • Status: Closed
  • Resolution: Approved
  • Fix Versions: 19
  • Submitted: 2022-03-07
  • Updated: 2022-03-07
  • Resolved: 2022-03-07
Related Reports
CSR :  
Description
Summary
-------

Add conventional constructors that take a cause to javax.net.ssl exception classes to avoid the need to call initCause as part of creating the exception.

Problem
-------
The creation of many javax.net.ssl exception classes involves setting the cause, but the set of constructors does not include any ones taking a cause.

Solution
--------

Add the the missing conventional constructors that take a cause argument.   This change is to match the API that already exists in SSLException.

Specification
-------------
1. Update on javax.net.ssl.SSLHandshakeException

        +    /**
        +     * Creates a {@code SSLHandshakeException} with the specified detail
        +     * message and cause.
        +     *
        +     * @param message the detail message (which is saved for later retrieval
        +     *        by the {@link #getMessage()} method).
        +     * @param cause the cause (which is saved for later retrieval by the
        +     *        {@link #getCause()} method).  (A {@code null} value is
        +     *        permitted, and indicates that the cause is nonexistent or
        +     *        unknown.)
        +     * @since 19
        +     */
        +    public SSLHandshakeException(String message, Throwable cause) {
        +        super(message, cause);
        +    }

2. Update on SSLKeyException

        +    /**
        +     * Creates a {@code SSLKeyException} with the specified detail
        +     * message and cause.
        +     *
        +     * @param message the detail message (which is saved for later retrieval
        +     *        by the {@link #getMessage()} method).
        +     * @param cause the cause (which is saved for later retrieval by the
        +     *        {@link #getCause()} method).  (A {@code null} value is
        +     *        permitted, and indicates that the cause is nonexistent or
        +     *        unknown.)
        +     * @since 19
        +     */
        +    public SSLKeyException(String message, Throwable cause) {
        +        super(message, cause);
        +    }


3. Update on SSLPeerUnverifiedException

        +    /**
        +     * Creates a {@code SSLPeerUnverifiedException} with the specified detail
        +     * message and cause.
        +     *
        +     * @param message the detail message (which is saved for later retrieval
        +     *        by the {@link #getMessage()} method).
        +     * @param cause the cause (which is saved for later retrieval by the
        +     *        {@link #getCause()} method).  (A {@code null} value is
        +     *        permitted, and indicates that the cause is nonexistent or
        +     *        unknown.)
        +     * @since 19
        +     */
        +    public SSLPeerUnverifiedException(String message, Throwable cause) {
        +        super(message, cause);
        +    }

4. Update on SSLProtocolException

        +    /**
        +     * Creates a {@code SSLProtocolException} with the specified detail
        +     * message and cause.
        +     *
        +     * @param message the detail message (which is saved for later retrieval
        +     *        by the {@link #getMessage()} method).
        +     * @param cause the cause (which is saved for later retrieval by the
        +     *        {@link #getCause()} method).  (A {@code null} value is
        +     *        permitted, and indicates that the cause is nonexistent or
        +     *        unknown.)
        +     * @since 19
        +     */
        +    public SSLProtocolException(String message, Throwable cause) {
        +        super(message, cause);
        +    }

Comments
Moving to Approved.
07-03-2022

> Minor nit. You might include a sentence in the Description that this change is to match the API that already exists in SSLException. Good suggestion. I think it makes the overall picture more clear about the update. I added it to the Solution section.
07-03-2022

Minor nit. You might include a sentence in the Description that this change is to match the API that already exists in SSLException.
07-03-2022