Skip to content

Commit

Permalink
Don't fiddle with ports before passing them to the parser.
Browse files Browse the repository at this point in the history
If the user doesn't specify a port, allow the parser implementation
to figure it out for itself. This allows for things like SRV lookups,
or different default ports per protocol.
  • Loading branch information
csmith committed Aug 8, 2016
1 parent e38204f commit ac24970
Showing 1 changed file with 1 addition and 14 deletions.
15 changes: 1 addition & 14 deletions src/main/java/com/dmdirc/Server.java
Expand Up @@ -60,7 +60,6 @@
import java.net.SocketException;
import java.net.SocketTimeoutException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Collection;
Expand Down Expand Up @@ -214,8 +213,7 @@ public Server(
}

/**
* Updates the connection details for this server. If the specified URI does not define a port,
* the default port from the protocol description will be used.
* Updates the connection details for this server.
*
* @param uri The new URI that this server should connect to
* @param profile The profile that this server should use
Expand All @@ -224,17 +222,6 @@ private void setConnectionDetails(final URI uri, final Profile profile) {
this.address = checkNotNull(uri);
this.protocolDescription = Optional.ofNullable(parserFactory.getDescription(uri));
this.profile = profile;

if (uri.getPort() == -1) {
protocolDescription.ifPresent(pd -> {
try {
this.address = new URI(uri.getScheme(), uri.getUserInfo(), uri.getHost(),
pd.getDefaultPort(), uri.getPath(), uri.getQuery(), uri.getFragment());
} catch (URISyntaxException ex) {
LOG.warn(APP_ERROR, "Unable to construct URI", ex);
}
});
}
}

@Override
Expand Down

0 comments on commit ac24970

Please sign in to comment.