@Test public void getPort_notStarted() throws Exception { InetSocketAddress addr = new InetSocketAddress(0); NettyServer ns = new NettyServer( addr, NioServerSocketChannel.class, new HashMap<ChannelOption<?>, Object>(), null, null, new ProtocolNegotiators.PlaintextNegotiator(), Collections.<ServerStreamTracer.Factory>emptyList(), TransportTracer.getDefaultFactory(), 1, 1, 1, 1, 1, 1, 1, 1, 1, true, 0, channelz); assertThat(ns.getPort()).isEqualTo(-1); }
@Override public int getPort() { if (channel == null) { return -1; } SocketAddress localAddr = channel.localAddress(); if (!(localAddr instanceof InetSocketAddress)) { return -1; } return ((InetSocketAddress) localAddr).getPort(); }
NettyServer implements InternalServer, InternalWithLogId { @Override public int getPort() { if (channel == null) { return -1; } SocketAddress localAddr = channel.localAddress(); if (!(localAddr instanceof InetSocketAddress)) { return -1; } return ((InetSocketAddress) localAddr).getPort(); } }
NettyServer implements InternalServer, InternalWithLogId { @Override public int getPort() { if (channel == null) { return -1; } SocketAddress localAddr = channel.localAddress(); if (!(localAddr instanceof InetSocketAddress)) { return -1; } return ((InetSocketAddress) localAddr).getPort(); } NettyServer(
      SocketAddress address, Class<? extends ServerChannel> channelType,
      Map<ChannelOption<?>, ?> channelOptions,
      @Nullable EventLoopGroup bossGroup, @Nullable EventLoopGroup workerGroup,
      ProtocolNegotiator protocolNegotiator, List<ServerStreamTracer.Factory> streamTracerFactories,
      TransportTracer.Factory transportTracerFactory,
      int maxStreamsPerConnection, int flowControlWindow, int maxMessageSize, int maxHeaderListSize,
      long keepAliveTimeInNanos, long keepAliveTimeoutInNanos,
      long maxConnectionIdleInNanos,
      long maxConnectionAgeInNanos, long maxConnectionAgeGraceInNanos,
      boolean permitKeepAliveWithoutCalls, long permitKeepAliveTimeInNanos,
      InternalChannelz channelz); }
NettyServer implements InternalServer, InternalWithLogId { @Override public int getPort() { if (channel == null) { return -1; } SocketAddress localAddr = channel.localAddress(); if (!(localAddr instanceof InetSocketAddress)) { return -1; } return ((InetSocketAddress) localAddr).getPort(); } NettyServer(
      SocketAddress address, Class<? extends ServerChannel> channelType,
      Map<ChannelOption<?>, ?> channelOptions,
      @Nullable EventLoopGroup bossGroup, @Nullable EventLoopGroup workerGroup,
      ProtocolNegotiator protocolNegotiator, List<ServerStreamTracer.Factory> streamTracerFactories,
      TransportTracer.Factory transportTracerFactory,
      int maxStreamsPerConnection, int flowControlWindow, int maxMessageSize, int maxHeaderListSize,
      long keepAliveTimeInNanos, long keepAliveTimeoutInNanos,
      long maxConnectionIdleInNanos,
      long maxConnectionAgeInNanos, long maxConnectionAgeGraceInNanos,
      boolean permitKeepAliveWithoutCalls, long permitKeepAliveTimeInNanos,
      InternalChannelz channelz); @Override int getPort(); @Override List<InternalInstrumented<SocketStats>> getListenSockets(); @Override void start(ServerListener serverListener); @Override void shutdown(); @Override InternalLogId getLogId(); @Override String toString(); }
NettyServer implements InternalServer, InternalWithLogId { @Override public int getPort() { if (channel == null) { return -1; } SocketAddress localAddr = channel.localAddress(); if (!(localAddr instanceof InetSocketAddress)) { return -1; } return ((InetSocketAddress) localAddr).getPort(); } NettyServer(
      SocketAddress address, Class<? extends ServerChannel> channelType,
      Map<ChannelOption<?>, ?> channelOptions,
      @Nullable EventLoopGroup bossGroup, @Nullable EventLoopGroup workerGroup,
      ProtocolNegotiator protocolNegotiator, List<ServerStreamTracer.Factory> streamTracerFactories,
      TransportTracer.Factory transportTracerFactory,
      int maxStreamsPerConnection, int flowControlWindow, int maxMessageSize, int maxHeaderListSize,
      long keepAliveTimeInNanos, long keepAliveTimeoutInNanos,
      long maxConnectionIdleInNanos,
      long maxConnectionAgeInNanos, long maxConnectionAgeGraceInNanos,
      boolean permitKeepAliveWithoutCalls, long permitKeepAliveTimeInNanos,
      InternalChannelz channelz); @Override int getPort(); @Override List<InternalInstrumented<SocketStats>> getListenSockets(); @Override void start(ServerListener serverListener); @Override void shutdown(); @Override InternalLogId getLogId(); @Override String toString();  }