Merge branch 'stable-3.9' into stable-3.10
* stable-3.9:
Fix NPE upon Git clone
Fix javadocs for deprecation of Changes#id(int)
Release-Notes: skip
Change-Id: Ib33c0d1c4f884cabba86f7d0d9c2929104d1a5da
diff --git a/java/com/google/gerrit/extensions/api/changes/ChangeApi.java b/java/com/google/gerrit/extensions/api/changes/ChangeApi.java
index 1c83bc2..dec3125 100644
--- a/java/com/google/gerrit/extensions/api/changes/ChangeApi.java
+++ b/java/com/google/gerrit/extensions/api/changes/ChangeApi.java
@@ -132,13 +132,21 @@
setReadyForReview(null);
}
- /** Create a new change that reverts this change. */
+ /**
+ * Create a new change that reverts this change.
+ *
+ * @see Changes#id(String, int)
+ */
@CanIgnoreReturnValue
default ChangeApi revert() throws RestApiException {
return revert(new RevertInput());
}
- /** Create a new change that reverts this change. */
+ /**
+ * Create a new change that reverts this change.
+ *
+ * @see Changes#id(String, int)
+ */
@CanIgnoreReturnValue
ChangeApi revert(RevertInput in) throws RestApiException;
diff --git a/java/com/google/gerrit/extensions/api/changes/Changes.java b/java/com/google/gerrit/extensions/api/changes/Changes.java
index 5e3d08c..605a92e 100644
--- a/java/com/google/gerrit/extensions/api/changes/Changes.java
+++ b/java/com/google/gerrit/extensions/api/changes/Changes.java
@@ -32,14 +32,10 @@
/**
* Look up a change by numeric ID.
*
- * <p><strong>Note:</strong> This method eagerly reads the change. Methods that mutate the change
- * do not necessarily re-read the change. Therefore, calling a getter method on an instance after
- * calling a mutation method on that same instance is not guaranteed to reflect the mutation. It
- * is not recommended to store references to {@code ChangeApi} instances. Also note that the
- * change numeric id without a project name parameter may fail to identify a unique change
- * element, because the potential conflict with other changes imported from Gerrit instances with
- * a different Server-Id.
+ * <p><strong>Note:</strong> Change number is not guaranteed to unambiguously identify a change.
*
+ * @see #id(String, int)
+ * @deprecated in favor of {@link #id(String, int)}
* @param id change number.
* @return API for accessing the change.
* @throws RestApiException if an error occurred.
@@ -50,7 +46,7 @@
/**
* Look up a change by string ID.
*
- * @see #id(int)
+ * @see #id(String, int)
* @param id any identifier supported by the REST API, including change number, Change-Id, or
* project~branch~Change-Id triplet.
* @return API for accessing the change.
@@ -61,16 +57,23 @@
/**
* Look up a change by project, branch, and change ID.
*
- * @see #id(int)
+ * @see #id(String, int)
*/
ChangeApi id(String project, String branch, String id) throws RestApiException;
/**
* Look up a change by project and numeric ID.
*
+ * <p><strong>Note:</strong> This method eagerly reads the change. Methods that mutate the change
+ * do not necessarily re-read the change. Therefore, calling a getter method on an instance after
+ * calling a mutation method on that same instance is not guaranteed to reflect the mutation. It
+ * is not recommended to store references to {@code ChangeApi} instances. Also note that the
+ * change numeric id without a project name parameter may fail to identify a unique change
+ * element, because the potential conflict with other changes imported from Gerrit instances with
+ * a different Server-Id.
+ *
* @param project project name.
* @param id change number.
- * @see #id(int)
*/
ChangeApi id(String project, int id) throws RestApiException;
diff --git a/java/com/google/gerrit/server/git/ChangesByProjectCacheImpl.java b/java/com/google/gerrit/server/git/ChangesByProjectCacheImpl.java
index ea7fc1b..2bbd261 100644
--- a/java/com/google/gerrit/server/git/ChangesByProjectCacheImpl.java
+++ b/java/com/google/gerrit/server/git/ChangesByProjectCacheImpl.java
@@ -286,7 +286,7 @@
int size = 0;
size += JavaWeights.OBJECT; // change
size += JavaWeights.REFERENCE + GerritWeights.KEY_INT; // changeId
- size += JavaWeights.REFERENCE + c.getServerId().length();
+ size += JavaWeights.REFERENCE + (c.getServerId() == null ? 0 : c.getServerId().length());
size += JavaWeights.REFERENCE + JavaWeights.OBJECT + 40; // changeKey;
size += JavaWeights.REFERENCE + GerritWeights.TIMESTAMP; // createdOn;
size += JavaWeights.REFERENCE + GerritWeights.TIMESTAMP; // lastUpdatedOn;