Skip to content
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

Use default host and port when the service instance does not set them #27891

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -34,7 +34,8 @@ public void filter(ResteasyReactiveClientRequestContext requestContext) {
try {
serviceInstance = Stork.getInstance()
.getService(serviceName)
.selectInstanceAndRecordStart(measureTime);
.selectInstanceAndRecordStart(measureTime)
.log();
} catch (Throwable e) {
log.error("Error selecting service instance for serviceName: " + serviceName, e);
requestContext.resume(e);
Expand All @@ -46,8 +47,18 @@ public void filter(ResteasyReactiveClientRequestContext requestContext) {
boolean isHttps = instance.isSecure() || "storks".equals(uri.getScheme());
String scheme = isHttps ? "https" : "http";
try {
// In the case the service instance does not set the host and/or port
String host = instance.getHost() == null ? "localhost" : instance.getHost();
int port = instance.getPort();
if (instance.getPort() == 0) {
if (isHttps) {
port = 433;
} else {
port = 80;
}
}
URI newUri = new URI(scheme,
uri.getUserInfo(), instance.getHost(), instance.getPort(),
uri.getUserInfo(), host, port,
uri.getPath(), uri.getQuery(), uri.getFragment());
requestContext.setUri(newUri);
if (measureTime && instance.gatherStatistics()) {
Expand Down