File tree Expand file tree Collapse file tree 3 files changed +6
-15
lines changed
jaxrs-api/src/main/java/jakarta/ws/rs Expand file tree Collapse file tree 3 files changed +6
-15
lines changed Original file line number Diff line number Diff line change 11/*
2- * Copyright (c) 2010, 2019 Oracle and/or its affiliates. All rights reserved.
2+ * Copyright (c) 2010 Oracle and/or its affiliates. All rights reserved.
33 *
44 * This program and the accompanying materials are made available under the
55 * terms of the Eclipse Public License v. 2.0, which is available at
@@ -174,10 +174,7 @@ private static ClassLoader getClassLoader() {
174174 private static <T > T findFirstService (final String factoryId , final ClassLoader cl , final Class <T > service ) {
175175 final PrivilegedAction <T > action = () -> {
176176 try {
177- final ServiceLoader <T > loader = ServiceLoader .load (service , cl );
178- if (loader .iterator ().hasNext ()) {
179- return loader .iterator ().next ();
180- }
177+ return ServiceLoader .load (service , cl ).findFirst ().orElse (null );
181178 } catch (Exception e ) {
182179 LOGGER .log (Level .FINER , "Failed to load service " + factoryId + "." , e );
183180 }
Original file line number Diff line number Diff line change 11/*
2- * Copyright (c) 2010, 2019 Oracle and/or its affiliates. All rights reserved.
2+ * Copyright (c) 2010 Oracle and/or its affiliates. All rights reserved.
33 *
44 * This program and the accompanying materials are made available under the
55 * terms of the Eclipse Public License v. 2.0, which is available at
@@ -174,10 +174,7 @@ private static ClassLoader getClassLoader() {
174174 private static <T > T findFirstService (final String factoryId , final ClassLoader cl , final Class <T > service ) {
175175 final PrivilegedAction <T > action = () -> {
176176 try {
177- final ServiceLoader <T > loader = ServiceLoader .load (service , cl );
178- if (loader .iterator ().hasNext ()) {
179- return loader .iterator ().next ();
180- }
177+ return ServiceLoader .load (service , cl ).findFirst ().orElse (null );
181178 } catch (Exception e ) {
182179 LOGGER .log (Level .FINER , "Failed to load service " + factoryId + "." , e );
183180 }
Original file line number Diff line number Diff line change 11/*
2- * Copyright (c) 2010, 2019 Oracle and/or its affiliates. All rights reserved.
2+ * Copyright (c) 2010 Oracle and/or its affiliates. All rights reserved.
33 *
44 * This program and the accompanying materials are made available under the
55 * terms of the Eclipse Public License v. 2.0, which is available at
@@ -174,10 +174,7 @@ private static ClassLoader getClassLoader() {
174174 private static <T > T findFirstService (final String factoryId , final ClassLoader cl , final Class <T > service ) {
175175 final PrivilegedAction <T > action = () -> {
176176 try {
177- final ServiceLoader <T > loader = ServiceLoader .load (service , cl );
178- if (loader .iterator ().hasNext ()) {
179- return loader .iterator ().next ();
180- }
177+ return ServiceLoader .load (service , cl ).findFirst ().orElse (null );
181178 } catch (Exception e ) {
182179 LOGGER .log (Level .FINER , "Failed to load service " + factoryId + "." , e );
183180 }
You can’t perform that action at this time.
0 commit comments