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

Add constructors taking a cause to SocketException

    XMLWordPrintable

    Details

    • Type: CSR
    • Status: Closed
    • Priority: P4
    • Resolution: Approved
    • Fix Version/s: 19
    • Component/s: core-libs
    • Labels:
      None
    • Subcomponent:
    • Compatibility Kind:
      source
    • Compatibility Risk:
      minimal
    • Compatibility Risk Description:
      Add conventional constructors taking a cause to an exception class.
    • Interface Kind:
      Java API
    • Scope:
      SE

      Description

      Summary

      Add conventional constructors that take a cause to SocketException to avoid the need to call initCause as part of creating the exception.

      Problem

      The creation of many SocketExceptions involves setting the cause, but the set of constructors does not include any ones taking a cause.

      Solution

      Add the two missing conventional constructors that take a cause argument.

      Specification

      --- a/src/java.base/share/classes/java/net/SocketException.java
      +++ b/src/java.base/share/classes/java/net/SocketException.java
      @@ -1,5 +1,5 @@
       /*
      - * Copyright (c) 1995, 2019, Oracle and/or its affiliates. All rights reserved.
      + * Copyright (c) 1995, 2022, Oracle and/or its affiliates. All rights reserved.
        * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
        *
        * This code is free software; you can redistribute it and/or modify it
      @@ -52,4 +52,27 @@ public class SocketException extends IOException {
            */
           public SocketException() {
           }
      +
      +    /**
      +     * Constructs a new {@code SocketException} with the
      +     * specified detail message and cause.
      +     *
      +     * @param msg the detail message.
      +     * @param cause the cause
      +     * @since 19
      +     */
      +    public SocketException(String msg, Throwable cause) {
      +        super(msg, cause);
      +    }
      +
      +    /**
      +     * Constructs a new {@code SocketException} with the
      +     * specified cause.
      +     *
      +     * @param cause the cause
      +     * @since 19
      +     */
      +    public SocketException(Throwable cause) {
      +        super(cause);
      +    }
       }

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              darcy Joe Darcy
              Reporter:
              darcy Joe Darcy
              Reviewed By:
              Alan Bateman
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: