JAV-282 Auto choose same name transport#110
Conversation
… name have multiple transport instances.
if no listen address, then will not publish endpoint. currently, all customers deployed microservice to web container, rest listen address is not null, so will not cause compatible problem.
|
|
||
| public static boolean canTcpListen(InetAddress address, int port) { | ||
| try (ServerSocket ss = new ServerSocket(port, 0, address)) { | ||
| return true; |
There was a problem hiding this comment.
We should close the socket before return to avoid the resource leak.
There was a problem hiding this comment.
this is try final quick code, will auto invoke close
| ss.close(); | ||
|
|
||
| InetAddress address = InetAddress.getByName("127.0.0.1"); | ||
| Assert.assertTrue(NetUtils.canTcpListen(address, port)); |
There was a problem hiding this comment.
Please check if the port is released.
There was a problem hiding this comment.
jdk make sure to call close
| }; | ||
|
|
||
| ServletRestTransport transport = new ServletRestTransport(); | ||
| Assert.assertFalse(transport.canInit()); |
There was a problem hiding this comment.
We may need to check the socket release here.
| setListenAddressWithoutSchema(TransportConfig.getAddress()); | ||
|
|
||
| URIEndpointObject ep = (URIEndpointObject) getEndpoint().getAddress(); | ||
| if (ep == null) { |
There was a problem hiding this comment.
What's the meaning of null URIEndpointObject?
There was a problem hiding this comment.
no listen address in microservice.yaml, that's mean will not register publish endpoint to SC.
| }; | ||
|
|
||
| VertxRestTransport transport = new VertxRestTransport(); | ||
| Assert.assertTrue(transport.canInit()); |
| buildTransportMap(); | ||
|
|
||
| for (Transport transport : transportMap.values()) { | ||
| transportMap.put(transport.getName(), transport); |
There was a problem hiding this comment.
yes
unused code, and will not cause problem
when i fetch and rebase, delete this line, then i can not push, git said that: rejected ..... (stale info)
i will delete this line in next PR.
allowed depend servlet and vertx rest transport together, sdk will try to choose a better one.