When trying to get the port spark is actually listening on with the port being set to 0, it can return 0 if called too quickly.
This seams to be because the server is initializing in a separate thread and therefor not setting the port number to the actual port number before calling port().
See example
public int initWeb() {
port(0);
get("/thing", (req, res) -> ...);
return port(); // returns 0
}
There also seams to be no way to check for the server being fully initialized as far as I can tell, but I could be wrong about that.
When trying to get the port spark is actually listening on with the port being set to 0, it can return 0 if called too quickly. This seams to be because the server is initializing in a separate thread and therefor not setting the port number to the actual port number before calling port(). See example
There also seams to be no way to check for the server being fully initialized as far as I can tell, but I could be wrong about that.