]> source.dussan.org Git - jgit.git/commitdiff
File compile and API errors in JGit 02/121602/3
authorMichael Keppler <Michael.Keppler@gmx.de>
Mon, 23 Apr 2018 20:00:27 +0000 (22:00 +0200)
committerMatthias Sohn <matthias.sohn@sap.com>
Tue, 24 Apr 2018 22:46:01 +0000 (00:46 +0200)
* Photon throws null analysis errors on the repeated invocation of those
previously null checked methods. Extract them to a local variable to
avoid this. (the null analysis is configured in project properties)
* setUseProtocolV2() misses @since tag. Problem was introduced with
332bc611249d21f9b604f2c0207bf0bdfbfc3a78. Might be caused by the long
delay of 2 months from creation to merging.

Change-Id: Ibbb1a1580b604b8e7cd4bf7edc4643e292b6b4a8
Signed-off-by: Michael Keppler <Michael.Keppler@gmx.de>
org.eclipse.jgit/src/org/eclipse/jgit/transport/RefAdvertiser.java

index 0257ebec6378872e4d93d64bb84e340568025e60..60401355a64948a2a345885f1c5a2cb93b219d4c 100644 (file)
@@ -194,8 +194,9 @@ public abstract class RefAdvertiser {
 
        /**
         * @param b
-        *            true if this advertiser should advertise using the
-        *            protocol v2 format, false otherwise
+        *              true if this advertiser should advertise using the protocol
+        *              v2 format, false otherwise
+        * @since 5.0
         */
        public void setUseProtocolV2(boolean b) {
                useProtocolV2 = b;
@@ -289,8 +290,10 @@ public abstract class RefAdvertiser {
         */
        public Set<ObjectId> send(Map<String, Ref> refs) throws IOException {
                for (Ref ref : getSortedRefs(refs)) {
-                       if (ref.getObjectId() == null)
+                       ObjectId objectId = ref.getObjectId();
+                       if (objectId == null) {
                                continue;
+                       }
 
                        if (useProtocolV2) {
                                String symrefPart = symrefs.containsKey(ref.getName())
@@ -301,15 +304,16 @@ public abstract class RefAdvertiser {
                                        if (!ref.isPeeled() && repository != null) {
                                                ref = repository.peel(ref);
                                        }
-                                       if (ref.getPeeledObjectId() != null) {
-                                               peelPart = " peeled:" + ref.getPeeledObjectId().getName();
+                                       ObjectId peeledObjectId = ref.getPeeledObjectId();
+                                       if (peeledObjectId != null) {
+                                               peelPart = " peeled:" + peeledObjectId.getName();
                                        }
                                }
-                               writeOne(ref.getObjectId().getName() + " " + ref.getName() + symrefPart + peelPart + "\n");
+                               writeOne(objectId.getName() + " " + ref.getName() + symrefPart + peelPart + "\n");
                                continue;
                        }
 
-                       advertiseAny(ref.getObjectId(), ref.getName());
+                       advertiseAny(objectId, ref.getName());
 
                        if (!derefTags)
                                continue;