@@ -125,26 +125,21 @@ private void getServiceConfigurationsForServicesAndEis(
125125 SubscribableListener .<ElasticInferenceServiceAuthorizationModel >newForked (authModelListener -> {
126126 // Executing on a separate thread because there's a chance the authorization call needs to do some initialization for the Sender
127127 threadPool .executor (UTILITY_THREAD_POOL_NAME ).execute (() -> getEisAuthorization (authModelListener , eisSender ));
128- }).< List < InferenceServiceConfiguration >> andThen (( configurationListener , authorizationModel ) -> {
128+ }).andThenApply (( authorizationModel ) -> {
129129 var serviceConfigs = getServiceConfigurationsForServices (availableServices );
130- serviceConfigs .sort (Comparator .comparing (InferenceServiceConfiguration ::getService ));
131-
132- if (authorizationModel .isAuthorized () == false ) {
133- configurationListener .onResponse (serviceConfigs );
134- return ;
135- }
136130
137- // If there was a requested task type and the authorization response from EIS doesn't support it, we'll exclude EIS as a valid
138- // service
139- if (requestedTaskType != null && authorizationModel .getTaskTypes ().contains (requestedTaskType ) == false ) {
140- configurationListener .onResponse (serviceConfigs );
141- return ;
131+ if (authorizationModel .isAuthorized () == false
132+ // If there was a requested task type and the authorization response from EIS doesn't support it, we'll exclude EIS as a
133+ // valid service
134+ || (requestedTaskType != null && authorizationModel .getTaskTypes ().contains (requestedTaskType ) == false )) {
135+ serviceConfigs .sort (Comparator .comparing (InferenceServiceConfiguration ::getService ));
136+ return serviceConfigs ;
142137 }
143138
144139 var config = ElasticInferenceService .createConfiguration (authorizationModel .getTaskTypes ());
145140 serviceConfigs .add (config );
146141 serviceConfigs .sort (Comparator .comparing (InferenceServiceConfiguration ::getService ));
147- configurationListener . onResponse ( serviceConfigs ) ;
142+ return serviceConfigs ;
148143 })
149144 .addListener (
150145 listener .delegateFailureAndWrap (
0 commit comments