diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/Transport.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/Transport.java index 4d2f4a9ac..271f462aa 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/Transport.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/Transport.java @@ -191,11 +191,13 @@ public static void register(TransportProtocol proto) { * @param proto * the exact object previously given to register. */ + @SuppressWarnings("ModifyCollectionInEnhancedForLoop") public static void unregister(TransportProtocol proto) { for (WeakReference ref : protocols) { TransportProtocol refProto = ref.get(); - if (refProto == null || refProto == proto) + if (refProto == null || refProto == proto) { protocols.remove(ref); + } } } @@ -204,15 +206,17 @@ public static void unregister(TransportProtocol proto) { * * @return an immutable copy of the currently registered protocols. */ + @SuppressWarnings("ModifyCollectionInEnhancedForLoop") public static List getTransportProtocols() { int cnt = protocols.size(); List res = new ArrayList<>(cnt); for (WeakReference ref : protocols) { TransportProtocol proto = ref.get(); - if (proto != null) + if (proto != null) { res.add(proto); - else + } else { protocols.remove(ref); + } } return Collections.unmodifiableList(res); } @@ -508,6 +512,7 @@ public static Transport open(Repository local, URIish uri) * @throws org.eclipse.jgit.errors.TransportException * the transport cannot open this URI. */ + @SuppressWarnings("ModifyCollectionInEnhancedForLoop") public static Transport open(Repository local, URIish uri, String remoteName) throws NotSupportedException, TransportException { for (WeakReference ref : protocols) { @@ -541,6 +546,7 @@ public static Transport open(Repository local, URIish uri, String remoteName) * @throws org.eclipse.jgit.errors.TransportException * if transport failed */ + @SuppressWarnings("ModifyCollectionInEnhancedForLoop") public static Transport open(URIish uri) throws NotSupportedException, TransportException { for (WeakReference ref : protocols) { TransportProtocol proto = ref.get(); @@ -549,8 +555,9 @@ public static Transport open(URIish uri) throws NotSupportedException, Transport continue; } - if (proto.canHandle(uri, null, null)) + if (proto.canHandle(uri, null, null)) { return proto.open(uri); + } } throw new NotSupportedException(MessageFormat.format(JGitText.get().URINotSupported, uri));