From: Michael Keppler Date: Mon, 23 Apr 2018 20:00:27 +0000 (+0200) Subject: File compile and API errors in JGit X-Git-Tag: v5.0.0.201805151920-m7~26 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=refs%2Fchanges%2F02%2F121602%2F3;p=jgit.git File compile and API errors in JGit * 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 --- diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/RefAdvertiser.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/RefAdvertiser.java index 0257ebec63..60401355a6 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/RefAdvertiser.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/RefAdvertiser.java @@ -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 send(Map 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;