summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaushik Lingarkar <kaushik.lingarkar@linaro.org>2022-05-26 12:01:02 -0700
committerKaushik Lingarkar <kaushik.lingarkar@linaro.org>2022-06-02 09:51:03 -0700
commit4641218e0090ff6433787933f18717f83a87ffe9 (patch)
tree800f71df4adc0d48af585c73a98da00c739a321d
parentb382f4dc9cbc780b854ace8b9b2b40704eb089ed (diff)
Fix SSH queries to not show commit-message unless --commit-message is provided
Obtaining the commit message is a costly operation as the commit data has to be loaded. So, showing it even when --commit-message is not provided degrades the performance of SSH queries. Bug: Issue 15941 Release-Notes: SSH queries are fixed to show commit-message only when --commit-message is provided Change-Id: I45cb478364535f1b9670cf60e3892898c2a46089
-rw-r--r--java/com/google/gerrit/server/events/EventFactory.java30
1 files changed, 19 insertions, 11 deletions
diff --git a/java/com/google/gerrit/server/events/EventFactory.java b/java/com/google/gerrit/server/events/EventFactory.java
index 0c3c4fb583..1382be1691 100644
--- a/java/com/google/gerrit/server/events/EventFactory.java
+++ b/java/com/google/gerrit/server/events/EventFactory.java
@@ -124,12 +124,6 @@ public class EventFactory {
a.id = change.getKey().get();
a.number = change.getId().get();
a.subject = change.getSubject();
- try {
- a.commitMessage = changeDataFactory.create(change).commitMessage();
- } catch (Exception e) {
- logger.atSevere().withCause(e).log(
- "Error while getting full commit message for change %d", a.number);
- }
a.url = getChangeUrl(change);
a.owner = asAccountAttribute(change.getOwner());
a.assignee = asAccountAttribute(change.getAssignee());
@@ -147,11 +141,8 @@ public class EventFactory {
/** Create a {@link ChangeAttribute} instance from the specified change. */
public ChangeAttribute asChangeAttribute(Change change, ChangeNotes notes) {
ChangeAttribute a = asChangeAttribute(change);
- Set<String> hashtags = notes.load().getHashtags();
- if (!hashtags.isEmpty()) {
- a.hashtags = new ArrayList<>(hashtags.size());
- a.hashtags.addAll(hashtags);
- }
+ addHashTags(a, notes);
+ addCommitMessage(a, notes);
return a;
}
/**
@@ -347,6 +338,15 @@ public class EventFactory {
a.commitMessage = commitMessage;
}
+ private void addCommitMessage(ChangeAttribute changeAttribute, ChangeNotes notes) {
+ try {
+ addCommitMessage(changeAttribute, changeDataFactory.create(notes).commitMessage());
+ } catch (Exception e) {
+ logger.atSevere().withCause(e).log(
+ "Error while getting full commit message for change %d", changeAttribute.number);
+ }
+ }
+
public void addPatchSets(
RevWalk revWalk,
ChangeAttribute ca,
@@ -563,4 +563,12 @@ public class EventFactory {
}
return null;
}
+
+ private void addHashTags(ChangeAttribute changeAttribute, ChangeNotes notes) {
+ Set<String> hashtags = notes.load().getHashtags();
+ if (!hashtags.isEmpty()) {
+ changeAttribute.hashtags = new ArrayList<>(hashtags.size());
+ changeAttribute.hashtags.addAll(hashtags);
+ }
+ }
}