@Nullable
    public static Port maybeNewPort(@Nullable Integer portNumber, @Nullable InetAddress serverAddress,
                                    boolean enableSsl) {
        if (portNumber == null || portNumber < 0) {
            return null;
        }
        if (portNumber == 0) {
            portNumber = PortUtil.unusedTcpPort();
        }

        final Port port = new Port().setPort(portNumber);
        if (serverAddress != null) {
            port.setAddress(serverAddress);
        }
        return port.setProtocol(enableSsl ? SessionProtocol.HTTPS : SessionProtocol.HTTP);
    }
Returns a newly created {@link Port}.
{@code null} if the specified {@code code} is either {@code null} or a negative number.
Note that if the given {@code portNumber} is zero, an available portNumber randomly selected will be
assigned.
spring/boot3-autoconfigure/src/main/java/com/linecorp/armeria/internal/spring/ArmeriaConfigurationNetUtil.java