From e1ba93ddcbbe15e8ad5053fcd84a843d9cd98d22 Mon Sep 17 00:00:00 2001 From: David Ostrovsky Date: Tue, 17 Oct 2023 07:40:23 +0200 Subject: [PATCH] Bump Bazel version to 7.1.1 In Bazel 7.x release line, the bzlmod feature is activated per default, so that we need to disable it. See this issue for more details: [1]. This requires fixing quite some error prone bug patterns. This change should be separated in single changes to address issues flagged by error prone. Test plan: $> bazel test //... [1] https://github.com/bazelbuild/bazel/issues/18958 Change-Id: I2526d93020c5d82314a09206907ebeed6f1a1700 --- .bazelrc | 4 + .bazelversion | 2 +- MODULE.bazel | 2 + .../keys/OCBPBEProtectionRemoverFactory.java | 3 +- .../test/DefaultReceivePackFactoryTest.java | 2 + .../jgit/http/test/FileResolverTest.java | 4 +- .../jgit/junit/ssh/SshTestGitServer.java | 2 +- .../tst/org/eclipse/jgit/pgm/CloneTest.java | 4 +- .../tst/org/eclipse/jgit/pgm/ConfigTest.java | 4 +- .../org/eclipse/jgit/api/AddCommandTest.java | 15 +-- .../jgit/api/CommitAndLogCommandTest.java | 9 +- .../eclipse/jgit/api/DescribeCommandTest.java | 8 +- .../jgit/api/PathCheckoutCommandTest.java | 8 +- .../eclipse/jgit/api/RebaseCommandTest.java | 3 +- .../jgit/api/StashDropCommandTest.java | 4 +- .../jgit/attributes/CGitAttributesTest.java | 3 +- .../attributes/TreeWalkAttributeTest.java | 2 +- .../merge/MergeGitAttributeTest.java | 1 + .../jgit/dircache/DirCacheBuilderTest.java | 2 +- .../storage/dfs/DfsPackParserTest.java | 4 +- .../storage/file/GcConcurrentTest.java | 5 +- .../storage/file/GcKeepFilesTest.java | 8 +- .../internal/storage/file/LockFileTest.java | 2 +- .../internal/storage/file/RefUpdateTest.java | 6 +- .../storage/pack/GcCommitSelectionTest.java | 4 +- .../tst/org/eclipse/jgit/lib/ConfigTest.java | 9 +- .../eclipse/jgit/lib/ObjectCheckerTest.java | 3 +- .../org/eclipse/jgit/lib/PersonIdentTest.java | 2 +- .../lib/ThreadSafeProgressMonitorTest.java | 2 +- .../org/eclipse/jgit/merge/MergerTest.java | 10 +- .../eclipse/jgit/patch/PatchCcErrorTest.java | 5 +- .../jgit/revwalk/RevCommitParseTest.java | 4 +- .../jgit/revwalk/RevWalkCommitGraphTest.java | 96 +++++++++---------- .../revwalk/RevWalkUtilsReachableTest.java | 1 + .../jgit/transport/PackParserTest.java | 26 ++--- .../transport/PushCertificateIdentTest.java | 5 +- .../ReceivePackAdvertiseRefsHookTest.java | 6 +- .../transport/SideBandOutputStreamTest.java | 5 +- .../eclipse/jgit/transport/SpiTransport.java | 1 + .../jgit/transport/UploadPackTest.java | 40 ++++---- .../org/eclipse/jgit/util/BlockListTest.java | 2 + .../org/eclipse/jgit/util/FileUtilsTest.java | 4 +- .../eclipse/jgit/util/GitDateParserTest.java | 1 + .../tst/org/eclipse/jgit/util/HookTest.java | 2 +- .../RawParseUtils_ParsePersonIdentTest.java | 6 +- .../tst/org/eclipse/jgit/util/RefMapTest.java | 2 + .../jgit/util/http/HttpCookiesMatcher.java | 4 +- 47 files changed, 176 insertions(+), 171 deletions(-) create mode 100644 MODULE.bazel diff --git a/.bazelrc b/.bazelrc index 5e1df6291d7..8324680c961 100644 --- a/.bazelrc +++ b/.bazelrc @@ -1,3 +1,7 @@ +# TODO(davido): Migrate all dependencies from WORKSPACE to MODULE.bazel +# https://issues.gerritcodereview.com/issues/303819949 +common --noenable_bzlmod + build --workspace_status_command="python ./tools/workspace_status.py" build --repository_cache=~/.gerritcodereview/bazel-cache/repository build --experimental_strict_action_env diff --git a/.bazelversion b/.bazelversion index 91e4a9f2622..21c8c7b46b8 100644 --- a/.bazelversion +++ b/.bazelversion @@ -1 +1 @@ -6.3.2 +7.1.1 diff --git a/MODULE.bazel b/MODULE.bazel new file mode 100644 index 00000000000..0b932b8d8c2 --- /dev/null +++ b/MODULE.bazel @@ -0,0 +1,2 @@ +# TODO(davido): Migrate all dependencies from WORKSPACE to MODULE.bazel +# https://issues.gerritcodereview.com/issues/303819949 diff --git a/org.eclipse.jgit.gpg.bc/src/org/eclipse/jgit/gpg/bc/internal/keys/OCBPBEProtectionRemoverFactory.java b/org.eclipse.jgit.gpg.bc/src/org/eclipse/jgit/gpg/bc/internal/keys/OCBPBEProtectionRemoverFactory.java index 3924d685968..46998e6a78e 100644 --- a/org.eclipse.jgit.gpg.bc/src/org/eclipse/jgit/gpg/bc/internal/keys/OCBPBEProtectionRemoverFactory.java +++ b/org.eclipse.jgit.gpg.bc/src/org/eclipse/jgit/gpg/bc/internal/keys/OCBPBEProtectionRemoverFactory.java @@ -63,6 +63,7 @@ class OCBPBEProtectionRemoverFactory } @Override + @SuppressWarnings("InsecureCryptoUsage") public PBESecretKeyDecryptor createDecryptor(String protection) throws PGPException { return new PBESecretKeyDecryptor(passphrase, calculatorProvider) { @@ -122,4 +123,4 @@ public byte[] recoverKeyData(int encAlgorithm, byte[] key, } }; } -} \ No newline at end of file +} diff --git a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/DefaultReceivePackFactoryTest.java b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/DefaultReceivePackFactoryTest.java index a017fa49d2d..dee06cd6c6a 100644 --- a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/DefaultReceivePackFactoryTest.java +++ b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/DefaultReceivePackFactoryTest.java @@ -95,6 +95,7 @@ public void testCreate_EmptyStringUser() throws ServiceNotEnabledException { } @Test + @SuppressWarnings("UndefinedEquals") public void testCreate_AuthUser() throws ServiceNotEnabledException, ServiceNotAuthorizedException { ReceivePack rp; @@ -142,6 +143,7 @@ public void testCreate_Disabled() throws ServiceNotAuthorizedException, } @Test + @SuppressWarnings("UndefinedEquals") public void testCreate_Enabled() throws ServiceNotEnabledException, ServiceNotAuthorizedException, IOException { final StoredConfig cfg = db.getConfig(); diff --git a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/FileResolverTest.java b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/FileResolverTest.java index 8d25c2e3954..34c871ab06f 100644 --- a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/FileResolverTest.java +++ b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/FileResolverTest.java @@ -88,7 +88,7 @@ public void testExportOk() throws IOException { try { resolver.open(null, name).close(); } catch (ServiceNotEnabledException e) { - fail("did not honor export-all flag"); + throw new AssertionError("did not honor export-all flag", e); } FileUtils.createNewFile(export); @@ -99,7 +99,7 @@ public void testExportOk() throws IOException { try { resolver.open(null, name).close(); } catch (ServiceNotEnabledException e) { - fail("did not honor git-daemon-export-ok"); + throw new AssertionError("did not honor git-daemon-export-ok", e); } } diff --git a/org.eclipse.jgit.junit.ssh/src/org/eclipse/jgit/junit/ssh/SshTestGitServer.java b/org.eclipse.jgit.junit.ssh/src/org/eclipse/jgit/junit/ssh/SshTestGitServer.java index 1138be8a96c..f5627e00c8a 100644 --- a/org.eclipse.jgit.junit.ssh/src/org/eclipse/jgit/junit/ssh/SshTestGitServer.java +++ b/org.eclipse.jgit.junit.ssh/src/org/eclipse/jgit/junit/ssh/SshTestGitServer.java @@ -323,7 +323,7 @@ protected List configureSubsystems() { server.setFileSystemFactory(new VirtualFileSystemFactory(repository .getDirectory().getParentFile().getAbsoluteFile().toPath())); return Collections - .singletonList((new SftpSubsystemFactory.Builder()).build()); + .singletonList(new SftpSubsystemFactory.Builder().build()); } /** diff --git a/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/CloneTest.java b/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/CloneTest.java index cbb5bbb9cca..a1fb9fb589b 100644 --- a/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/CloneTest.java +++ b/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/CloneTest.java @@ -183,7 +183,7 @@ public void testCloneBare() throws Exception { File gitDir = db.getDirectory(); String sourcePath = gitDir.getAbsolutePath(); - String targetPath = (new File(sourcePath)).getParentFile() + String targetPath = new File(sourcePath).getParentFile() .getParentFile().getAbsolutePath() + File.separator + "target.git"; String cmd = "git clone --bare " + shellQuote(sourcePath) + " " @@ -207,7 +207,7 @@ public void testCloneMirror() throws Exception { File gitDir = db.getDirectory(); String sourcePath = gitDir.getAbsolutePath(); - String targetPath = (new File(sourcePath)).getParentFile() + String targetPath = new File(sourcePath).getParentFile() .getParentFile().getAbsolutePath() + File.separator + "target.git"; String cmd = "git clone --mirror " + shellQuote(sourcePath) + " " diff --git a/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/ConfigTest.java b/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/ConfigTest.java index 005215f4431..eab882e158c 100644 --- a/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/ConfigTest.java +++ b/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/ConfigTest.java @@ -45,10 +45,10 @@ public void testListConfig() throws Exception { Map options = parseOptions(output); assertEquals(!isWindows, Boolean.valueOf(options.get("core.filemode"))); - assertTrue((Boolean.valueOf(options.get("core.logallrefupdates")))); + assertTrue(Boolean.valueOf(options.get("core.logallrefupdates"))); if (isMac) { assertTrue( - (Boolean.valueOf(options.get("core.precomposeunicode")))); + Boolean.valueOf(options.get("core.precomposeunicode"))); } assertEquals(Integer.valueOf(0), Integer.valueOf(options.get("core.repositoryformatversion"))); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/AddCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/AddCommandTest.java index db2d5d14048..88f28e6f7ac 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/AddCommandTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/AddCommandTest.java @@ -13,6 +13,7 @@ import static java.nio.charset.StandardCharsets.UTF_8; import static org.eclipse.jgit.util.FileUtils.RECURSIVE; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import static org.junit.Assume.assumeTrue; @@ -613,7 +614,7 @@ public void testAddExistingSingleFileTwice() throws IOException, writer.print("other content"); } - dc = git.add().addFilepattern("a.txt").call(); + git.add().addFilepattern("a.txt").call(); assertEquals( "[a.txt, mode:100644, content:other content]", @@ -640,7 +641,7 @@ public void testAddExistingSingleFileTwiceWithCommit() throws Exception { writer.print("other content"); } - dc = git.add().addFilepattern("a.txt").call(); + git.add().addFilepattern("a.txt").call(); assertEquals( "[a.txt, mode:100644, content:other content]", @@ -663,7 +664,7 @@ public void testAddRemovedFile() throws Exception { FileUtils.delete(file); // is supposed to do nothing - dc = git.add().addFilepattern("a.txt").call(); + git.add().addFilepattern("a.txt").call(); assertEquals( "[a.txt, mode:100644, content:content]", @@ -688,7 +689,7 @@ public void testAddRemovedCommittedFile() throws Exception { FileUtils.delete(file); // is supposed to do nothing - dc = git.add().addFilepattern("a.txt").call(); + git.add().addFilepattern("a.txt").call(); assertEquals( "[a.txt, mode:100644, content:content]", @@ -878,7 +879,7 @@ public void testAddAllNoRenormalize() throws Exception { } } // Help null pointer analysis. - assert lastFile != null; + assertNotNull(lastFile); // Wait a bit. If entries are "racily clean", we'll recompute // hashes from the disk files, and then the second add is also slow. // We want to test the normal case. @@ -1259,7 +1260,7 @@ public void testAddGitlink() throws Exception { "[git-link-dir, mode:160000]", indexState(0)); Set untrackedFiles = git.status().call().getUntracked(); - assert (untrackedFiles.isEmpty()); + assertTrue(untrackedFiles.isEmpty()); } } @@ -1274,7 +1275,7 @@ public void testAddSubrepoWithDirNoGitlinks() throws Exception { ConfigConstants.CONFIG_KEY_DIRNOGITLINKS, true); config.save(); - assert (db.getConfig().get(WorkingTreeOptions.KEY).isDirNoGitLinks()); + assertTrue(db.getConfig().get(WorkingTreeOptions.KEY).isDirNoGitLinks()); try (Git git = new Git(db)) { git.add().addFilepattern("nested-repo").call(); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitAndLogCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitAndLogCommandTest.java index b7abba42091..a1e4808f085 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitAndLogCommandTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitAndLogCommandTest.java @@ -284,11 +284,10 @@ public void testInsertChangeId() throws Exception { // template) chars = commit.getFullMessage().getBytes(UTF_8); int lineStart = 0; - int lineEnd = 0; for (int i = 0; i < 4; i++) { lineStart = RawParseUtils.nextLF(chars, lineStart); } - lineEnd = RawParseUtils.nextLF(chars, lineStart); + int lineEnd = RawParseUtils.nextLF(chars, lineStart); String line = RawParseUtils.decode(chars, lineStart, lineEnd); @@ -302,15 +301,9 @@ public void testInsertChangeId() throws Exception { .setInsertChangeId(false).call(); // we should find the untouched template chars = commit.getFullMessage().getBytes(UTF_8); - lineStart = 0; - lineEnd = 0; for (int i = 0; i < 4; i++) { lineStart = RawParseUtils.nextLF(chars, lineStart); } - lineEnd = RawParseUtils.nextLF(chars, lineStart); - - line = RawParseUtils.decode(chars, lineStart, lineEnd); - assertTrue(commit.getFullMessage() .contains("Change-Id: I" + ObjectId.zeroId().getName())); } diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/DescribeCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/DescribeCommandTest.java index ab87fa9662e..c6d5f053e30 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/DescribeCommandTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/DescribeCommandTest.java @@ -284,11 +284,11 @@ public void t1DominatesT2() throws Exception { /** * When t1 annotated dominates t2 lightweight tag * - *
+	 * {@code
 	 * t1 -+-> t2  -
 	 *     |       |
 	 *     +-> c3 -+-> c4
-	 * 
+ * } * * @throws Exception */ @@ -440,11 +440,11 @@ public void testDescribeUseAllRefsMaster() throws Exception { /** * Branch off from master and then tag * - *
+	 * {@code
 	 * c1 -+ -> c2
 	 *     |
 	 *     +-> t1
-	 * 
+ * } * @throws Exception * */ @Test diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PathCheckoutCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PathCheckoutCommandTest.java index f52b715d39f..cf952d2b771 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PathCheckoutCommandTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PathCheckoutCommandTest.java @@ -172,9 +172,9 @@ public void testCheckoutMultiple() throws Exception { @Test public void testUpdateWorkingDirectoryFromIndex() throws Exception { CheckoutCommand co = git.checkout(); - File written = writeTrashFile(FILE1, "3a"); + writeTrashFile(FILE1, "3a"); git.add().addFilepattern(FILE1).call(); - written = writeTrashFile(FILE1, ""); + File written = writeTrashFile(FILE1, ""); assertEquals("", read(written)); co.addPath(FILE1).call(); assertEquals("3a", read(written)); @@ -185,9 +185,9 @@ public void testUpdateWorkingDirectoryFromIndex() throws Exception { public void testUpdateWorkingDirectoryFromHeadWithIndexChange() throws Exception { CheckoutCommand co = git.checkout(); - File written = writeTrashFile(FILE1, "3a"); + writeTrashFile(FILE1, "3a"); git.add().addFilepattern(FILE1).call(); - written = writeTrashFile(FILE1, ""); + File written = writeTrashFile(FILE1, ""); assertEquals("", read(written)); co.addPath(FILE1).setStartPoint("HEAD").call(); assertEquals("3", read(written)); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/RebaseCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/RebaseCommandTest.java index 987c98e2326..86ec47cbbf4 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/RebaseCommandTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/RebaseCommandTest.java @@ -71,6 +71,7 @@ import org.junit.Before; import org.junit.Test; +@SuppressWarnings("AssertionFailureIgnored") public class RebaseCommandTest extends RepositoryTestCase { private static final String GIT_REBASE_TODO = "rebase-merge/git-rebase-todo"; @@ -2650,7 +2651,7 @@ public void testRebaseShouldTryToParseValidLineMarkedAsComment() assertEquals("1111111", firstLine.getCommit().name()); assertEquals("pick", firstLine.getAction().toToken()); } catch (Exception e) { - fail("Valid parsable RebaseTodoLine that has been commented out should allow to change the action, but failed"); + throw new AssertionError("Valid parsable RebaseTodoLine that has been commented out should allow to change the action, but failed", e); } assertEquals("2222222", steps.get(1).getCommit().name()); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/StashDropCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/StashDropCommandTest.java index f9af968a7e8..76b09bb19dd 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/StashDropCommandTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/StashDropCommandTest.java @@ -68,7 +68,7 @@ public void dropWithInvalidLogIndex() throws Exception { assertNull(stashRef); RevCommit stashed = git.stashCreate().call(); assertNotNull(stashed); - stashRef = git.getRepository().exactRef(Constants.R_STASH); + git.getRepository().exactRef(Constants.R_STASH); assertEquals(stashed, git.getRepository().exactRef(Constants.R_STASH).getObjectId()); try { @@ -87,7 +87,7 @@ public void dropSingleStashedCommit() throws Exception { assertNull(stashRef); RevCommit stashed = git.stashCreate().call(); assertNotNull(stashed); - stashRef = git.getRepository().exactRef(Constants.R_STASH); + git.getRepository().exactRef(Constants.R_STASH); assertEquals(stashed, git.getRepository().exactRef(Constants.R_STASH).getObjectId()); assertNull(git.stashDrop().call()); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/attributes/CGitAttributesTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/attributes/CGitAttributesTest.java index 5638c1f7d91..562a515721a 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/attributes/CGitAttributesTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/attributes/CGitAttributesTest.java @@ -104,10 +104,9 @@ private LinkedHashMap cgitAttributes( UTF_8))) { r.lines().forEach(line -> { // Parse the line and add to result map - int start = 0; int i = line.indexOf(':'); String path = line.substring(0, i).trim(); - start = i + 1; + int start = i + 1; i = line.indexOf(':', start); String key = line.substring(start, i).trim(); String value = line.substring(i + 1).trim(); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/attributes/TreeWalkAttributeTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/attributes/TreeWalkAttributeTest.java index 73abd2d37eb..698fdb31a89 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/attributes/TreeWalkAttributeTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/attributes/TreeWalkAttributeTest.java @@ -791,7 +791,7 @@ private static Set asSet(Collection attributes) { for (Attribute a : attributes) { ret.add(a); } - return (ret); + return ret; } private File writeAttributesFile(String name, String... rules) diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/attributes/merge/MergeGitAttributeTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/attributes/merge/MergeGitAttributeTest.java index 6b23de3320a..059ab8a08e1 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/attributes/merge/MergeGitAttributeTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/attributes/merge/MergeGitAttributeTest.java @@ -43,6 +43,7 @@ import org.eclipse.jgit.treewalk.filter.PathFilter; import org.junit.Test; +@SuppressWarnings("CatchAndPrintStackTrace") public class MergeGitAttributeTest extends RepositoryTestCase { private static final String REFS_HEADS_RIGHT = "refs/heads/right"; diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache/DirCacheBuilderTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache/DirCacheBuilderTest.java index 703d68b37c9..61801106afa 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache/DirCacheBuilderTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache/DirCacheBuilderTest.java @@ -218,7 +218,7 @@ final class ReceivedEventMarkerException extends RuntimeException { try { b.commit(); } catch (ReceivedEventMarkerException e) { - fail("unexpected IndexChangedEvent"); + throw new AssertionError("unexpected IndexChangedEvent", e); } } diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/dfs/DfsPackParserTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/dfs/DfsPackParserTest.java index 845d5fcca18..130af277731 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/dfs/DfsPackParserTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/dfs/DfsPackParserTest.java @@ -46,10 +46,10 @@ public void parse_writeObjSizeIdx() throws IOException { .fromString("2e65efe2a145dda7ee51d1741299f848e5bf752e"); pack.header(2); - pack.write((Constants.OBJ_BLOB) << 4 | 1); + pack.write(Constants.OBJ_BLOB << 4 | 1); pack.deflate(new byte[] { 'a' }); - pack.write((Constants.OBJ_REF_DELTA) << 4 | 4); + pack.write(Constants.OBJ_REF_DELTA << 4 | 4); pack.copyRaw(blobA); pack.deflate(new byte[] { 0x1, 0x1, 0x1, 'b' }); pack.digest(); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GcConcurrentTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GcConcurrentTest.java index 96a064989b5..8c1b4f7b651 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GcConcurrentTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GcConcurrentTest.java @@ -10,7 +10,6 @@ package org.eclipse.jgit.internal.storage.file; -import static java.lang.Integer.valueOf; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; @@ -73,7 +72,7 @@ public Integer call() throws Exception { try { gc.setProgressMonitor(this); gc.repack(); - return valueOf(0); + return Integer.valueOf(0); } catch (IOException e) { // leave the syncPoint in broken state so any awaiting // threads and any threads that call await in the future get @@ -84,7 +83,7 @@ public Integer call() throws Exception { } catch (InterruptedException ignored) { // } - return valueOf(1); + return Integer.valueOf(1); } } } diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GcKeepFilesTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GcKeepFilesTest.java index 9a2935f136e..e1b6778c0ed 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GcKeepFilesTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GcKeepFilesTest.java @@ -162,7 +162,7 @@ public void testKeptObjectsAreNotIncludedWhenPackKeptObjectsConfigIsFalse() private void testKeptObjectsAreIncluded() throws Exception { BranchBuilder bb = tr.branch("refs/heads/master"); ObjectId commitObjectInLockedPack = bb.commit().create().toObjectId(); - gc.gc(); + gc.gc().get(); stats = gc.getStatistics(); assertEquals(COMMIT_AND_TREE_OBJECTS, stats.numberOfPackedObjects); assertEquals(1, stats.numberOfPackFiles); @@ -170,7 +170,7 @@ private void testKeptObjectsAreIncluded() throws Exception { .createNewFile()); bb.commit().create(); - gc.gc(); + gc.gc().get(); stats = gc.getStatistics(); assertEquals(2 * COMMIT_AND_TREE_OBJECTS + 1, stats.numberOfPackedObjects); @@ -194,7 +194,7 @@ private void testKeptObjectsAreIncluded() throws Exception { private void testKeptObjectsAreNotIncluded() throws Exception { BranchBuilder bb = tr.branch("refs/heads/master"); ObjectId commitObjectInLockedPack = bb.commit().create().toObjectId(); - gc.gc(); + gc.gc().get(); stats = gc.getStatistics(); assertEquals(COMMIT_AND_TREE_OBJECTS, stats.numberOfPackedObjects); assertEquals(1, stats.numberOfPackFiles); @@ -202,7 +202,7 @@ private void testKeptObjectsAreNotIncluded() throws Exception { .createNewFile()); bb.commit().create(); - gc.gc(); + gc.gc().get(); stats = gc.getStatistics(); assertEquals(COMMIT_AND_TREE_OBJECTS + 1, stats.numberOfPackedObjects); assertEquals(2, stats.numberOfPackFiles); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/LockFileTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/LockFileTest.java index 7eab1dcb09a..49c0ffd2c8c 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/LockFileTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/LockFileTest.java @@ -209,7 +209,7 @@ public void testUnlockNoop() throws Exception { lock.unlock(); lock.unlock(); } catch (Throwable e) { - fail("unlock should be noop if not locked at all."); + throw new AssertionError("unlock should be noop if not locked at all.", e); } } } diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/RefUpdateTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/RefUpdateTest.java index 28d5ca726af..cb977bd6017 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/RefUpdateTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/RefUpdateTest.java @@ -513,7 +513,6 @@ public void testUpdateRefNoChange() throws IOException { @Test public void testRefsCacheAfterUpdate() throws Exception { // Do not use the default repo for this case. - List allRefs = db.getRefDatabase().getRefs(); ObjectId oldValue = db.resolve("HEAD"); ObjectId newValue = db.resolve("HEAD^"); // first make HEAD refer to loose ref @@ -529,7 +528,7 @@ public void testRefsCacheAfterUpdate() throws Exception { update = updateRef.update(); assertEquals(Result.FAST_FORWARD, update); - allRefs = db.getRefDatabase().getRefs(); + List allRefs = db.getRefDatabase().getRefs(); Ref master = getRef(allRefs, "refs/heads/master").get(); Ref head = getRef(allRefs, "HEAD").get(); assertEquals("refs/heads/master", master.getName()); @@ -550,7 +549,6 @@ public void testRefsCacheAfterUpdate() throws Exception { @Test public void testRefsCacheAfterUpdateLooseOnly() throws Exception { // Do not use the default repo for this case. - List allRefs = db.getRefDatabase().getRefs(); ObjectId oldValue = db.resolve("HEAD"); writeSymref(Constants.HEAD, "refs/heads/newref"); RefUpdate updateRef = db.updateRef(Constants.HEAD); @@ -559,7 +557,7 @@ public void testRefsCacheAfterUpdateLooseOnly() throws Exception { Result update = updateRef.update(); assertEquals(Result.NEW, update); - allRefs = db.getRefDatabase().getRefs(); + List allRefs = db.getRefDatabase().getRefs(); Ref head = getRef(allRefs, "HEAD").get(); Ref newref = getRef(allRefs, "refs/heads/newref").get(); assertEquals("refs/heads/newref", newref.getName()); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/pack/GcCommitSelectionTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/pack/GcCommitSelectionTest.java index 0c09ad1510c..ecf9a15b031 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/pack/GcCommitSelectionTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/pack/GcCommitSelectionTest.java @@ -110,7 +110,7 @@ public void testBitmapDoesNotIncludeAnnotatedTags() throws Exception { tr.branch(mainBranch).update(commit1); gc.setExpireAgeMillis(0); - gc.gc(); + gc.gc().get(); // Create only 2 bitmaps, for commit0 and commit1, excluding commit2 assertEquals(2, gc.getStatistics().numberOfBitmaps); @@ -227,7 +227,7 @@ public void testBitmapsForExcludedBranches() throws Exception { PackConfig packConfig = new PackConfig(); packConfig.setBitmapExcludedRefsPrefixes(new String[] { "refs/heads/other" }); gc.setPackConfig(packConfig); - gc.gc(); + gc.gc().get(); assertEquals(1, gc.getStatistics().numberOfBitmaps); } diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ConfigTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ConfigTest.java index 0c0257df900..7c5da425f37 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ConfigTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ConfigTest.java @@ -1568,7 +1568,6 @@ public void testCommitTemplateConfigRelativePath() @Test public void testCommitTemplateEncoding() throws ConfigInvalidException, IOException { - Config config = new Config(null); File workTree = tmp.newFolder("dummy-worktree"); Repository repo = FileRepositoryBuilder .create(new File(workTree, ".git")); @@ -1577,7 +1576,7 @@ public void testCommitTemplateEncoding() String templateContent = "content of the template"; JGitTestUtil.write(tempFile, templateContent); String expectedTemplatePath = tempFile.getPath(); - config = parse("[i18n]\n\tcommitEncoding = utf-8\n" + Config config = parse("[i18n]\n\tcommitEncoding = utf-8\n" + "[commit]\n\ttemplate = " + Config.escapeValue(expectedTemplatePath) + "\n"); assertEquals(templateContent, @@ -1591,7 +1590,6 @@ public void testCommitTemplateEncoding() @Test(expected = ConfigInvalidException.class) public void testCommitTemplateWithInvalidEncoding() throws ConfigInvalidException, IOException { - Config config = new Config(null); File workTree = tmp.newFolder("dummy-worktree"); File tempFile = tmp.newFile("testCommitTemplate-"); Repository repo = FileRepositoryBuilder @@ -1599,7 +1597,7 @@ public void testCommitTemplateWithInvalidEncoding() repo.create(); String templateContent = "content of the template"; JGitTestUtil.write(tempFile, templateContent); - config = parse("[i18n]\n\tcommitEncoding = invalidEcoding\n" + Config config = parse("[i18n]\n\tcommitEncoding = invalidEcoding\n" + "[commit]\n\ttemplate = " + Config.escapeValue(tempFile.getPath()) + "\n"); config.get(CommitConfig.KEY).getCommitTemplateContent(repo); @@ -1608,7 +1606,6 @@ public void testCommitTemplateWithInvalidEncoding() @Test(expected = FileNotFoundException.class) public void testCommitTemplateWithInvalidPath() throws ConfigInvalidException, IOException { - Config config = new Config(null); File workTree = tmp.newFolder("dummy-worktree"); File tempFile = tmp.newFile("testCommitTemplate-"); Repository repo = FileRepositoryBuilder @@ -1618,7 +1615,7 @@ public void testCommitTemplateWithInvalidPath() JGitTestUtil.write(tempFile, templateContent); // commit message encoding String expectedTemplatePath = "~/nonExistingTemplate"; - config = parse("[commit]\n\ttemplate = " + expectedTemplatePath + "\n"); + Config config = parse("[commit]\n\ttemplate = " + expectedTemplatePath + "\n"); String templatePath = config.get(CommitConfig.KEY) .getCommitTemplatePath(); assertEquals(expectedTemplatePath, templatePath); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ObjectCheckerTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ObjectCheckerTest.java index 5c44c9c44d0..3ec4b6a073d 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ObjectCheckerTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ObjectCheckerTest.java @@ -11,7 +11,6 @@ package org.eclipse.jgit.lib; -import static java.lang.Integer.valueOf; import static java.nio.charset.StandardCharsets.UTF_8; import static org.eclipse.jgit.junit.JGitTestUtil.concat; import static org.eclipse.jgit.lib.Constants.OBJECT_ID_LENGTH; @@ -92,7 +91,7 @@ public void setUp() throws Exception { public void testInvalidType() { String msg = MessageFormat.format( JGitText.get().corruptObjectInvalidType2, - valueOf(OBJ_BAD)); + Integer.valueOf(OBJ_BAD)); assertCorrupt(msg, OBJ_BAD, new byte[0]); } diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/PersonIdentTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/PersonIdentTest.java index 97da1757e05..9bcfe868c71 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/PersonIdentTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/PersonIdentTest.java @@ -25,7 +25,7 @@ public class PersonIdentTest { @Test public void test001_NewIdent() { final PersonIdent p = new PersonIdent("A U Thor", "author@example.com", - new Date(1142878501000L), TimeZone.getTimeZone("EST")); + new Date(1142878501000L), TimeZone.getTimeZone("America/New_York")); assertEquals("A U Thor", p.getName()); assertEquals("author@example.com", p.getEmailAddress()); assertEquals(1142878501000L, p.getWhen().getTime()); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ThreadSafeProgressMonitorTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ThreadSafeProgressMonitorTest.java index e21ff580bd5..a5a6ce5d763 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ThreadSafeProgressMonitorTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ThreadSafeProgressMonitorTest.java @@ -125,7 +125,7 @@ private static void await(CountDownLatch cdl) { try { assertTrue("latch released", cdl.await(1000, TimeUnit.MILLISECONDS)); } catch (InterruptedException ie) { - fail("Did not expect to be interrupted"); + throw new AssertionError("Did not expect to be interrupted", ie); } } diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/MergerTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/MergerTest.java index 3f99fe2b260..406ef755a04 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/MergerTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/MergerTest.java @@ -1444,7 +1444,7 @@ public void checkMergeConflictInVirtualAncestor( // Merge merge-both-sides into master git.checkout().setName("master").call(); - mergeResult = git.merge().include(commitX).setStrategy(strategy) + git.merge().include(commitX).setStrategy(strategy) .call(); // Now, merge commit A and B (i.e. "master" and "second-branch"). @@ -1739,25 +1739,25 @@ public void checkModeMergeConflictInVirtualAncestor(MergeStrategy strategy) thro git.add().addFilepattern("c").call(); RevCommit commitI = git.commit().setMessage("Initial commit").call(); - File a = writeTrashFile("a", "content in Ancestor"); + writeTrashFile("a", "content in Ancestor"); git.add().addFilepattern("a").call(); RevCommit commitA1 = git.commit().setMessage("Ancestor 1").call(); - a = writeTrashFile("a", "content in Child 1 (commited on master)"); + writeTrashFile("a", "content in Child 1 (commited on master)"); git.add().addFilepattern("a").call(); // commit C1M git.commit().setMessage("Child 1 on master").call(); git.checkout().setCreateBranch(true).setStartPoint(commitI).setName("branch-to-merge").call(); // "a" becomes executable in A2 - a = writeTrashFile("a", "content in Ancestor"); + File a = writeTrashFile("a", "content in Ancestor"); a.setExecutable(true); git.add().addFilepattern("a").call(); RevCommit commitA2 = git.commit().setMessage("Ancestor 2").call(); // second branch git.checkout().setCreateBranch(true).setStartPoint(commitA1).setName("second-branch").call(); - a = writeTrashFile("a", "content in Child 2 (commited on second-branch)"); + writeTrashFile("a", "content in Child 2 (commited on second-branch)"); git.add().addFilepattern("a").call(); // commit C2S git.commit().setMessage("Child 2 on second-branch").call(); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/patch/PatchCcErrorTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/patch/PatchCcErrorTest.java index 71bda46ee50..8335c07b1f3 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/patch/PatchCcErrorTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/patch/PatchCcErrorTest.java @@ -10,7 +10,6 @@ package org.eclipse.jgit.patch; -import static java.lang.Integer.valueOf; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; @@ -35,7 +34,7 @@ public void testError_CcTruncatedOld() throws IOException { assertSame(FormatError.Severity.ERROR, e.getSeverity()); assertEquals(MessageFormat.format( JGitText.get().truncatedHunkLinesMissingForAncestor, - valueOf(1), valueOf(1)), e.getMessage()); + Integer.valueOf(1), Integer.valueOf(1)), e.getMessage()); assertEquals(346, e.getOffset()); assertTrue(e.getLineText().startsWith( "@@@ -55,12 -163,13 +163,15 @@@ public ")); @@ -45,7 +44,7 @@ public void testError_CcTruncatedOld() throws IOException { assertSame(FormatError.Severity.ERROR, e.getSeverity()); assertEquals(MessageFormat.format( JGitText.get().truncatedHunkLinesMissingForAncestor, - valueOf(2), valueOf(2)), e.getMessage()); + Integer.valueOf(2), Integer.valueOf(2)), e.getMessage()); assertEquals(346, e.getOffset()); assertTrue(e.getLineText().startsWith( "@@@ -55,12 -163,13 +163,15 @@@ public ")); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevCommitParseTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevCommitParseTest.java index 82af34ded2d..6872289a8b0 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevCommitParseTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevCommitParseTest.java @@ -153,9 +153,9 @@ public void testParse_incompleteAuthorAndCommitter() throws Exception { c.parseCanonical(rw, b.toString().getBytes(UTF_8)); } assertEquals( - new PersonIdent("", "a_u_thor@example.com", 1218123387000l, 7), + new PersonIdent("", "a_u_thor@example.com", 1218123387000L, 7), c.getAuthorIdent()); - assertEquals(new PersonIdent("", "", 1218123390000l, -5), + assertEquals(new PersonIdent("", "", 1218123390000L, -5), c.getCommitterIdent()); } diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevWalkCommitGraphTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevWalkCommitGraphTest.java index c2f8f106313..199e50372ef 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevWalkCommitGraphTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevWalkCommitGraphTest.java @@ -44,12 +44,12 @@ public class RevWalkCommitGraphTest extends RevWalkTestCase { - private RevWalk rw; + private RevWalk walk; @Override public void setUp() throws Exception { super.setUp(); - rw = new RevWalk(db); + walk = new RevWalk(db); mockSystemReader.setJGitConfig(new MockConfig()); } @@ -58,7 +58,7 @@ public void testParseHeaders() throws Exception { RevCommit c1 = commitFile("file1", "1", "master"); RevCommit notParseInGraph = rw.lookupCommit(c1); - rw.parseHeaders(notParseInGraph); + walk.parseHeaders(notParseInGraph); assertFalse(notParseInGraph instanceof RevCommitCG); assertNotNull(notParseInGraph.getRawBuffer()); assertEquals(Constants.COMMIT_GENERATION_UNKNOWN, @@ -67,8 +67,8 @@ public void testParseHeaders() throws Exception { enableAndWriteCommitGraph(); reinitializeRevWalk(); - RevCommit parseInGraph = rw.lookupCommit(c1); - parseInGraph.parseHeaders(rw); + RevCommit parseInGraph = walk.lookupCommit(c1); + parseInGraph.parseHeaders(walk); assertTrue(parseInGraph instanceof RevCommitCG); assertNotNull(parseInGraph.getRawBuffer()); @@ -79,9 +79,9 @@ public void testParseHeaders() throws Exception { assertArrayEquals(notParseInGraph.getParents(), parseInGraph.getParents()); reinitializeRevWalk(); - rw.setRetainBody(false); - RevCommit noBody = rw.lookupCommit(c1); - noBody.parseHeaders(rw); + walk.setRetainBody(false); + RevCommit noBody = walk.lookupCommit(c1); + noBody.parseHeaders(walk); assertTrue(noBody instanceof RevCommitCG); assertNull(noBody.getRawBuffer()); @@ -97,12 +97,12 @@ public void testParseCanonical() throws Exception { RevCommit c1 = commitFile("file1", "1", "master"); enableAndWriteCommitGraph(); - RevCommit notParseInGraph = rw.lookupCommit(c1); - rw.parseHeaders(notParseInGraph); + RevCommit notParseInGraph = walk.lookupCommit(c1); + walk.parseHeaders(notParseInGraph); reinitializeRevWalk(); - RevCommit parseInGraph = rw.lookupCommit(c1); - parseInGraph.parseCanonical(rw, rw.getCachedBytes(c1)); + RevCommit parseInGraph = walk.lookupCommit(c1); + parseInGraph.parseCanonical(walk, walk.getCachedBytes(c1)); assertTrue(parseInGraph instanceof RevCommitCG); assertNotNull(parseInGraph.getRawBuffer()); @@ -115,9 +115,9 @@ public void testParseCanonical() throws Exception { parseInGraph.getParents()); reinitializeRevWalk(); - rw.setRetainBody(false); - RevCommit noBody = rw.lookupCommit(c1); - noBody.parseCanonical(rw, rw.getCachedBytes(c1)); + walk.setRetainBody(false); + RevCommit noBody = walk.lookupCommit(c1); + noBody.parseCanonical(walk, walk.getCachedBytes(c1)); assertTrue(noBody instanceof RevCommitCG); assertNull(noBody.getRawBuffer()); @@ -136,8 +136,8 @@ public void testInitializeShallowCommits() throws Exception { assertCommitCntInGraph(2); db.getObjectDatabase().setShallowCommits(Collections.singleton(c1)); - RevCommit parseInGraph = rw.lookupCommit(c1); - parseInGraph.parseHeaders(rw); + RevCommit parseInGraph = walk.lookupCommit(c1); + parseInGraph.parseHeaders(walk); assertTrue(parseInGraph instanceof RevCommitCG); assertNotNull(parseInGraph.getRawBuffer()); @@ -155,20 +155,20 @@ public void testTreeFilter() throws Exception { enableAndWriteCommitGraph(); assertCommitCntInGraph(4); - rw.markStart(rw.lookupCommit(c4)); - rw.setTreeFilter(AndTreeFilter.create(PathFilter.create("file1"), + walk.markStart(walk.lookupCommit(c4)); + walk.setTreeFilter(AndTreeFilter.create(PathFilter.create("file1"), TreeFilter.ANY_DIFF)); - assertEquals(c3, rw.next()); - assertEquals(c1, rw.next()); - assertNull(rw.next()); + assertEquals(c3, walk.next()); + assertEquals(c1, walk.next()); + assertNull(walk.next()); reinitializeRevWalk(); - rw.markStart(rw.lookupCommit(c4)); - rw.setTreeFilter(AndTreeFilter.create(PathFilter.create("file2"), + walk.markStart(walk.lookupCommit(c4)); + walk.setTreeFilter(AndTreeFilter.create(PathFilter.create("file2"), TreeFilter.ANY_DIFF)); - assertEquals(c4, rw.next()); - assertEquals(c2, rw.next()); - assertNull(rw.next()); + assertEquals(c4, walk.next()); + assertEquals(c2, walk.next()); + assertNull(walk.next()); } @Test @@ -180,12 +180,12 @@ public void testChangedPathFilter() throws Exception { enableAndWriteCommitGraph(); - TreeRevFilter trf = new TreeRevFilter(rw, PathFilter.create("file1")); - rw.markStart(rw.lookupCommit(c4)); - rw.setRevFilter(trf); - assertEquals(c3, rw.next()); - assertEquals(c1, rw.next()); - assertNull(rw.next()); + TreeRevFilter trf = new TreeRevFilter(walk, PathFilter.create("file1")); + walk.markStart(walk.lookupCommit(c4)); + walk.setRevFilter(trf); + assertEquals(c3, walk.next()); + assertEquals(c1, walk.next()); + assertNull(walk.next()); // 1 commit that has exactly one parent and matches path assertEquals(1, trf.getChangedPathFilterTruePositive()); @@ -245,14 +245,14 @@ public void testChangedPathFilterWithFollowFilter() throws Exception { db.getConfig().setString(ConfigConstants.CONFIG_DIFF_SECTION, null, ConfigConstants.CONFIG_KEY_RENAMES, "true"); - TreeRevFilter trf = new TreeRevFilter(rw, + TreeRevFilter trf = new TreeRevFilter(walk, new FollowFilter(PathFilter.create("renamed-file"), db.getConfig().get(DiffConfig.KEY))); - rw.markStart(rw.lookupCommit(c4)); - rw.setRevFilter(trf); - assertEquals(c3, rw.next()); - assertEquals(c1, rw.next()); - assertNull(rw.next()); + walk.markStart(walk.lookupCommit(c4)); + walk.setRevFilter(trf); + assertEquals(c3, walk.next()); + assertEquals(c1, walk.next()); + assertNull(walk.next()); // Path "renamed-file" is in c3's bloom filter, and another path "file" // is in c1's bloom filter (we know of "file" because the rev walk @@ -278,10 +278,10 @@ public void testWalkWithCommitMessageFilter() throws Exception { enableAndWriteCommitGraph(); assertCommitCntInGraph(3); - rw.setRevFilter(MessageRevFilter.create("quick brown fox jumps")); - rw.markStart(rw.lookupCommit(c)); - assertEquals(b, rw.next()); - assertNull(rw.next()); + walk.setRevFilter(MessageRevFilter.create("quick brown fox jumps")); + walk.markStart(walk.lookupCommit(c)); + assertEquals(b, walk.next()); + assertNull(walk.next()); } @Test @@ -427,12 +427,12 @@ public void testMergedInto() throws Exception { } boolean isObjectIdInGraph(AnyObjectId id) { - return rw.commitGraph().findGraphPosition(id) >= 0; + return walk.commitGraph().findGraphPosition(id) >= 0; } List allMergedInto(RevCommit needle) throws IOException { List refs = db.getRefDatabase().getRefs(); - return rw.getMergedInto(rw.lookupCommit(needle), refs); + return walk.getMergedInto(walk.lookupCommit(needle), refs); } void assertRefsEquals(List expecteds, List actuals) { @@ -480,7 +480,7 @@ void testRevWalkBehavior(String branch, String compare) throws Exception { } void assertCommitCntInGraph(int expect) { - assertEquals(expect, rw.commitGraph().getCommitCnt()); + assertEquals(expect, walk.commitGraph().getCommitCnt()); } void assertCommits(List expect, List actual) { @@ -544,8 +544,8 @@ void enableAndWriteCommitGraph() throws Exception { } private void reinitializeRevWalk() { - rw.close(); - rw = new RevWalk(db); + walk.close(); + walk = new RevWalk(db); } private static final class MockConfig extends FileBasedConfig { diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevWalkUtilsReachableTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevWalkUtilsReachableTest.java index 0a045c917b5..3d69c812c5e 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevWalkUtilsReachableTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevWalkUtilsReachableTest.java @@ -116,6 +116,7 @@ private Ref branch(String name, RevCommit dst) throws Exception { .setStartPoint(dst.name()).call(); } + @SuppressWarnings("UndefinedEquals") private void assertContains(RevCommit commit, Collection refsThatShouldContainCommit) throws Exception { Collection allRefs = db.getRefDatabase().getRefs(); Collection sortedRefs = RefComparator.sort(allRefs); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PackParserTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PackParserTest.java index 2fd82e7bdba..6148df99f39 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PackParserTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PackParserTest.java @@ -191,7 +191,7 @@ public void testTinyThinPack() throws Exception { InMemoryPack pack = new InMemoryPack(); pack.header(1); - pack.write((Constants.OBJ_REF_DELTA) << 4 | 4); + pack.write(Constants.OBJ_REF_DELTA << 4 | 4); pack.copyRaw(a); pack.deflate(new byte[] { 0x1, 0x1, 0x1, 'b' }); pack.digest(); @@ -211,7 +211,7 @@ public void testPackWithDuplicateBlob() throws Exception { InMemoryPack pack = new InMemoryPack(); pack.header(1); - pack.write((Constants.OBJ_BLOB) << 4 | 0x80 | 1); + pack.write(Constants.OBJ_BLOB << 4 | 0x80 | 1); pack.write(1); pack.deflate(data); pack.digest(); @@ -231,9 +231,9 @@ public void testParseOfsDeltaFullSize() throws Exception { InMemoryPack pack = new InMemoryPack(); pack.header(2); - pack.write((Constants.OBJ_BLOB) << 4 | 10); // offset 12 + pack.write(Constants.OBJ_BLOB << 4 | 10); // offset 12 pack.deflate(data); - pack.write((Constants.OBJ_OFS_DELTA) << 4 | 4); // offset 31 + pack.write(Constants.OBJ_OFS_DELTA << 4 | 4); // offset 31 pack.write(19); pack.deflate(new byte[] { 0xA, 0xB, 0x1, 'b' }); pack.digest(); @@ -270,7 +270,7 @@ public void testPackWithTrailingGarbage() throws Exception { InMemoryPack pack = new InMemoryPack(); pack.header(1); - pack.write((Constants.OBJ_REF_DELTA) << 4 | 4); + pack.write(Constants.OBJ_REF_DELTA << 4 | 4); pack.copyRaw(a); pack.deflate(new byte[] { 0x1, 0x1, 0x1, 'b' }); pack.digest(); @@ -300,7 +300,7 @@ public void testMaxObjectSizeFullBlob() throws Exception { InMemoryPack pack = new InMemoryPack(); pack.header(1); - pack.write((Constants.OBJ_BLOB) << 4 | 10); + pack.write(Constants.OBJ_BLOB << 4 | 10); pack.deflate(data); pack.digest(); @@ -333,7 +333,7 @@ public void testMaxObjectSizeDeltaBlock() throws Exception { InMemoryPack pack = new InMemoryPack(); pack.header(1); - pack.write((Constants.OBJ_REF_DELTA) << 4 | 14); + pack.write(Constants.OBJ_REF_DELTA << 4 | 14); pack.copyRaw(a); pack.deflate(new byte[] { 1, 11, 11, 'a', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' }); @@ -366,7 +366,7 @@ public void testMaxObjectSizeDeltaResultSize() throws Exception { InMemoryPack pack = new InMemoryPack(); pack.header(1); - pack.write((Constants.OBJ_REF_DELTA) << 4 | 4); + pack.write(Constants.OBJ_REF_DELTA << 4 | 4); pack.copyRaw(a); pack.deflate(new byte[] { 10, 11, 1, 'a' }); pack.digest(); @@ -398,7 +398,7 @@ public void testNonMarkingInputStream() throws Exception { InMemoryPack pack = new InMemoryPack(); pack.header(1); - pack.write((Constants.OBJ_REF_DELTA) << 4 | 4); + pack.write(Constants.OBJ_REF_DELTA << 4 | 4); pack.copyRaw(a); pack.deflate(new byte[] { 0x1, 0x1, 0x1, 'b' }); pack.digest(); @@ -439,7 +439,7 @@ public void testDataAfterPackFooterSingleRead() throws Exception { InMemoryPack pack = new InMemoryPack(); pack.header(1); - pack.write((Constants.OBJ_REF_DELTA) << 4 | 4); + pack.write(Constants.OBJ_REF_DELTA << 4 | 4); pack.copyRaw(a); pack.deflate(new byte[] { 0x1, 0x1, 0x1, 'b' }); pack.digest(); @@ -470,7 +470,7 @@ public void testDataAfterPackFooterSplitObjectRead() throws Exception { pack.header(objects); for (int i = 0; i < objects; i++) { - pack.write((Constants.OBJ_BLOB) << 4 | 10); + pack.write(Constants.OBJ_BLOB << 4 | 10); pack.deflate(data); } pack.digest(); @@ -508,7 +508,7 @@ public void testDataAfterPackFooterSplitHeaderRead() throws Exception { for (int i = 0; i < offset; i++) sb.append(i); offset = sb.toString().length(); - int lenByte = (Constants.OBJ_BLOB) << 4 | (offset & 0x0F); + int lenByte = Constants.OBJ_BLOB << 4 | (offset & 0x0F); offset >>= 4; if (offset > 0) lenByte |= 1 << 7; @@ -525,7 +525,7 @@ public void testDataAfterPackFooterSplitHeaderRead() throws Exception { for (int i = 0; i < objects; i++) { // The last pack header written falls across the 8192 byte boundary // between [8189:8210] - pack.write((Constants.OBJ_REF_DELTA) << 4 | 4); + pack.write(Constants.OBJ_REF_DELTA << 4 | 4); pack.copyRaw(b); pack.deflate(new byte[] { 0x1, 0x1, 0x1, 'b' }); } diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PushCertificateIdentTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PushCertificateIdentTest.java index f5658abceb4..a71128119e7 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PushCertificateIdentTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PushCertificateIdentTest.java @@ -73,7 +73,7 @@ public void exoticUserId() throws Exception { @Test public void fuzzyCasesMatchPersonIdent() throws Exception { // See RawParseUtils_ParsePersonIdentTest#testParsePersonIdent_fuzzyCases() - Date when = new Date(1234567890000l); + Date when = new Date(1234567890000L); TimeZone tz = TimeZone.getTimeZone("GMT-7"); assertMatchesPersonIdent( @@ -89,7 +89,7 @@ public void fuzzyCasesMatchPersonIdent() throws Exception { @Test public void incompleteCasesMatchPersonIdent() throws Exception { // See RawParseUtils_ParsePersonIdentTest#testParsePersonIdent_incompleteCases() - Date when = new Date(1234567890000l); + Date when = new Date(1234567890000L); TimeZone tz = TimeZone.getTimeZone("GMT-7"); assertMatchesPersonIdent( @@ -138,6 +138,7 @@ public void incompleteCasesMatchPersonIdent() throws Exception { "Me "); } + @SuppressWarnings("UndefinedEquals") private static void assertMatchesPersonIdent(String raw, PersonIdent expectedPersonIdent, String expectedUserId) { PushCertificateIdent certIdent = PushCertificateIdent.parse(raw); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/ReceivePackAdvertiseRefsHookTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/ReceivePackAdvertiseRefsHookTest.java index a91bc95c8d0..7dac27f6122 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/ReceivePackAdvertiseRefsHookTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/ReceivePackAdvertiseRefsHookTest.java @@ -187,10 +187,10 @@ public void testSuccess() throws Exception { TemporaryBuffer.Heap pack = new TemporaryBuffer.Heap(1024); packHeader(pack, 2); - pack.write((Constants.OBJ_BLOB) << 4 | 1); + pack.write(Constants.OBJ_BLOB << 4 | 1); deflate(pack, new byte[] { 'a' }); - pack.write((Constants.OBJ_REF_DELTA) << 4 | 4); + pack.write(Constants.OBJ_REF_DELTA << 4 | 4); a.copyRawTo(pack); deflate(pack, new byte[] { 0x1, 0x1, 0x1, 'b' }); @@ -296,7 +296,7 @@ public void testUsingHiddenDeltaBaseFails() throws Exception { packHeader(pack, 3); copy(pack, src.open(N)); copy(pack, src.open(s.parseBody(N).getTree())); - pack.write((Constants.OBJ_REF_DELTA) << 4 | 4); + pack.write(Constants.OBJ_REF_DELTA << 4 | 4); b.copyRawTo(pack); deflate(pack, delta); digest(pack); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/SideBandOutputStreamTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/SideBandOutputStreamTest.java index 3516ed01fc2..53645a1413b 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/SideBandOutputStreamTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/SideBandOutputStreamTest.java @@ -10,7 +10,6 @@ package org.eclipse.jgit.transport; -import static java.lang.Integer.valueOf; import static java.nio.charset.StandardCharsets.UTF_8; import static org.eclipse.jgit.transport.SideBandOutputStream.CH_DATA; import static org.eclipse.jgit.transport.SideBandOutputStream.CH_ERROR; @@ -224,7 +223,9 @@ public void testConstructor_RejectsBadBufferSize() throws Exception { } catch (IllegalArgumentException e) { assertEquals(MessageFormat.format( JGitText.get().packetSizeMustBeAtMost, - valueOf(Integer.MAX_VALUE), valueOf(65520)), e.getMessage()); + Integer.valueOf(Integer.MAX_VALUE), + Integer.valueOf(65520)), + e.getMessage()); } } diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/SpiTransport.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/SpiTransport.java index b951f523fce..4f3f0bf98eb 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/SpiTransport.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/SpiTransport.java @@ -48,6 +48,7 @@ public Transport open(URIish uri, Repository local, String remoteName) } }; + @SuppressWarnings("unused") private SpiTransport(Repository local, URIish uri) { super(local, uri); } diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackTest.java index 026492f7b69..ccf3577f6b7 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackTest.java @@ -1800,14 +1800,14 @@ class DeepTreePreparator { RevBlob blobHighDepth = remote.blob("hi"); RevTree subtree = remote.tree(remote.file("1", blobHighDepth)); - RevTree rootTree = (new TreeBuilder() { + RevTree rootTree = new TreeBuilder() { @Override void addElements(DirCacheBuilder dcBuilder) throws Exception { dcBuilder.add(remote.file("1", blobLowDepth)); dcBuilder.addTree(new byte[] {'2'}, DirCacheEntry.STAGE_0, remote.getRevWalk().getObjectReader(), subtree); } - }).build(); + }.build(); RevCommit commit = remote.commit(rootTree); DeepTreePreparator() throws Exception {} @@ -1904,21 +1904,21 @@ public void testV2FetchFilterTreeDepth2() throws Exception { class RepeatedSubtreePreparator { RevBlob foo = remote.blob("foo"); RevTree subtree3 = remote.tree(remote.file("foo", foo)); - RevTree subtree2 = (new TreeBuilder() { + RevTree subtree2 = new TreeBuilder() { @Override void addElements(DirCacheBuilder dcBuilder) throws Exception { dcBuilder.addTree(new byte[] {'b'}, DirCacheEntry.STAGE_0, remote.getRevWalk().getObjectReader(), subtree3); } - }).build(); - RevTree subtree1 = (new TreeBuilder() { + }.build(); + RevTree subtree1 = new TreeBuilder() { @Override void addElements(DirCacheBuilder dcBuilder) throws Exception { dcBuilder.addTree(new byte[] {'x'}, DirCacheEntry.STAGE_0, remote.getRevWalk().getObjectReader(), subtree2); } - }).build(); - RevTree rootTree = (new TreeBuilder() { + }.build(); + RevTree rootTree = new TreeBuilder() { @Override void addElements(DirCacheBuilder dcBuilder) throws Exception { dcBuilder.addTree(new byte[] {'a'}, DirCacheEntry.STAGE_0, @@ -1926,7 +1926,7 @@ void addElements(DirCacheBuilder dcBuilder) throws Exception { dcBuilder.addTree(new byte[] {'x'}, DirCacheEntry.STAGE_0, remote.getRevWalk().getObjectReader(), subtree2); } - }).build(); + }.build(); RevCommit commit = remote.commit(rootTree); RepeatedSubtreePreparator() throws Exception {} @@ -1970,22 +1970,22 @@ class RepeatedSubtreeAtSameLevelPreparator { RevTree subtree1 = remote.tree(remote.file("foo", foo)); /** b/foo */ - RevTree subtree2 = (new TreeBuilder() { + RevTree subtree2 = new TreeBuilder() { @Override void addElements(DirCacheBuilder dcBuilder) throws Exception { dcBuilder.addTree(new byte[] {'b'}, DirCacheEntry.STAGE_0, remote.getRevWalk().getObjectReader(), subtree1); } - }).build(); + }.build(); /** x/b/foo */ - RevTree subtree3 = (new TreeBuilder() { + RevTree subtree3 = new TreeBuilder() { @Override void addElements(DirCacheBuilder dcBuilder) throws Exception { dcBuilder.addTree(new byte[] {'x'}, DirCacheEntry.STAGE_0, remote.getRevWalk().getObjectReader(), subtree2); } - }).build(); + }.build(); RevBlob baz = remote.blob("baz"); @@ -1993,33 +1993,33 @@ void addElements(DirCacheBuilder dcBuilder) throws Exception { RevTree subtree4 = remote.tree(remote.file("baz", baz)); /** c/baz */ - RevTree subtree5 = (new TreeBuilder() { + RevTree subtree5 = new TreeBuilder() { @Override void addElements(DirCacheBuilder dcBuilder) throws Exception { dcBuilder.addTree(new byte[] {'c'}, DirCacheEntry.STAGE_0, remote.getRevWalk().getObjectReader(), subtree4); } - }).build(); + }.build(); /** u/c/baz */ - RevTree subtree6 = (new TreeBuilder() { + RevTree subtree6 = new TreeBuilder() { @Override void addElements(DirCacheBuilder dcBuilder) throws Exception { dcBuilder.addTree(new byte[] {'u'}, DirCacheEntry.STAGE_0, remote.getRevWalk().getObjectReader(), subtree5); } - }).build(); + }.build(); /** v/c/baz */ - RevTree subtree7 = (new TreeBuilder() { + RevTree subtree7 = new TreeBuilder() { @Override void addElements(DirCacheBuilder dcBuilder) throws Exception { dcBuilder.addTree(new byte[] {'v'}, DirCacheEntry.STAGE_0, remote.getRevWalk().getObjectReader(), subtree5); } - }).build(); + }.build(); - RevTree rootTree = (new TreeBuilder() { + RevTree rootTree = new TreeBuilder() { @Override void addElements(DirCacheBuilder dcBuilder) throws Exception { dcBuilder.addTree(new byte[] {'a'}, DirCacheEntry.STAGE_0, @@ -2031,7 +2031,7 @@ void addElements(DirCacheBuilder dcBuilder) throws Exception { dcBuilder.addTree(new byte[] {'z'}, DirCacheEntry.STAGE_0, remote.getRevWalk().getObjectReader(), subtree7); } - }).build(); + }.build(); RevCommit commit = remote.commit(rootTree); RepeatedSubtreeAtSameLevelPreparator() throws Exception {} diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/BlockListTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/BlockListTest.java index a270ca88612..2f41827376e 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/BlockListTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/BlockListTest.java @@ -293,6 +293,7 @@ public void testFastIterator() { } @Test + @SuppressWarnings("ModifiedButNotUsed") public void testAddRejectsBadIndexes() { BlockList list = new BlockList<>(4); list.add(Integer.valueOf(41)); @@ -313,6 +314,7 @@ public void testAddRejectsBadIndexes() { } @Test + @SuppressWarnings("ModifiedButNotUsed") public void testRemoveRejectsBadIndexes() { BlockList list = new BlockList<>(4); list.add(Integer.valueOf(41)); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/FileUtilsTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/FileUtilsTest.java index 2b1fb2ef04b..7075a7015b8 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/FileUtilsTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/FileUtilsTest.java @@ -74,7 +74,7 @@ public void testDeleteFile() throws IOException { try { FileUtils.delete(f, FileUtils.SKIP_MISSING); } catch (IOException e) { - fail("deletion of non-existing file must not fail with option SKIP_MISSING"); + throw new AssertionError("deletion of non-existing file must not fail with option SKIP_MISSING", e); } } @@ -108,7 +108,7 @@ public void testDeleteRecursive() throws IOException { try { FileUtils.delete(d, FileUtils.RECURSIVE | FileUtils.SKIP_MISSING); } catch (IOException e) { - fail("recursive deletion of non-existing directory must not fail with option SKIP_MISSING"); + throw new AssertionError("recursive deletion of non-existing directory must not fail with option SKIP_MISSING", e); } } diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/GitDateParserTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/GitDateParserTest.java index 2f49dba5685..4f844381766 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/GitDateParserTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/GitDateParserTest.java @@ -22,6 +22,7 @@ import org.junit.Before; import org.junit.Test; +@SuppressWarnings("UndefinedEquals") public class GitDateParserTest { @Before public void setUp() { diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/HookTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/HookTest.java index 1231aefee04..b7490f0b1f0 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/HookTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/HookTest.java @@ -157,7 +157,7 @@ public void testAllCommitHooks() throws Exception { git.commit().setMessage("commit") .setHookOutputStream(new PrintStream(out)).call(); } catch (AbortedByHookException e) { - fail("unexpected hook failure"); + throw new AssertionError("unexpected hook failure", e); } assertEquals("unexpected hook output", "test pre-commit\ntest commit-msg .git/COMMIT_EDITMSG\ntest post-commit\n", diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/RawParseUtils_ParsePersonIdentTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/RawParseUtils_ParsePersonIdentTest.java index ee3ce8d98cc..355bbbab16a 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/RawParseUtils_ParsePersonIdentTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/RawParseUtils_ParsePersonIdentTest.java @@ -22,7 +22,7 @@ public class RawParseUtils_ParsePersonIdentTest { @Test public void testParsePersonIdent_legalCases() { - final Date when = new Date(1234567890000l); + final Date when = new Date(1234567890000L); final TimeZone tz = TimeZone.getTimeZone("GMT-7"); assertPersonIdent("Me 1234567890 -0700", @@ -50,7 +50,7 @@ public void testParsePersonIdent_legalCases() { @Test public void testParsePersonIdent_fuzzyCases() { - final Date when = new Date(1234567890000l); + final Date when = new Date(1234567890000L); final TimeZone tz = TimeZone.getTimeZone("GMT-7"); assertPersonIdent( @@ -64,7 +64,7 @@ public void testParsePersonIdent_fuzzyCases() { @Test public void testParsePersonIdent_incompleteCases() { - final Date when = new Date(1234567890000l); + final Date when = new Date(1234567890000L); final TimeZone tz = TimeZone.getTimeZone("GMT-7"); assertPersonIdent("Me <> 1234567890 -0700", new PersonIdent("Me", "", diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/RefMapTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/RefMapTest.java index 627417d4627..61f7915892b 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/RefMapTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/RefMapTest.java @@ -269,6 +269,7 @@ public void testMerge_WithPrefix() { } @Test + @SuppressWarnings("ModifiedButNotUsed") public void testPut_KeyMustMatchName_NoPrefix() { final Ref refA = newRef("refs/heads/A", ID_ONE); RefMap map = new RefMap("", packed, loose, resolved); @@ -281,6 +282,7 @@ public void testPut_KeyMustMatchName_NoPrefix() { } @Test + @SuppressWarnings("ModifiedButNotUsed") public void testPut_KeyMustMatchName_WithPrefix() { final Ref refA = newRef("refs/heads/A", ID_ONE); RefMap map = new RefMap("refs/heads/", packed, loose, resolved); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/http/HttpCookiesMatcher.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/http/HttpCookiesMatcher.java index 5a2bd976c75..c0b5ffe3f27 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/http/HttpCookiesMatcher.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/http/HttpCookiesMatcher.java @@ -92,7 +92,7 @@ private static boolean equals(String value1, String value2) { } @SuppressWarnings("boxing") - protected static void describeCookie(Description description, + static void describeCookie(Description description, HttpCookie cookie) { description.appendText("HttpCookie["); description.appendText("name: ").appendValue(cookie.getName()) @@ -114,4 +114,4 @@ protected static void describeCookie(Description description, description.appendText("]"); } } -} \ No newline at end of file +}