2828import jakarta .ws .rs .HttpMethod ;
2929
3030import java .net .HttpURLConnection ;
31+ import java .net .URI ;
3132import java .net .URL ;
3233import java .util .HashMap ;
3334import java .util .List ;
@@ -208,7 +209,7 @@ private String searchAllBackendForQuery(String queryId)
208209 Future <Integer > call =
209210 executorService .submit (
210211 () -> {
211- URL url = new URL (target );
212+ URL url = URI . create (target ). toURL ( );
212213 HttpURLConnection conn = (HttpURLConnection ) url .openConnection ();
213214 conn .setConnectTimeout ((int ) TimeUnit .SECONDS .toMillis (5 ));
214215 conn .setReadTimeout ((int ) TimeUnit .SECONDS .toMillis (5 ));
@@ -232,7 +233,10 @@ private String searchAllBackendForQuery(String queryId)
232233 log .warn ("Query id [%s] not found" , queryId );
233234 }
234235 // Fallback on first active backend if queryId mapping not found.
235- return gatewayBackendManager .getActiveBackends (defaultRoutingGroup ).get (0 ).getProxyTo ();
236+ return gatewayBackendManager .getActiveBackends (defaultRoutingGroup ).stream ()
237+ .findFirst ()
238+ .map (ProxyBackendConfiguration ::getProxyTo )
239+ .orElseThrow (() -> new IllegalStateException ("No active backends available for default routing group: " + defaultRoutingGroup ));
236240 }
237241
238242 /**
@@ -255,7 +259,7 @@ private String findExternalUrlForUnknownQueryId(String queryId)
255259 return externalUrl ;
256260 }
257261
258- private static LoadingCache <String , String > buildCache (Function <String , String > loader )
262+ private LoadingCache <String , String > buildCache (Function <String , String > loader )
259263 {
260264 return CacheBuilder .newBuilder ()
261265 .maximumSize (10000 )
0 commit comments