api: Clarify Server APIs can be used before start()

Fixes #8349
This commit is contained in:
Eric Anderson 2021-08-06 09:10:26 -07:00
parent 3668f2e52c
commit 0e7e0b4f57
1 changed files with 13 additions and 1 deletions

View File

@ -43,7 +43,7 @@ public abstract class Server {
* listening socket(s).
*
* @return {@code this} object
* @throws IllegalStateException if already started
* @throws IllegalStateException if already started or shut down
* @throws IOException if unable to bind
* @since 1.0.0
*/
@ -119,6 +119,9 @@ public abstract class Server {
* {@link #awaitTermination()} or {@link #awaitTermination(long, TimeUnit)} needs to be called to
* wait for existing calls to finish.
*
* <p>Calling this method before {@code start()} will shut down and terminate the server like
* normal, but prevents starting the server in the future.
*
* @return {@code this} object
* @since 1.0.0
*/
@ -130,6 +133,9 @@ public abstract class Server {
* return {@code false} immediately after this method returns. After this call returns, this
* server has released the listening socket(s) and may be reused by another server.
*
* <p>Calling this method before {@code start()} will shut down and terminate the server like
* normal, but prevents starting the server in the future.
*
* @return {@code this} object
* @since 1.0.0
*/
@ -157,6 +163,9 @@ public abstract class Server {
/**
* Waits for the server to become terminated, giving up if the timeout is reached.
*
* <p>Calling this method before {@code start()} or {@code shutdown()} is permitted and does not
* change its behavior.
*
* @return whether the server is terminated, as would be done by {@link #isTerminated()}.
*/
public abstract boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException;
@ -164,6 +173,9 @@ public abstract class Server {
/**
* Waits for the server to become terminated.
*
* <p>Calling this method before {@code start()} or {@code shutdown()} is permitted and does not
* change its behavior.
*
* @since 1.0.0
*/
public abstract void awaitTermination() throws InterruptedException;