core,netty: expose listening on multiple ports#5306
core,netty: expose listening on multiple ports#5306carl-mastrangelo merged 8 commits intogrpc:masterfrom
Conversation
|
|
||
| /** | ||
| * Returns a list of listening sockets for this server. May be different than the originally | ||
| * requested sockets (e.g. listening on port '0' maye end up listening on a different port). |
| /** | ||
| * Returns a list of listening sockets for this server. May be different than the originally | ||
| * requested sockets (e.g. listening on port '0' maye end up listening on a different port). | ||
| * Callers should not modify the returned list or the addresses. |
There was a problem hiding this comment.
Maybe instead say "The returned list is unmodifiable", which also made a requirement for implementations.
| public SocketAddress getListenSocketAddress() { | ||
| if (channel == null) { | ||
| return -1; | ||
| log.fine("server not yet listening on " + address); |
There was a problem hiding this comment.
Is this log permanent? It's unusual for a getter to produce logs.
There was a problem hiding this comment.
Not sure what you mean. In the case there isn't a listening address (really, bound address), the return value won't be accurate. I can remove it if you want.
There was a problem hiding this comment.
I meant logs are usually logged when state changes. It's rare for a pure getter that has no side-effect. The only case where the return value is not accurate is when port is 0, which is pretty distinguishable. I would prefer removing it.
| int port = ts.getPort(); | ||
| if (port != -1) { | ||
| return port; | ||
| SocketAddress addr = ts.getListenSocketAddress(); |
There was a problem hiding this comment.
Please update the documentation on Server.getPort() for the case where the server listens on multiple ports, and add a reference to getListenSockets().
There was a problem hiding this comment.
Added docs on Server.
Fixes #4134