This commit is contained in:
Looly
2020-03-13 18:06:26 +08:00
parent aaee713fad
commit cf842ce474
2 changed files with 3 additions and 1 deletions

View File

@@ -28,7 +28,8 @@ public class ServiceLoaderUtil {
*/
public static <T> T loadFirstAvailable(Class<T> clazz) {
final Iterator<T> iterator = load(clazz).iterator();
if(iterator.hasNext()){
//noinspection WhileLoopReplaceableByForEach
while(iterator.hasNext()){
try {
return iterator.next();
} catch (ServiceConfigurationError e) {