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

Improve the API documentation of HttpRequest.Builder::build to state that the default implementation provided by the JDK returns immutable objects.

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P4 P4
    • 19
    • core-libs
    • None
    • minimal
    • This is a spec clarification with no behavior change
    • Java API
    • SE

      Summary

      Clarify in API Documentation that the default implementation of HttpRequest.Builder::build returns an immutable and reusable HttpRequest Object.

      Problem

      In the API Documentation for HttpRequest.Builder::build, it is not stated or clear what the characteristics of the returned HttpRequest are. It should be stated that the instantiated HttpRequest Object is immutable and can be reused. This is already stated in the class-level API documentation but it will be made more visible by repeating it the documentation of the build method.

      Solution

      An @implSpec Javadoc Tag was added to the method to describe the immutable and reusable traits of the returned HttpRequest instance.

      Specification

      Given here is the diff for the changes described above.

      In interface HttpRequest.Builder:

               /**
                * Builds and returns an {@link HttpRequest}.
                *
      +         * @implSpec This method returns a new {@code HttpRequest} each time it is
      +         * invoked. Once built, the {@code HttpRequest} is immutable and can be
      +         * sent multiple times.
      +         *
                * @return a new {@code HttpRequest}
                * @throws IllegalStateException if a URI has not been set
                */
              public HttpRequest build();

            ccleary Conor Cleary (Inactive)
            dfuchs Daniel Fuchs
            Chris Hegarty, Daniel Fuchs, Jaikiran Pai
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: