Merge changes Idf4f7843,I63967d5f,Ic6410276 into stable-3.4 * changes: Revert "Bazel: tag no_rbe //javatests/com/google/gerrit/git:medium_tests" Revert "Bazel: Add no_rbe tag to test rules that cannot be run on RBE" Bazel: Use custom Ubuntu 18.04 image for RBE
diff --git a/Documentation/config-gerrit.txt b/Documentation/config-gerrit.txt index f0a22cd..7090ff8 100644 --- a/Documentation/config-gerrit.txt +++ b/Documentation/config-gerrit.txt
@@ -2165,7 +2165,7 @@ or "http://example.com:8080/gerrit/" so Gerrit can output links that point back to itself. + -Setting this is highly recommended, as its necessary for the upload +Setting this is highly recommended, as it is necessary for the upload code invoked by "git push" or "repo upload" to output hyperlinks to the newly uploaded changes.
diff --git a/Documentation/dev-plugins.txt b/Documentation/dev-plugins.txt index 67e49eb..3d0d6f9 100644 --- a/Documentation/dev-plugins.txt +++ b/Documentation/dev-plugins.txt
@@ -2645,7 +2645,7 @@ Plugins may also decide not to vote on a given change by returning an `Optional.empty()` (ie: the plugin is not enabled for this repository). -If a plugin decides not to vote, it's name will not be displayed in the UI and +If a plugin decides not to vote, its name will not be displayed in the UI and it will not be recoded in the database. .Gerrit's Pre-submit handling with three plugins
diff --git a/Documentation/note-db.txt b/Documentation/note-db.txt index a13cbfb..7b436a9 100644 --- a/Documentation/note-db.txt +++ b/Documentation/note-db.txt
@@ -192,5 +192,5 @@ In case of rollback from NoteDB to ReviewDB, all the meta refs and the sequence ref need to be removed. -The [remove-notedb-refs.sh,role=external,window=_blank](https://gerrit.googlesource.com/gerrit/+/refs/heads/master/contrib/remove-notedb-refs.sh) +The link:https://gerrit.googlesource.com/gerrit/+/refs/heads/master/contrib/remove-notedb-refs.sh[remove-notedb-refs.sh,role=external,window=_blank] script has been written to automate this process.
diff --git a/WORKSPACE b/WORKSPACE index 7ac98b3..6348be8 100644 --- a/WORKSPACE +++ b/WORKSPACE
@@ -226,36 +226,30 @@ sha1 = "28c59f58f5adcc307604602e2aa89e2aca14c554", ) -SLF4J_VERS = "1.7.26" +SLF4J_VERS = "1.7.33" maven_jar( name = "log-api", artifact = "org.slf4j:slf4j-api:" + SLF4J_VERS, - sha1 = "77100a62c2e6f04b53977b9f541044d7d722693d", + sha1 = "d375aa1b98d34d5ddf73a3f19eaad66e98975b12", ) maven_jar( name = "log-ext", artifact = "org.slf4j:slf4j-ext:" + SLF4J_VERS, - sha1 = "31cdf122e000322e9efcb38913e9ab07825b17ef", + sha1 = "00da03640ae1ad57f964dcaa542fb5d804dce8a6", ) maven_jar( name = "impl-log4j", - artifact = "org.slf4j:slf4j-log4j12:" + SLF4J_VERS, - sha1 = "12f5c685b71c3027fd28bcf90528ec4ec74bf818", + artifact = "org.slf4j:slf4j-reload4j:" + SLF4J_VERS, + sha1 = "ddc89144bfb56781936120b2334a70869b68db6d", ) maven_jar( name = "jcl-over-slf4j", artifact = "org.slf4j:jcl-over-slf4j:" + SLF4J_VERS, - sha1 = "33fbc2d93de829fa5e263c5ce97f5eab8f57d53e", -) - -maven_jar( - name = "log4j", - artifact = "log4j:log4j:1.2.17", - sha1 = "5af35056b4d257e4b64b9e8069c0746e8b08629f", + sha1 = "28c441128bc81b6d95cc2857ae5bb46ae5bf658b", ) maven_jar(
diff --git a/java/com/google/gerrit/common/UsedAt.java b/java/com/google/gerrit/common/UsedAt.java index 73b1d40..3e103c8 100644 --- a/java/com/google/gerrit/common/UsedAt.java +++ b/java/com/google/gerrit/common/UsedAt.java
@@ -42,6 +42,7 @@ PLUGIN_SERVICEUSER, PLUGIN_HIGH_AVAILABILITY, PLUGIN_MULTI_SITE, + PLUGIN_WEBSESSION_FLATFILE, PLUGINS_ALL, // Use this project if a method/type is generally made available to all plugins. }
diff --git a/java/com/google/gerrit/httpd/CacheBasedWebSession.java b/java/com/google/gerrit/httpd/CacheBasedWebSession.java index 7212e3e..f302095 100644 --- a/java/com/google/gerrit/httpd/CacheBasedWebSession.java +++ b/java/com/google/gerrit/httpd/CacheBasedWebSession.java
@@ -19,6 +19,7 @@ import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Strings; import com.google.gerrit.common.Nullable; +import com.google.gerrit.common.UsedAt; import com.google.gerrit.entities.Account; import com.google.gerrit.extensions.restapi.BadRequestException; import com.google.gerrit.httpd.WebSessionManager.Key; @@ -44,7 +45,9 @@ @RequestScoped public abstract class CacheBasedWebSession implements WebSession { @VisibleForTesting public static final String ACCOUNT_COOKIE = "GerritAccount"; - protected static final long MAX_AGE_MINUTES = HOURS.toMinutes(12); + + @UsedAt(UsedAt.Project.PLUGIN_WEBSESSION_FLATFILE) + public static final long MAX_AGE_MINUTES = HOURS.toMinutes(12); private final HttpServletRequest request; private final HttpServletResponse response;
diff --git a/java/com/google/gerrit/httpd/auth/openid/OpenIdServiceImpl.java b/java/com/google/gerrit/httpd/auth/openid/OpenIdServiceImpl.java index b685011..c655b6c 100644 --- a/java/com/google/gerrit/httpd/auth/openid/OpenIdServiceImpl.java +++ b/java/com/google/gerrit/httpd/auth/openid/OpenIdServiceImpl.java
@@ -172,7 +172,7 @@ aReq.addExtension(pape); } } catch (MessageException | ConsumerException e) { - logger.atSevere().withCause(e).log("Cannot create OpenID redirect for %s" + openidIdentifier); + logger.atSevere().withCause(e).log("Cannot create OpenID redirect for %s", openidIdentifier); return new DiscoveryResult(DiscoveryResult.Status.ERROR); }
diff --git a/java/com/google/gerrit/mail/ParserUtil.java b/java/com/google/gerrit/mail/ParserUtil.java index 4b292f3..40c5a95 100644 --- a/java/com/google/gerrit/mail/ParserUtil.java +++ b/java/com/google/gerrit/mail/ParserUtil.java
@@ -115,7 +115,8 @@ int numConsecutiveDigits = 0; int maxConsecutiveDigits = 0; int numDigitGroups = 0; - for (char c : s.toCharArray()) { + for (int i = 0; i < s.length(); i++) { + char c = s.charAt(i); if (c >= '0' && c <= '9') { numConsecutiveDigits++; } else if (numConsecutiveDigits > 0) {
diff --git a/java/com/google/gerrit/server/git/DelegateRepository.java b/java/com/google/gerrit/server/git/DelegateRepository.java index ddfc115..9ead038 100644 --- a/java/com/google/gerrit/server/git/DelegateRepository.java +++ b/java/com/google/gerrit/server/git/DelegateRepository.java
@@ -65,6 +65,10 @@ this.delegate = delegate; } + Repository delegate() { + return delegate; + } + @Override public void create(boolean bare) throws IOException { delegate.create(bare);
diff --git a/java/com/google/gerrit/server/git/GarbageCollection.java b/java/com/google/gerrit/server/git/GarbageCollection.java index 9b52f48..c37572d 100644 --- a/java/com/google/gerrit/server/git/GarbageCollection.java +++ b/java/com/google/gerrit/server/git/GarbageCollection.java
@@ -86,7 +86,12 @@ try (Repository repo = repoManager.openRepository(p)) { logGcConfiguration(p, repo, aggressive); print(writer, "collecting garbage for \"" + p + "\":\n"); - GarbageCollectCommand gc = Git.wrap(repo).gc(); + GarbageCollectCommand gc = + Git.wrap( + repo instanceof DelegateRepository + ? ((DelegateRepository) repo).delegate() + : repo) + .gc(); gc.setAggressive(aggressive); logGcInfo(p, "before:", gc.getStatistics()); gc.setProgressMonitor(
diff --git a/java/com/google/gerrit/server/git/GitRepositoryManagerModule.java b/java/com/google/gerrit/server/git/GitRepositoryManagerModule.java index 354b69f..e4137b0 100644 --- a/java/com/google/gerrit/server/git/GitRepositoryManagerModule.java +++ b/java/com/google/gerrit/server/git/GitRepositoryManagerModule.java
@@ -15,6 +15,7 @@ package com.google.gerrit.server.git; import com.google.gerrit.lifecycle.LifecycleModule; +import com.google.gerrit.server.ModuleImpl; import com.google.gerrit.server.config.RepositoryConfig; import com.google.inject.Inject; @@ -22,7 +23,9 @@ * Module to install {@link MultiBaseLocalDiskRepositoryManager} rather than {@link * LocalDiskRepositoryManager} if needed. */ +@ModuleImpl(name = GitRepositoryManagerModule.MANAGER_MODULE) public class GitRepositoryManagerModule extends LifecycleModule { + public static final String MANAGER_MODULE = "git-manager"; private final RepositoryConfig repoConfig;
diff --git a/java/com/google/gerrit/server/git/MergeUtil.java b/java/com/google/gerrit/server/git/MergeUtil.java index 58df343..16a1ae6 100644 --- a/java/com/google/gerrit/server/git/MergeUtil.java +++ b/java/com/google/gerrit/server/git/MergeUtil.java
@@ -304,13 +304,13 @@ int nameLength = Math.max(oursName.length(), theirsName.length()); String oursNameFormatted = String.format( - "%0$-" + nameLength + "s (%s %s)", + "%-" + nameLength + "s (%s %s)", oursName, abbreviateName(ours, NAME_ABBREV_LEN), oursMsg.substring(0, Math.min(oursMsg.length(), 60))); String theirsNameFormatted = String.format( - "%0$-" + nameLength + "s (%s %s)", + "%-" + nameLength + "s (%s %s)", theirsName, abbreviateName(theirs, NAME_ABBREV_LEN), theirsMsg.substring(0, Math.min(theirsMsg.length(), 60)));
diff --git a/java/com/google/gerrit/server/git/MultiProgressMonitor.java b/java/com/google/gerrit/server/git/MultiProgressMonitor.java index 7e5c99f..15fbe3f 100644 --- a/java/com/google/gerrit/server/git/MultiProgressMonitor.java +++ b/java/com/google/gerrit/server/git/MultiProgressMonitor.java
@@ -161,7 +161,7 @@ volatileTotal.addAndGet(workUnits); } else { logger.atWarning().log( - "Total work has been finalized on sub-task " + getName() + " and cannot be updated"); + "Total work has been finalized on sub-task %s and cannot be updated", getName()); } }
diff --git a/java/com/google/gerrit/server/project/CreateRefControl.java b/java/com/google/gerrit/server/project/CreateRefControl.java index 69ac93e..2e76949 100644 --- a/java/com/google/gerrit/server/project/CreateRefControl.java +++ b/java/com/google/gerrit/server/project/CreateRefControl.java
@@ -105,7 +105,7 @@ // If the tag has a PGP signature, allow a lower level of permission // than if it doesn't have a PGP signature. PermissionBackend.ForRef forRef = permissionBackend.user(user.get()).ref(branch); - if (tag.getFullMessage().contains("-----BEGIN PGP SIGNATURE-----\n")) { + if (tag.getRawGpgSignature() != null) { forRef.check(RefPermission.CREATE_SIGNED_TAG); } else { forRef.check(RefPermission.CREATE_TAG);
diff --git a/javatests/com/google/gerrit/mail/data/NonUTF8Message.java b/javatests/com/google/gerrit/mail/data/NonUTF8Message.java index 60368eb..86a0b56 100644 --- a/javatests/com/google/gerrit/mail/data/NonUTF8Message.java +++ b/javatests/com/google/gerrit/mail/data/NonUTF8Message.java
@@ -45,7 +45,8 @@ public int[] rawChars() { int[] arr = new int[raw.length()]; int i = 0; - for (char c : raw.toCharArray()) { + for (int j = 0; j < raw.length(); j++) { + char c = raw.charAt(j); arr[i++] = c; } return arr;
diff --git a/javatests/com/google/gerrit/server/config/GitwebConfigTest.java b/javatests/com/google/gerrit/server/config/GitwebConfigTest.java index cb6de34..7316074 100644 --- a/javatests/com/google/gerrit/server/config/GitwebConfigTest.java +++ b/javatests/com/google/gerrit/server/config/GitwebConfigTest.java
@@ -24,7 +24,8 @@ @Test public void validPathSeparator() { - for (char c : VALID_CHARACTERS.toCharArray()) { + for (int i = 0; i < VALID_CHARACTERS.length(); i++) { + char c = VALID_CHARACTERS.charAt(i); assertWithMessage("valid character rejected: " + c) .that(GitwebConfig.isValidPathSeparator(c)) .isTrue(); @@ -33,7 +34,8 @@ @Test public void inalidPathSeparator() { - for (char c : SOME_INVALID_CHARACTERS.toCharArray()) { + for (int i = 0; i < SOME_INVALID_CHARACTERS.length(); i++) { + char c = SOME_INVALID_CHARACTERS.charAt(i); assertWithMessage("invalid character accepted: " + c) .that(GitwebConfig.isValidPathSeparator(c)) .isFalse();
diff --git a/javatests/com/google/gerrit/server/git/GarbageCollectionTest.java b/javatests/com/google/gerrit/server/git/GarbageCollectionTest.java new file mode 100644 index 0000000..41b5d79 --- /dev/null +++ b/javatests/com/google/gerrit/server/git/GarbageCollectionTest.java
@@ -0,0 +1,101 @@ +// Copyright (C) 2022 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.google.gerrit.server.git; + +import static com.google.common.truth.Truth.assertThat; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import com.google.common.collect.ImmutableList; +import com.google.gerrit.entities.Project; +import com.google.gerrit.entities.Project.NameKey; +import com.google.gerrit.extensions.registration.DynamicSet; +import com.google.gerrit.server.config.GcConfig; +import com.google.gerrit.server.config.SitePaths; +import com.google.gerrit.server.plugincontext.PluginContext.PluginMetrics; +import com.google.gerrit.server.plugincontext.PluginSetContext; +import java.io.IOException; +import org.eclipse.jgit.errors.RepositoryNotFoundException; +import org.eclipse.jgit.lib.Config; +import org.eclipse.jgit.lib.Repository; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TemporaryFolder; +import org.mockito.Mock; +import org.mockito.junit.MockitoJUnit; +import org.mockito.junit.MockitoRule; + +public class GarbageCollectionTest { + private static final Project.NameKey FOO = Project.nameKey("foo"); + + @Rule public final MockitoRule mockito = MockitoJUnit.rule(); + @Rule public TemporaryFolder temporaryFolder = new TemporaryFolder(); + + @Mock private GcConfig gcConfig; + @Mock private DelegateRepository wrapper; + + private SitePaths site; + private Config cfg; + + @Before + public void setup() throws Exception { + site = new SitePaths(temporaryFolder.newFolder().toPath()); + site.resolve("git").toFile().mkdir(); + cfg = new Config(); + cfg.setString("gerrit", null, "basePath", "git"); + } + + @Test + public void shouldCallGcOnDelegatedRepositoryWhenDelegateRepositoryIsPassed() throws IOException { + // given + GarbageCollection objectUnderTest = prepareObjectForTesting(); + + // when + objectUnderTest.run(ImmutableList.of(FOO), false, null); + + // then + verify(wrapper).delegate(); + } + + private GarbageCollection prepareObjectForTesting() throws IOException { + LocalDiskRepositoryManager repoManager = new DelegatedRepositoryManager(site, cfg, wrapper); + try (Repository repo = repoManager.createRepository(FOO)) { + assertThat(repo).isNotNull(); + } + return new GarbageCollection( + repoManager, + new GarbageCollectionQueue(), + gcConfig, + new PluginSetContext<>(new DynamicSet<>(), PluginMetrics.DISABLED_INSTANCE)); + } + + private static final class DelegatedRepositoryManager extends LocalDiskRepositoryManager { + private final DelegateRepository wrapper; + + private DelegatedRepositoryManager(SitePaths site, Config cfg, DelegateRepository wrapper) { + super(site, cfg); + this.wrapper = wrapper; + } + + @Override + public Repository openRepository(NameKey name) throws RepositoryNotFoundException { + Repository opened = super.openRepository(name); + when(wrapper.delegate()).thenReturn(opened); + when(wrapper.getConfig()).thenReturn(opened.getConfig()); + return wrapper; + } + } +}
diff --git a/lib/nongoogle_test.sh b/lib/nongoogle_test.sh index 272cfa9..bdd40fc 100755 --- a/lib/nongoogle_test.sh +++ b/lib/nongoogle_test.sh
@@ -33,6 +33,7 @@ jimfs jna jruby +log4j mina-core nekohtml objenesis
diff --git a/modules/jgit b/modules/jgit index 60b81c5..1e59cab 160000 --- a/modules/jgit +++ b/modules/jgit
@@ -1 +1 @@ -Subproject commit 60b81c5a9280e44fa48d533a61f915382b2b9ce2 +Subproject commit 1e59cabc08ffddaae7129f0407f7ae17f01c5d90
diff --git a/tools/nongoogle.bzl b/tools/nongoogle.bzl index 3d04592..f482e3d 100644 --- a/tools/nongoogle.bzl +++ b/tools/nongoogle.bzl
@@ -17,6 +17,12 @@ """ maven_jar( + name = "log4j", + artifact = "ch.qos.reload4j:reload4j:1.2.18.1", + sha1 = "7075022a11e18c1ad230de5be074e0c691fed17b", + ) + + maven_jar( name = "j2objc", artifact = "com.google.j2objc:j2objc-annotations:1.1", sha1 = "ed28ded51a8b1c6b112568def5f4b455e6809019",