diff --git a/independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/impl/StorkClientRequestFilter.java b/independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/impl/StorkClientRequestFilter.java index 43c8c218eb4cb..eeb59d0e0ab5d 100644 --- a/independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/impl/StorkClientRequestFilter.java +++ b/independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/impl/StorkClientRequestFilter.java @@ -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); @@ -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()) {