Class PortInUseException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
org.springframework.boot.web.server.WebServerException
org.springframework.boot.web.server.PortInUseException
- All Implemented Interfaces:
- Serializable
A 
PortInUseException is thrown when a web server fails to start due to a port
 already being in use.- Since:
- 2.0.0
- Author:
- Andy Wilkinson, Phillip Webb
- See Also:
- 
Constructor SummaryConstructorsConstructorDescriptionPortInUseException(int port) Creates a new port in use exception for the givenport.PortInUseException(int port, Throwable cause) Creates a new port in use exception for the givenport.
- 
Method SummaryModifier and TypeMethodDescriptionintgetPort()Returns the port that was in use.static <E extends Exception>
 voidifCausedBy(Exception ex, Class<E> causedBy, Consumer<E> action) Perform an action if the given exception was caused by a specific exception type.static voidifPortBindingException(Exception ex, Consumer<BindException> action) Perform an action if the given exception was caused by a "port in use"BindException.static voidthrowIfPortBindingException(Exception ex, IntSupplier port) Throw aPortInUseExceptionif the given exception was caused by a "port in use"BindException.Methods inherited from class java.lang.ThrowableaddSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
- 
Constructor Details- 
PortInUseExceptionpublic PortInUseException(int port) Creates a new port in use exception for the givenport.- Parameters:
- port- the port that was in use
 
- 
PortInUseExceptionCreates a new port in use exception for the givenport.- Parameters:
- port- the port that was in use
- cause- the cause of the exception
 
 
- 
- 
Method Details- 
getPortpublic int getPort()Returns the port that was in use.- Returns:
- the port
 
- 
throwIfPortBindingExceptionThrow aPortInUseExceptionif the given exception was caused by a "port in use"BindException.- Parameters:
- ex- the source exception
- port- a suppler used to provide the port
- Since:
- 2.2.7
 
- 
ifPortBindingExceptionPerform an action if the given exception was caused by a "port in use"BindException.- Parameters:
- ex- the source exception
- action- the action to perform
- Since:
- 2.2.7
 
- 
ifCausedBypublic static <E extends Exception> void ifCausedBy(Exception ex, Class<E> causedBy, Consumer<E> action) Perform an action if the given exception was caused by a specific exception type.- Type Parameters:
- E- the cause exception type
- Parameters:
- ex- the source exception
- causedBy- the required cause type
- action- the action to perform
- Since:
- 2.2.7
 
 
-