Просмотр исходного кода

BaseReceivePack: Add hasReceivedPack method

The getPackSize method will throw IllegalStateException if it is
called when the pack size is not set. This is the case for example
when the received commands are all DELETE and there is no pack.

Add a new method hasReceivedPack that can be called prior to calling
getPackSize, to avoid causing the IllegalStateException.

See [1] for context.

[1] https://bugs.chromium.org/p/gerrit/issues/detail?id=11918

Change-Id: I56397256a05e92c8398e65c07a859cee59b46317
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
tags/v5.6.0.201911271000-m3
David Pursehouse 4 лет назад
Родитель
Сommit
fd798d326e
1 измененных файлов: 14 добавлений и 0 удалений
  1. 14
    0
      org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java

+ 14
- 0
org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java Просмотреть файл

@@ -1068,6 +1068,20 @@ public abstract class BaseReceivePack {
return msgOutWrapper;
}

/**
* Get whether or not a pack has been received.
*
* This can be called before calling {@link #getPackSize()} to avoid causing
* {@code IllegalStateException} when the pack size was not set because no
* pack was received.
*
* @return true if a pack has been received.
* @since 5.6
*/
public boolean hasReceivedPack() {
return packSize != null;
}

/**
* Get the size of the received pack file including the index size.
*

Загрузка…
Отмена
Сохранить