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
332bc61124. 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>
This commit is contained in:
Michael Keppler 2018-04-23 22:00:27 +02:00 committed by Matthias Sohn
parent d3ef52133d
commit 32a8162bc3
1 changed files with 11 additions and 7 deletions

View File

@ -194,8 +194,9 @@ public void init(Repository src) {
/**
* @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 void addSymref(String from, String to) {
*/
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 Set<ObjectId> send(Map<String, Ref> refs) throws IOException {
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;