-
Notifications
You must be signed in to change notification settings - Fork 827
JAV-282 Auto choose same name transport #110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should close the socket before return to avoid the resource leak.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check if the port is released.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
jdk make sure to call close
}; | ||
|
||
ServletRestTransport transport = new ServletRestTransport(); | ||
Assert.assertFalse(transport.canInit()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may need to check the socket release here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same to above
setListenAddressWithoutSchema(TransportConfig.getAddress()); | ||
|
||
URIEndpointObject ep = (URIEndpointObject) getEndpoint().getAddress(); | ||
if (ep == null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the meaning of null URIEndpointObject?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no listen address in microservice.yaml, that's mean will not register publish endpoint to SC.
}; | ||
|
||
VertxRestTransport transport = new VertxRestTransport(); | ||
Assert.assertTrue(transport.canInit()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Socket resource check here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
released already.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, it sounds good.
buildTransportMap(); | ||
|
||
for (Transport transport : transportMap.values()) { | ||
transportMap.put(transport.getName(), transport); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
多了一条语句
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.