protoc-bridge
protoc-bridge copied to clipboard
Fix getting a free socket on macos
Here is a new fix for a free socket on mac problem, without restry. Turns out mac allows a socket on ANY host (. in netstat) to bind even though a socket with localhost and a same port is present in LISTENING state. This is different from linux, where such an attempt would fail with a java.net.BindException.
A way to fix this is by simply passing a localhost (or rather 127.0.0.1, to match MacPluginFrontend) to ServerSocket constructor. I've test it on my project, and got no failures on 5 rebuilds (it used to be 2 failed bazel targets per rebuild on protoc-bridge:0.9.8).
@bell-db fyi