From 292815cf05d52dd80eb24e7de4aa8416181400b8 Mon Sep 17 00:00:00 2001 From: Jacek Centkowski Date: Thu, 11 Jul 2019 11:03:28 +0200 Subject: [PATCH 1/3] Follow up to "Adapt gerrit.sh script to work on Alpine Linux" Issue: Older centos linux distros don't return all pids when simple 'ps' is called and as a result gerrit's PID is not listed and cannot be found by the following 'grep'. It result in the situation when gerrit.sh is not properly handling start/stop commands. Solution: Add 'ax' parameter so that 'ps' returns all pids. It was successfully tested with centos and alpine 3.9.4 e.g.: bash-4.4# echo "$PID" 62 bash-4.4# ps ax -o pid | grep -w $PID 62 Change-Id: I43596f0449f0d357dc640e582381210b61e4ca2d Signed-off-by: Jacek Centkowski --- .../src/main/resources/com/google/gerrit/pgm/init/gerrit.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gerrit-pgm/src/main/resources/com/google/gerrit/pgm/init/gerrit.sh b/gerrit-pgm/src/main/resources/com/google/gerrit/pgm/init/gerrit.sh index 58ea2900c9..104d49a4cf 100755 --- a/gerrit-pgm/src/main/resources/com/google/gerrit/pgm/init/gerrit.sh +++ b/gerrit-pgm/src/main/resources/com/google/gerrit/pgm/init/gerrit.sh @@ -63,7 +63,7 @@ test $# -gt 0 || usage running() { test -f $1 || return 1 PID=`cat $1` - ps -o pid | grep -w $PID >/dev/null 2>/dev/null || return 1 + ps ax -o pid | grep -w $PID >/dev/null 2>/dev/null || return 1 return 0 } From dba9da101c021b4ea0aabfd78c78a89a8e963d66 Mon Sep 17 00:00:00 2001 From: David Pursehouse Date: Thu, 11 Jul 2019 09:58:31 +0900 Subject: [PATCH 2/3] Replace usage of Iterables.limit with Java 8 Stream API Also remove ChangeQueryBuilder's unnecessary construction of an ImmutableSet. The else block returns a regular Set, so there is no need for the other branch to return ImmutableSet. Change-Id: I28b14ee322b7edabea5023f9cb25452d128da9d8 --- .../com/google/gerrit/server/ReviewersUtil.java | 9 +++------ .../com/google/gerrit/server/group/ListGroups.java | 14 +++++++------- .../server/query/change/ChangeQueryBuilder.java | 4 +--- 3 files changed, 11 insertions(+), 16 deletions(-) diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/ReviewersUtil.java b/gerrit-server/src/main/java/com/google/gerrit/server/ReviewersUtil.java index dadef31f3e..1d83316f29 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/ReviewersUtil.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/ReviewersUtil.java @@ -18,8 +18,6 @@ import static java.util.stream.Collectors.toList; import com.google.common.base.Strings; import com.google.common.collect.ImmutableList; -import com.google.common.collect.Iterables; -import com.google.common.collect.Lists; import com.google.gerrit.common.data.GroupReference; import com.google.gerrit.common.errors.NoSuchGroupException; import com.google.gerrit.extensions.common.GroupBaseInfo; @@ -275,10 +273,9 @@ public class ReviewersUtil { private List suggestAccountGroups( SuggestReviewers suggestReviewers, ProjectState projectState) { - return Lists.newArrayList( - Iterables.limit( - groupBackend.suggest(suggestReviewers.getQuery(), projectState), - suggestReviewers.getLimit())); + return groupBackend.suggest(suggestReviewers.getQuery(), projectState).stream() + .limit(suggestReviewers.getLimit()) + .collect(toList()); } private static class GroupAsReviewer { diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/group/ListGroups.java b/gerrit-server/src/main/java/com/google/gerrit/server/group/ListGroups.java index e94289481e..4b7fa6c474 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/group/ListGroups.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/group/ListGroups.java @@ -15,10 +15,10 @@ package com.google.gerrit.server.group; import static com.google.common.collect.ImmutableList.toImmutableList; +import static java.util.stream.Collectors.toList; import com.google.common.base.MoreObjects; import com.google.common.base.Strings; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Streams; import com.google.gerrit.common.data.GroupDescription; @@ -304,12 +304,12 @@ public class ListGroups implements RestReadView { "You should only have no more than one --project and -n with --suggest"); } List groupRefs = - Lists.newArrayList( - Iterables.limit( - groupBackend.suggest( - suggest, - projects.stream().findFirst().map(pc -> pc.getProjectState()).orElse(null)), - limit <= 0 ? 10 : Math.min(limit, 10))); + groupBackend + .suggest( + suggest, projects.stream().findFirst().map(pc -> pc.getProjectState()).orElse(null)) + .stream() + .limit(limit <= 0 ? 10 : Math.min(limit, 10)) + .collect(toList()); List groupInfos = Lists.newArrayListWithCapacity(groupRefs.size()); for (GroupReference ref : groupRefs) { diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/query/change/ChangeQueryBuilder.java b/gerrit-server/src/main/java/com/google/gerrit/server/query/change/ChangeQueryBuilder.java index 5aca6b4238..1edbc38dce 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/query/change/ChangeQueryBuilder.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/query/change/ChangeQueryBuilder.java @@ -21,8 +21,6 @@ import static java.util.stream.Collectors.toSet; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Enums; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.primitives.Ints; import com.google.gerrit.common.data.GroupDescription; @@ -1244,7 +1242,7 @@ public class ChangeQueryBuilder extends QueryBuilder { int maxTerms = args.indexConfig.maxTerms(); if (allMembers.size() > maxTerms) { // limit the number of query terms otherwise Gerrit will barf - accounts = ImmutableSet.copyOf(Iterables.limit(allMembers, maxTerms)); + accounts = allMembers.stream().limit(maxTerms).collect(toSet()); } else { accounts = allMembers; } From 00e3fe6584de634619a1aeb2824c9bafb1f18beb Mon Sep 17 00:00:00 2001 From: Dariusz Luksza Date: Tue, 7 Feb 2017 17:12:27 +0100 Subject: [PATCH 3/3] Expose Gerrit's GWT client library in the plugin API This allows plugins to use and/or extend classes and resources in the com.google.gerrit.client package. Change-Id: I06d0908801d667124820f53b32ef4db9112f271e Signed-off-by: Dariusz Luksza --- gerrit-gwtui/BUILD | 14 ++++++++++++++ gerrit-plugin-gwtui/BUILD | 5 ++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/gerrit-gwtui/BUILD b/gerrit-gwtui/BUILD index bda9aed079..3e68cf91fa 100644 --- a/gerrit-gwtui/BUILD +++ b/gerrit-gwtui/BUILD @@ -6,6 +6,7 @@ load( ) load("//tools/bzl:junit.bzl", "junit_tests") load("//tools/bzl:license.bzl", "license_test") +load("//tools/bzl:java.bzl", "java_library2") gwt_genrule() @@ -20,6 +21,19 @@ gen_ui_module( gwt_user_agent_permutations() +java_library2( + name = "client-lib", + srcs = glob(["src/main/**/*.java"]), + exported_deps = [":ui_module"], + resources = glob(["src/main/**/*"]), + visibility = ["//visibility:public"], + deps = [ + "//gerrit-gwtui-common:client-lib", + "//lib/gwt:dev", + "//lib/gwt:user", + ], +) + license_test( name = "ui_module_license_test", target = ":ui_module", diff --git a/gerrit-plugin-gwtui/BUILD b/gerrit-plugin-gwtui/BUILD index 8cc05b6a64..63a9d55046 100644 --- a/gerrit-plugin-gwtui/BUILD +++ b/gerrit-plugin-gwtui/BUILD @@ -19,7 +19,10 @@ java_binary( java_library2( name = "gwtui-api-lib", srcs = SRCS, - exported_deps = ["//gerrit-gwtui-common:client-lib"], + exported_deps = [ + "//gerrit-gwtui:client-lib", + "//gerrit-gwtui-common:client-lib", + ], resources = glob(["src/main/**/*"]), deps = DEPS + [ "//gerrit-common:libclient-src.jar",