@@ -306,14 +306,7 @@ private Stream<ServiceProvider> stream() {
306306 */
307307 public static final List <ServiceProvider > available () {
308308 ArrayList <ServiceProvider > providers = new Selector (null ).stream ().collect (Collectors .toCollection (ArrayList ::new ));
309- /*
310- * Get the current service provider. If no provider has been set yet, set it now for
311- * consistency with the contract saying that the first item is the current provider.
312- */
313- ServiceProvider first = current .get ();
314- if (first == null && !providers .isEmpty ()) {
315- first = setDefault (providers .get (0 ));
316- }
309+ final ServiceProvider first = current .get ();
317310 /*
318311 * Make sure that 'first' is the first item in the 'providers' list. If that item appears
319312 * somewhere else, we have to remove the second occurrence for avoiding duplicated elements.
@@ -396,27 +389,10 @@ public static final ServiceProvider current() {
396389 } else {
397390 throw new IllegalStateException ("No Measurement ServiceProvider found." );
398391 }
399- p = setDefault (p );
400392 }
401393 return p ;
402394 }
403395
404- /**
405- * Sets the given provider as the current one if and only if no other provider are currently set.
406- * If another provider is already set, that other provider is returned.
407- *
408- * @param provider the provider to set by default if no other provider is currently set.
409- * @return the current provider, which is the specified {@code provider} if no other provider
410- * was set before this method call.
411- */
412- private static ServiceProvider setDefault (ServiceProvider provider ) {
413- while (!current .compareAndSet (null , provider )) {
414- final ServiceProvider c = current .get ();
415- if (c != null ) return c ;
416- }
417- return provider ;
418- }
419-
420396 /**
421397 * Replaces the current {@link ServiceProvider}.
422398 *
0 commit comments