From 6521c647b7073a9423749b1896302e3e0975d649 Mon Sep 17 00:00:00 2001 From: David Ostrovsky Date: Sun, 28 Apr 2024 14:30:56 +0200 Subject: Bazel: Update RBE docker image to Ubuntu 22.04 and JDK 17 In this change we update the JDK used in RBE to JDK 17. Use Ubuntu 22.04 docker image with JDK 17 from Bazel project as the new base image. So that we don't need to maintain our own docker image any more. Also align the naming convention for the docker images with the Bazel project: -, and remove "rbe"-prefix from the docker image name, because the image doesn't have any RBE specifics and could be used for Gerrit build and tests outside of the RBE pipeline. Change-Id: I617354c79301ec6dd52161dd3727f646c2a8ac56 --- tools/remote-bazelrc | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'tools') diff --git a/tools/remote-bazelrc b/tools/remote-bazelrc index 0c558f8136..f8aabd28ae 100644 --- a/tools/remote-bazelrc +++ b/tools/remote-bazelrc @@ -30,12 +30,11 @@ build:remote --disk_cache= # Set several flags related to specifying the platform, toolchain and java # properties. -build:remote --crosstool_top=@rbe_jdk11//cc:toolchain -build:remote --extra_toolchains=@rbe_jdk11//config:cc-toolchain -build:remote --extra_execution_platforms=@rbe_jdk11//config:platform -build:remote --host_platform=@rbe_jdk11//config:platform -build:remote --platforms=@rbe_jdk11//config:platform -build:remote --action_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1 +build:remote --crosstool_top=@ubuntu2204_jdk17//cc:toolchain +build:remote --extra_toolchains=@ubuntu2204_jdk17//config:cc-toolchain +build:remote --extra_execution_platforms=@ubuntu2204_jdk17//config:platform +build:remote --host_platform=@ubuntu2204_jdk17//config:platform +build:remote --platforms=@ubuntu2204_jdk17//config:platform # Set various strategies so that all actions execute remotely. Mixing remote # and local execution will lead to errors unless the toolchain and remote -- cgit v1.2.3 From d8cb554f25925f3ea2d66815fdaa59efa1867ae3 Mon Sep 17 00:00:00 2001 From: Matthias Sohn Date: Sun, 28 Apr 2024 21:28:30 +0200 Subject: [errorprone] Fix UnnecessaryParentheses errors See https://errorprone.info/bugpattern/UnnecessaryParentheses Change-Id: I783fd24286ec1bd55efbf21d05758465f4af87ee --- .../eclipse/jgit/junit/ssh/SshTestGitServer.java | 2 +- .../tst/org/eclipse/jgit/pgm/CloneTest.java | 4 +- .../tst/org/eclipse/jgit/pgm/ConfigTest.java | 5 +-- .../tst/org/eclipse/jgit/api/AddCommandTest.java | 4 +- .../jgit/attributes/TreeWalkAttributeTest.java | 2 +- .../internal/storage/dfs/DfsPackParserTest.java | 4 +- .../org/eclipse/jgit/transport/PackParserTest.java | 26 ++++++------- .../ReceivePackAdvertiseRefsHookTest.java | 6 +-- .../org/eclipse/jgit/transport/UploadPackTest.java | 43 ++++++++++++---------- tools/BUILD | 2 +- 10 files changed, 50 insertions(+), 48 deletions(-) (limited to 'tools') 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 1138be8a96..f5627e00c8 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 @@ public class SshTestGitServer { 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 cbb5bbb9cc..a1fb9fb589 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 class CloneTest extends CLIRepositoryTestCase { 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 class CloneTest extends CLIRepositoryTestCase { 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 005215f443..0af310c497 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,9 @@ public class ConfigTest extends CLIRepositoryTestCase { 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")))); + assertTrue(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 db2d5d1404..aa65985c55 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 @@ -1259,7 +1259,7 @@ public class AddCommandTest extends RepositoryTestCase { "[git-link-dir, mode:160000]", indexState(0)); Set untrackedFiles = git.status().call().getUntracked(); - assert (untrackedFiles.isEmpty()); + assert untrackedFiles.isEmpty(); } } @@ -1274,7 +1274,7 @@ public class AddCommandTest extends RepositoryTestCase { ConfigConstants.CONFIG_KEY_DIRNOGITLINKS, true); config.save(); - assert (db.getConfig().get(WorkingTreeOptions.KEY).isDirNoGitLinks()); + assert 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/attributes/TreeWalkAttributeTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/attributes/TreeWalkAttributeTest.java index 73abd2d37e..698fdb31a8 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 @@ public class TreeWalkAttributeTest extends RepositoryTestCase { 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/internal/storage/dfs/DfsPackParserTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/dfs/DfsPackParserTest.java index 845d5fcca1..130af27773 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 class DfsPackParserTest { .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/transport/PackParserTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PackParserTest.java index 2fd82e7bdb..6148df99f3 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 class PackParserTest extends RepositoryTestCase { 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 class PackParserTest extends RepositoryTestCase { 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 class PackParserTest extends RepositoryTestCase { 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 class PackParserTest extends RepositoryTestCase { 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 class PackParserTest extends RepositoryTestCase { 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 class PackParserTest extends RepositoryTestCase { 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 class PackParserTest extends RepositoryTestCase { 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 class PackParserTest extends RepositoryTestCase { 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 class PackParserTest extends RepositoryTestCase { 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 class PackParserTest extends RepositoryTestCase { 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 class PackParserTest extends RepositoryTestCase { 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 class PackParserTest extends RepositoryTestCase { 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/ReceivePackAdvertiseRefsHookTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/ReceivePackAdvertiseRefsHookTest.java index a91bc95c8d..7dac27f612 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 class ReceivePackAdvertiseRefsHookTest extends LocalDiskRepositoryTestCas 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 class ReceivePackAdvertiseRefsHookTest extends LocalDiskRepositoryTestCas 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/UploadPackTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackTest.java index 026492f7b6..def73acadd 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,15 @@ public class UploadPackTest { 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 +1905,23 @@ public class UploadPackTest { 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 +1929,7 @@ public class UploadPackTest { dcBuilder.addTree(new byte[] {'x'}, DirCacheEntry.STAGE_0, remote.getRevWalk().getObjectReader(), subtree2); } - }).build(); + }.build(); RevCommit commit = remote.commit(rootTree); RepeatedSubtreePreparator() throws Exception {} @@ -1970,22 +1973,22 @@ public class UploadPackTest { 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 +1996,33 @@ public class UploadPackTest { 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 +2034,7 @@ public class UploadPackTest { 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/tools/BUILD b/tools/BUILD index c2b2366c49..dbec43b7fa 100644 --- a/tools/BUILD +++ b/tools/BUILD @@ -396,7 +396,7 @@ java_package_configuration( "-Xep:UnnecessaryLambda:ERROR", "-Xep:UnnecessaryMethodInvocationMatcher:ERROR", "-Xep:UnnecessaryMethodReference:ERROR", - "-Xep:UnnecessaryParentheses:WARN", + "-Xep:UnnecessaryParentheses:ERROR", "-Xep:UnnecessaryTypeArgument:ERROR", "-Xep:UnrecognisedJavadocTag:ERROR", "-Xep:UnsafeFinalization:ERROR", -- cgit v1.2.3 From 964498e0a5059fc62417f4d09074b56b42b148be Mon Sep 17 00:00:00 2001 From: Matthias Sohn Date: Sun, 28 Apr 2024 22:41:46 +0200 Subject: [errorprone] Fix error pattern JdkObsolete See https://errorprone.info/bugpattern/JdkObsolete Change-Id: Id105e2695eb64523bd217f507bf95f909bc6b348 --- .../transport/http/apache/HttpClientConnection.java | 4 ++-- .../src/org/eclipse/jgit/http/server/GitFilter.java | 6 +++--- .../jgit/lfs/internal/LfsConnectionFactory.java | 6 +++--- .../src/org/eclipse/jgit/pgm/CommandCatalog.java | 4 ++-- .../transport/sshd/KnownHostEntryReader.java | 4 ++-- .../transport/sshd/OpenSshServerKeyDatabase.java | 3 +-- .../eclipse/jgit/transport/sshd/SshdSession.java | 3 +-- .../tst/org/eclipse/jgit/lib/ConfigTest.java | 9 ++++----- .../jgit/revplot/AbstractPlotRendererTest.java | 4 ++-- .../jgit/transport/http/JDKHttpConnectionTest.java | 4 ++-- .../eclipse/jgit/util/http/HttpCookiesMatcher.java | 4 ++-- .../src/org/eclipse/jgit/awtui/SwingCommitList.java | 7 ++++--- .../src/org/eclipse/jgit/api/CheckoutCommand.java | 3 +-- .../src/org/eclipse/jgit/api/CherryPickCommand.java | 6 +++--- .../src/org/eclipse/jgit/api/CommitCommand.java | 3 +-- .../src/org/eclipse/jgit/api/MergeCommand.java | 4 ++-- .../src/org/eclipse/jgit/api/RebaseCommand.java | 5 ++--- .../src/org/eclipse/jgit/api/ResetCommand.java | 4 ++-- .../src/org/eclipse/jgit/api/RevertCommand.java | 6 +++--- .../src/org/eclipse/jgit/api/RmCommand.java | 3 +-- .../src/org/eclipse/jgit/api/StatusCommand.java | 4 ++-- .../jgit/api/errors/CheckoutConflictException.java | 4 ++-- .../storage/commitgraph/CommitGraphWriter.java | 6 +++--- .../jgit/internal/storage/dfs/DfsReader.java | 3 +-- .../org/eclipse/jgit/internal/storage/file/GC.java | 5 ++--- .../storage/file/PackBitmapIndexBuilder.java | 5 ++--- .../jgit/internal/storage/file/RefDirectory.java | 6 +++--- .../internal/storage/memory/TernarySearchTree.java | 8 ++++---- .../jgit/internal/storage/pack/DeltaTask.java | 7 ++++--- .../internal/transport/ssh/OpenSshConfigFile.java | 5 ++--- .../src/org/eclipse/jgit/lib/RebaseTodoFile.java | 4 ++-- .../src/org/eclipse/jgit/merge/ResolveMerger.java | 5 ++--- .../eclipse/jgit/revwalk/MergeBaseGenerator.java | 5 +++-- .../src/org/eclipse/jgit/transport/Transport.java | 6 ++---- .../org/eclipse/jgit/transport/TransportHttp.java | 5 ++--- .../eclipse/jgit/transport/WalkFetchConnection.java | 21 +++++++++++---------- .../jgit/transport/http/JDKHttpConnection.java | 4 ++-- .../jgit/treewalk/filter/IndexDiffFilter.java | 17 ++++++++++------- .../org/eclipse/jgit/util/io/UnionInputStream.java | 5 +++-- tools/BUILD | 2 +- 40 files changed, 106 insertions(+), 113 deletions(-) (limited to 'tools') diff --git a/org.eclipse.jgit.http.apache/src/org/eclipse/jgit/transport/http/apache/HttpClientConnection.java b/org.eclipse.jgit.http.apache/src/org/eclipse/jgit/transport/http/apache/HttpClientConnection.java index 6d806dee37..0cb6fe10d0 100644 --- a/org.eclipse.jgit.http.apache/src/org/eclipse/jgit/transport/http/apache/HttpClientConnection.java +++ b/org.eclipse.jgit.http.apache/src/org/eclipse/jgit/transport/http/apache/HttpClientConnection.java @@ -25,10 +25,10 @@ import java.net.URL; import java.security.KeyManagementException; import java.security.NoSuchAlgorithmException; import java.security.SecureRandom; +import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; -import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -300,7 +300,7 @@ public class HttpClientConnection implements HttpConnection { for (Header hdr : resp.getAllHeaders()) { List list = ret.get(hdr.getName()); if (list == null) { - list = new LinkedList<>(); + list = new ArrayList<>(); ret.put(hdr.getName(), list); } for (HeaderElement hdrElem : hdr.getElements()) { diff --git a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/GitFilter.java b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/GitFilter.java index 2f3eee41d6..703c0be8d9 100644 --- a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/GitFilter.java +++ b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/GitFilter.java @@ -12,7 +12,7 @@ package org.eclipse.jgit.http.server; import java.io.File; import java.text.MessageFormat; -import java.util.LinkedList; +import java.util.ArrayList; import java.util.List; import javax.servlet.Filter; @@ -65,9 +65,9 @@ public class GitFilter extends MetaFilter { private ReceivePackErrorHandler receivePackErrorHandler; - private final List uploadPackFilters = new LinkedList<>(); + private final List uploadPackFilters = new ArrayList<>(); - private final List receivePackFilters = new LinkedList<>(); + private final List receivePackFilters = new ArrayList<>(); /** * New servlet that will load its base directory from {@code web.xml}. diff --git a/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/internal/LfsConnectionFactory.java b/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/internal/LfsConnectionFactory.java index d7d8d63775..1a4e85ded6 100644 --- a/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/internal/LfsConnectionFactory.java +++ b/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/internal/LfsConnectionFactory.java @@ -9,11 +9,11 @@ */ package org.eclipse.jgit.lfs.internal; +import static org.eclipse.jgit.lib.Constants.DEFAULT_REMOTE_NAME; import static org.eclipse.jgit.util.HttpSupport.ENCODING_GZIP; import static org.eclipse.jgit.util.HttpSupport.HDR_ACCEPT; import static org.eclipse.jgit.util.HttpSupport.HDR_ACCEPT_ENCODING; import static org.eclipse.jgit.util.HttpSupport.HDR_CONTENT_TYPE; -import static org.eclipse.jgit.lib.Constants.DEFAULT_REMOTE_NAME; import java.io.IOException; import java.net.ProxySelector; @@ -22,7 +22,7 @@ import java.net.URL; import java.time.LocalDateTime; import java.time.ZoneOffset; import java.time.format.DateTimeFormatter; -import java.util.LinkedList; +import java.util.ArrayList; import java.util.Map; import java.util.TreeMap; @@ -266,7 +266,7 @@ public class LfsConnectionFactory { Protocol.Request req = new Protocol.Request(); req.operation = operation; if (resources != null) { - req.objects = new LinkedList<>(); + req.objects = new ArrayList<>(); for (LfsPointer res : resources) { Protocol.ObjectSpec o = new Protocol.ObjectSpec(); o.oid = res.getOid().getName(); diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CommandCatalog.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CommandCatalog.java index 210e17277f..2a9f7acdb9 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CommandCatalog.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CommandCatalog.java @@ -19,10 +19,10 @@ import java.net.URL; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; +import java.util.Collections; import java.util.Enumeration; import java.util.HashMap; import java.util.Map; -import java.util.Vector; /** * List of all commands known by jgit's command line tools. @@ -104,7 +104,7 @@ public class CommandCatalog { final String pfx = "META-INF/services/"; //$NON-NLS-1$ return ldr.getResources(pfx + TextBuiltin.class.getName()); } catch (IOException err) { - return new Vector().elements(); + return Collections.emptyEnumeration(); } } diff --git a/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/KnownHostEntryReader.java b/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/KnownHostEntryReader.java index a00e5d96ac..96829b7365 100644 --- a/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/KnownHostEntryReader.java +++ b/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/KnownHostEntryReader.java @@ -18,9 +18,9 @@ import java.io.BufferedReader; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; +import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; -import java.util.LinkedList; import java.util.List; import java.util.stream.Collectors; @@ -65,7 +65,7 @@ public class KnownHostEntryReader { */ public static List readFromFile(Path path) throws IOException { - List result = new LinkedList<>(); + List result = new ArrayList<>(); try (BufferedReader r = Files.newBufferedReader(path, UTF_8)) { r.lines().forEachOrdered(l -> { if (l == null) { diff --git a/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/OpenSshServerKeyDatabase.java b/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/OpenSshServerKeyDatabase.java index 65ba5be0c5..2b4f7e50ff 100644 --- a/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/OpenSshServerKeyDatabase.java +++ b/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/OpenSshServerKeyDatabase.java @@ -31,7 +31,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; -import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Random; @@ -587,7 +586,7 @@ public class OpenSshServerKeyDatabase if (rawEntries == null || rawEntries.isEmpty()) { return Collections.emptyList(); } - List newEntries = new LinkedList<>(); + List newEntries = new ArrayList<>(); for (KnownHostEntry entry : rawEntries) { AuthorizedKeyEntry keyPart = entry.getKeyEntry(); if (keyPart == null) { diff --git a/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/transport/sshd/SshdSession.java b/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/transport/sshd/SshdSession.java index b94ccc6d4f..96316ba1aa 100644 --- a/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/transport/sshd/SshdSession.java +++ b/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/transport/sshd/SshdSession.java @@ -23,7 +23,6 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.EnumSet; -import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.concurrent.CopyOnWriteArrayList; @@ -263,7 +262,7 @@ public class SshdSession implements RemoteSession2 { private List parseProxyJump(String proxyJump) throws URISyntaxException { String[] hops = proxyJump.split(","); //$NON-NLS-1$ - List result = new LinkedList<>(); + List result = new ArrayList<>(); for (String hop : hops) { // There shouldn't be any whitespace, but let's be lenient hop = hop.trim(); 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 0c0257df90..5c63c2df6b 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 @@ -42,7 +42,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Iterator; -import java.util.LinkedList; import java.util.List; import java.util.Set; import java.util.concurrent.TimeUnit; @@ -124,16 +123,16 @@ public class ConfigTest { @Test public void test005_PutGetStringList() { Config c = new Config(); - final LinkedList values = new LinkedList<>(); + List values = new ArrayList<>(); values.add("value1"); values.add("value2"); c.setStringList("my", null, "somename", values); - final Object[] expArr = values.toArray(); - final String[] actArr = c.getStringList("my", null, "somename"); + Object[] expArr = values.toArray(); + String[] actArr = c.getStringList("my", null, "somename"); assertArrayEquals(expArr, actArr); - final String expText = "[my]\n\tsomename = value1\n\tsomename = value2\n"; + String expText = "[my]\n\tsomename = value1\n\tsomename = value2\n"; assertEquals(expText, c.toText()); } diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revplot/AbstractPlotRendererTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revplot/AbstractPlotRendererTest.java index 49f832a1aa..e4bd8506e3 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revplot/AbstractPlotRendererTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revplot/AbstractPlotRendererTest.java @@ -11,7 +11,7 @@ package org.eclipse.jgit.revplot; import static org.junit.Assert.assertEquals; -import java.util.LinkedList; +import java.util.ArrayList; import java.util.List; import org.eclipse.jgit.api.Git; @@ -70,7 +70,7 @@ public class AbstractPlotRendererTest extends RepositoryTestCase { private static class TestPlotRenderer extends AbstractPlotRenderer { - List indentations = new LinkedList<>(); + List indentations = new ArrayList<>(); @Override protected int drawLabel(int x, int y, Ref ref) { diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/http/JDKHttpConnectionTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/http/JDKHttpConnectionTest.java index 37f9514494..f71781dcf3 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/http/JDKHttpConnectionTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/http/JDKHttpConnectionTest.java @@ -16,9 +16,9 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import java.net.HttpURLConnection; +import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; -import java.util.LinkedList; import java.util.List; import java.util.Map; @@ -74,7 +74,7 @@ public class JDKHttpConnectionTest { } private void assertValues(String key, String... values) { - List l = new LinkedList<>(); + List l = new ArrayList<>(); List hf = c.getHeaderFields(key); if (hf != null) { l.addAll(hf); 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 5a2bd976c7..18faab5c9f 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 @@ -10,7 +10,7 @@ package org.eclipse.jgit.util.http; import java.net.HttpCookie; -import java.util.LinkedList; +import java.util.ArrayList; import java.util.List; import org.hamcrest.Description; @@ -26,7 +26,7 @@ public final class HttpCookiesMatcher { public static Matcher> containsInOrder( Iterable expectedCookies, int allowedMaxAgeDelta) { - final List> cookieMatchers = new LinkedList<>(); + final List> cookieMatchers = new ArrayList<>(); for (HttpCookie cookie : expectedCookies) { cookieMatchers .add(new HttpCookieMatcher(cookie, allowedMaxAgeDelta)); diff --git a/org.eclipse.jgit.ui/src/org/eclipse/jgit/awtui/SwingCommitList.java b/org.eclipse.jgit.ui/src/org/eclipse/jgit/awtui/SwingCommitList.java index 47acc11e7d..901452617d 100644 --- a/org.eclipse.jgit.ui/src/org/eclipse/jgit/awtui/SwingCommitList.java +++ b/org.eclipse.jgit.ui/src/org/eclipse/jgit/awtui/SwingCommitList.java @@ -11,16 +11,17 @@ package org.eclipse.jgit.awtui; import java.awt.Color; -import java.util.LinkedList; +import java.util.ArrayDeque; +import java.util.Deque; import org.eclipse.jgit.revplot.PlotCommitList; import org.eclipse.jgit.revplot.PlotLane; class SwingCommitList extends PlotCommitList { - final LinkedList colors; + final Deque colors; SwingCommitList() { - colors = new LinkedList<>(); + colors = new ArrayDeque<>(); repackColors(); } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/CheckoutCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/CheckoutCommand.java index a03ea01864..c133219d4d 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/CheckoutCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/CheckoutCommand.java @@ -17,7 +17,6 @@ import java.text.MessageFormat; import java.util.ArrayList; import java.util.EnumSet; import java.util.HashSet; -import java.util.LinkedList; import java.util.List; import java.util.Set; @@ -164,7 +163,7 @@ public class CheckoutCommand extends GitCommand { */ protected CheckoutCommand(Repository repo) { super(repo); - this.paths = new LinkedList<>(); + this.paths = new ArrayList<>(); } @Override diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/CherryPickCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/CherryPickCommand.java index a1c64788bd..a353d1a135 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/CherryPickCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/CherryPickCommand.java @@ -14,7 +14,7 @@ import static org.eclipse.jgit.lib.Constants.OBJECT_ID_ABBREV_STRING_LENGTH; import java.io.IOException; import java.text.MessageFormat; -import java.util.LinkedList; +import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -63,7 +63,7 @@ import org.eclipse.jgit.treewalk.FileTreeIterator; public class CherryPickCommand extends GitCommand { private String reflogPrefix = "cherry-pick:"; //$NON-NLS-1$ - private List commits = new LinkedList<>(); + private List commits = new ArrayList<>(); private String ourCommitName = null; @@ -102,7 +102,7 @@ public class CherryPickCommand extends GitCommand { UnmergedPathsException, ConcurrentRefUpdateException, WrongRepositoryStateException, NoHeadException { RevCommit newHead = null; - List cherryPickedRefs = new LinkedList<>(); + List cherryPickedRefs = new ArrayList<>(); checkCallable(); try (RevWalk revWalk = new RevWalk(repo)) { diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java index 483b9602da..a1a2cc09d2 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java @@ -16,7 +16,6 @@ import java.text.MessageFormat; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; -import java.util.LinkedList; import java.util.List; import org.eclipse.jgit.annotations.NonNull; @@ -109,7 +108,7 @@ public class CommitCommand extends GitCommand { * parents this commit should have. The current HEAD will be in this list * and also all commits mentioned in .git/MERGE_HEAD */ - private List parents = new LinkedList<>(); + private List parents = new ArrayList<>(); private String reflogComment; diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/MergeCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/MergeCommand.java index ed4a5342b3..7064f5a57a 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/MergeCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/MergeCommand.java @@ -13,9 +13,9 @@ package org.eclipse.jgit.api; import java.io.IOException; import java.text.MessageFormat; +import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; -import java.util.LinkedList; import java.util.List; import java.util.Locale; import java.util.Map; @@ -75,7 +75,7 @@ public class MergeCommand extends GitCommand { private ContentMergeStrategy contentStrategy; - private List commits = new LinkedList<>(); + private List commits = new ArrayList<>(); private Boolean squash; diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java index 757aff89c3..858bd961cd 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java @@ -23,7 +23,6 @@ import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.Iterator; -import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.regex.Matcher; @@ -1120,8 +1119,8 @@ public class RebaseCommand extends GitCommand { private void popSteps(int numSteps) throws IOException { if (numSteps == 0) return; - List todoLines = new LinkedList<>(); - List poppedLines = new LinkedList<>(); + List todoLines = new ArrayList<>(); + List poppedLines = new ArrayList<>(); for (RebaseTodoLine line : repo.readRebaseTodo( rebaseState.getPath(GIT_REBASE_TODO), true)) { diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/ResetCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/ResetCommand.java index 225c9996cf..47145a0563 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/ResetCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/ResetCommand.java @@ -11,8 +11,8 @@ package org.eclipse.jgit.api; import java.io.IOException; import java.text.MessageFormat; +import java.util.ArrayList; import java.util.Collection; -import java.util.LinkedList; import org.eclipse.jgit.api.errors.CheckoutConflictException; import org.eclipse.jgit.api.errors.GitAPIException; @@ -90,7 +90,7 @@ public class ResetCommand extends GitCommand { private ResetType mode; - private Collection filepaths = new LinkedList<>(); + private Collection filepaths = new ArrayList<>(); private boolean isReflogDisabled; diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/RevertCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/RevertCommand.java index 5231d4a327..855c3b1cf3 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/RevertCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/RevertCommand.java @@ -13,7 +13,7 @@ import static org.eclipse.jgit.lib.Constants.OBJECT_ID_ABBREV_STRING_LENGTH; import java.io.IOException; import java.text.MessageFormat; -import java.util.LinkedList; +import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -58,13 +58,13 @@ import org.eclipse.jgit.treewalk.FileTreeIterator; * >Git documentation about revert */ public class RevertCommand extends GitCommand { - private List commits = new LinkedList<>(); + private List commits = new ArrayList<>(); private String ourCommitName = null; private boolean insertChangeId; - private List revertedRefs = new LinkedList<>(); + private List revertedRefs = new ArrayList<>(); private MergeResult failingResult; diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/RmCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/RmCommand.java index 656f36a81a..7459e7298f 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/RmCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/RmCommand.java @@ -13,7 +13,6 @@ import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.Collection; -import java.util.LinkedList; import java.util.List; import org.eclipse.jgit.api.errors.GitAPIException; @@ -71,7 +70,7 @@ public class RmCommand extends GitCommand { */ public RmCommand(Repository repo) { super(repo); - filepatterns = new LinkedList<>(); + filepatterns = new ArrayList<>(); } /** diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/StatusCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/StatusCommand.java index eab389460a..cdd078ea25 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/StatusCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/StatusCommand.java @@ -10,7 +10,7 @@ package org.eclipse.jgit.api; import java.io.IOException; -import java.util.LinkedList; +import java.util.ArrayList; import java.util.List; import org.eclipse.jgit.api.errors.GitAPIException; @@ -83,7 +83,7 @@ public class StatusCommand extends GitCommand { */ public StatusCommand addPath(String path) { if (paths == null) - paths = new LinkedList<>(); + paths = new ArrayList<>(); paths.add(path); return this; } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/errors/CheckoutConflictException.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/errors/CheckoutConflictException.java index 0224b3dbb3..5538711192 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/errors/CheckoutConflictException.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/errors/CheckoutConflictException.java @@ -37,7 +37,7 @@ */ package org.eclipse.jgit.api.errors; -import java.util.LinkedList; +import java.util.ArrayList; import java.util.List; /** @@ -99,7 +99,7 @@ public class CheckoutConflictException extends GitAPIException { */ CheckoutConflictException addConflictingPath(String conflictingPath) { if (conflictingPaths == null) - conflictingPaths = new LinkedList<>(); + conflictingPaths = new ArrayList<>(); conflictingPaths.add(conflictingPath); return this; } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/commitgraph/CommitGraphWriter.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/commitgraph/CommitGraphWriter.java index 1f1c35ac19..0d9815eceb 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/commitgraph/CommitGraphWriter.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/commitgraph/CommitGraphWriter.java @@ -31,12 +31,12 @@ import java.io.IOException; import java.io.InterruptedIOException; import java.io.OutputStream; import java.nio.ByteBuffer; +import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Optional; -import java.util.Stack; import org.eclipse.jgit.annotations.NonNull; import org.eclipse.jgit.annotations.Nullable; @@ -336,10 +336,10 @@ public class CommitGraphWriter { continue; } - Stack commitStack = new Stack<>(); + ArrayDeque commitStack = new ArrayDeque<>(); commitStack.push(cmit); - while (!commitStack.empty()) { + while (!commitStack.isEmpty()) { int maxGeneration = 0; boolean allParentComputed = true; RevCommit current = commitStack.peek(); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsReader.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsReader.java index a342796cbe..c939114f5f 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsReader.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsReader.java @@ -21,7 +21,6 @@ import java.util.Collections; import java.util.Comparator; import java.util.HashSet; import java.util.Iterator; -import java.util.LinkedList; import java.util.List; import java.util.Optional; import java.util.Set; @@ -308,7 +307,7 @@ public class DfsReader extends ObjectReader implements ObjectReuseAsIs { private Iterable> findAll( Iterable objectIds) throws IOException { - Collection pending = new LinkedList<>(); + Collection pending = new ArrayList<>(); for (T id : objectIds) { pending.add(id); } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java index 4c996730e8..cf26f8d284 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java @@ -49,7 +49,6 @@ import java.util.Date; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; -import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Objects; @@ -866,7 +865,7 @@ public class GC { } } - List excluded = new LinkedList<>(); + List excluded = new ArrayList<>(); for (Pack p : repo.getObjectDatabase().getPacks()) { checkCancelled(); if (!shouldPackKeptObjects() && p.shouldBeKept()) { @@ -1897,7 +1896,7 @@ public class GC { } private String getProcDesc() { - StringBuffer s = new StringBuffer(Long.toString(getPID())); + StringBuilder s = new StringBuilder(Long.toString(getPID())); s.append(' '); s.append(getHostName()); return s.toString(); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackBitmapIndexBuilder.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackBitmapIndexBuilder.java index 1da805503d..08d2b7178f 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackBitmapIndexBuilder.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackBitmapIndexBuilder.java @@ -11,9 +11,9 @@ package org.eclipse.jgit.internal.storage.file; import java.text.MessageFormat; +import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Collections; -import java.util.LinkedList; import java.util.List; import org.eclipse.jgit.internal.JGitText; @@ -41,8 +41,7 @@ public class PackBitmapIndexBuilder extends BasePackBitmapIndex { private final EWAHCompressedBitmap tags; private final BlockList byOffset; - private final LinkedList - bitmapsToWriteXorBuffer = new LinkedList<>(); + private final ArrayDeque bitmapsToWriteXorBuffer = new ArrayDeque<>(); private List bitmapsToWrite = new ArrayList<>(); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java index 169dce1cc0..8e57bf9f2f 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java @@ -41,11 +41,11 @@ import java.nio.file.Paths; import java.security.DigestInputStream; import java.security.MessageDigest; import java.text.MessageFormat; +import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.HashMap; -import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; @@ -64,8 +64,8 @@ import org.eclipse.jgit.events.RefsChangedEvent; import org.eclipse.jgit.internal.JGitText; import org.eclipse.jgit.lib.ConfigConstants; import org.eclipse.jgit.lib.Constants; -import org.eclipse.jgit.lib.CoreConfig.TrustPackedRefsStat; import org.eclipse.jgit.lib.CoreConfig.TrustLooseRefStat; +import org.eclipse.jgit.lib.CoreConfig.TrustPackedRefsStat; import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.ObjectIdRef; import org.eclipse.jgit.lib.Ref; @@ -413,7 +413,7 @@ public class RefDirectory extends RefDatabase { @Override public List getAdditionalRefs() throws IOException { - List ret = new LinkedList<>(); + List ret = new ArrayList<>(); for (String name : additionalRefsNames) { Ref r = exactRef(name); if (r != null) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/memory/TernarySearchTree.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/memory/TernarySearchTree.java index acc1c830d5..72434dbffe 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/memory/TernarySearchTree.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/memory/TernarySearchTree.java @@ -9,9 +9,9 @@ */ package org.eclipse.jgit.internal.storage.memory; +import java.util.ArrayDeque; import java.util.ArrayList; import java.util.HashMap; -import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Map.Entry; @@ -340,7 +340,7 @@ public final class TernarySearchTree { * @return all keys */ public Iterable getKeys() { - Queue queue = new LinkedList<>(); + Queue queue = new ArrayDeque<>(); lock.readLock().lock(); try { findKeysWithPrefix(root, new StringBuilder(), queue); @@ -358,7 +358,7 @@ public final class TernarySearchTree { * @return keys starting with given prefix */ public Iterable getKeysWithPrefix(String prefix) { - Queue keys = new LinkedList<>(); + Queue keys = new ArrayDeque<>(); if (prefix == null) { return keys; } @@ -486,7 +486,7 @@ public final class TernarySearchTree { * @return keys matching given pattern. */ public Iterable getKeysMatching(String pattern) { - Queue keys = new LinkedList<>(); + Queue keys = new ArrayDeque<>(); lock.readLock().lock(); try { findKeysWithPrefix(root, new StringBuilder(), 0, pattern, keys); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/DeltaTask.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/DeltaTask.java index 9a3f4b07ee..03d6f16733 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/DeltaTask.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/DeltaTask.java @@ -11,10 +11,10 @@ package org.eclipse.jgit.internal.storage.pack; import java.io.IOException; +import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; -import java.util.LinkedList; import java.util.List; import java.util.concurrent.Callable; @@ -232,14 +232,15 @@ final class DeltaTask implements Callable { } private final Block block; - final LinkedList slices; + + final ArrayDeque slices; private ObjectReader or; private DeltaWindow dw; DeltaTask(Block b) { this.block = b; - this.slices = new LinkedList<>(); + this.slices = new ArrayDeque<>(); } void add(Slice s) { diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/transport/ssh/OpenSshConfigFile.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/transport/ssh/OpenSshConfigFile.java index 29a2922136..3e75a9dde3 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/transport/ssh/OpenSshConfigFile.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/transport/ssh/OpenSshConfigFile.java @@ -22,7 +22,6 @@ import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.Iterator; -import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Set; @@ -100,7 +99,7 @@ public class OpenSshConfigFile implements SshConfigStore { * fully resolved entries created from that. */ private static class State { - List entries = new LinkedList<>(); + List entries = new ArrayList<>(); // Previous lookups, keyed by user@hostname:port Map hosts = new HashMap<>(); @@ -218,7 +217,7 @@ public class OpenSshConfigFile implements SshConfigStore { private List parse(BufferedReader reader) throws IOException { - final List entries = new LinkedList<>(); + final List entries = new ArrayList<>(); // The man page doesn't say so, but the openssh parser (readconf.c) // starts out in active mode and thus always applies any lines that diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/RebaseTodoFile.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/RebaseTodoFile.java index c716f464d3..b036a0b6a1 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/RebaseTodoFile.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/RebaseTodoFile.java @@ -17,7 +17,7 @@ import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; -import java.util.LinkedList; +import java.util.ArrayList; import java.util.List; import org.eclipse.jgit.lib.RebaseTodoLine.Action; @@ -62,7 +62,7 @@ public class RebaseTodoFile { byte[] buf = IO.readFully(new File(repo.getDirectory(), path)); int ptr = 0; int tokenBegin = 0; - List r = new LinkedList<>(); + List r = new ArrayList<>(); while (ptr < buf.length) { tokenBegin = ptr; ptr = RawParseUtils.nextLF(buf, ptr); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/merge/ResolveMerger.java b/org.eclipse.jgit/src/org/eclipse/jgit/merge/ResolveMerger.java index 825ef17c3f..1ad41be423 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/merge/ResolveMerger.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/merge/ResolveMerger.java @@ -32,7 +32,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; -import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Objects; @@ -106,9 +105,9 @@ public class ResolveMerger extends ThreeWayMerger { */ public static class Result { - private final List modifiedFiles = new LinkedList<>(); + private final List modifiedFiles = new ArrayList<>(); - private final List failedToDelete = new LinkedList<>(); + private final List failedToDelete = new ArrayList<>(); private ObjectId treeId = null; diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/MergeBaseGenerator.java b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/MergeBaseGenerator.java index a213dd47c6..be29dc3138 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/MergeBaseGenerator.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/MergeBaseGenerator.java @@ -12,7 +12,7 @@ package org.eclipse.jgit.revwalk; import java.io.IOException; import java.text.MessageFormat; -import java.util.LinkedList; +import java.util.ArrayDeque; import org.eclipse.jgit.errors.IncorrectObjectTypeException; import org.eclipse.jgit.errors.MissingObjectException; @@ -47,7 +47,8 @@ class MergeBaseGenerator extends Generator { private int recarryTest; private int recarryMask; private int mergeBaseAncestor = -1; - private LinkedList ret = new LinkedList<>(); + + private ArrayDeque ret = new ArrayDeque<>(); private CarryStack stack; diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/Transport.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/Transport.java index 4a02d6d452..b335675da5 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/Transport.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/Transport.java @@ -33,10 +33,8 @@ import java.util.Collection; import java.util.Collections; import java.util.Enumeration; import java.util.LinkedHashSet; -import java.util.LinkedList; import java.util.List; import java.util.Map; -import java.util.Vector; import java.util.concurrent.CopyOnWriteArrayList; import org.eclipse.jgit.annotations.NonNull; @@ -109,7 +107,7 @@ public abstract class Transport implements AutoCloseable { String name = prefix + Transport.class.getName(); return ldr.getResources(name); } catch (IOException err) { - return new Vector().elements(); + return Collections.emptyEnumeration(); } } @@ -595,7 +593,7 @@ public abstract class Transport implements AutoCloseable { Collection fetchSpecs) throws IOException { if (fetchSpecs == null) fetchSpecs = Collections.emptyList(); - final List result = new LinkedList<>(); + final List result = new ArrayList<>(); final Collection procRefs = expandPushWildcardsFor(db, specs); for (RefSpec spec : procRefs) { diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportHttp.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportHttp.java index 3162b89908..a65d0b756c 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportHttp.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportHttp.java @@ -66,7 +66,6 @@ import java.util.Collections; import java.util.EnumSet; import java.util.HashSet; import java.util.LinkedHashSet; -import java.util.LinkedList; import java.util.List; import java.util.Locale; import java.util.Map; @@ -763,7 +762,7 @@ public class TransportHttp extends HttpTransport implements WalkTransport, void processResponseCookies(HttpConnection conn) { if (cookieFile != null && http.getSaveCookies()) { - List foundCookies = new LinkedList<>(); + List foundCookies = new ArrayList<>(); List cookieHeaderValues = conn .getHeaderFields(HDR_SET_COOKIE); @@ -795,7 +794,7 @@ public class TransportHttp extends HttpTransport implements WalkTransport, private List extractCookies(String headerKey, List headerValues) { - List foundCookies = new LinkedList<>(); + List foundCookies = new ArrayList<>(); for (String headerValue : headerValues) { foundCookies .addAll(HttpCookie.parse(headerKey + ':' + headerValue)); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/WalkFetchConnection.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/WalkFetchConnection.java index 8d89107c2b..3da76f38fa 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/WalkFetchConnection.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/WalkFetchConnection.java @@ -16,12 +16,13 @@ import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.text.MessageFormat; +import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Collection; +import java.util.Deque; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; -import java.util.LinkedList; import java.util.List; import java.util.Set; @@ -112,16 +113,16 @@ class WalkFetchConnection extends BaseFetchConnection { private final DateRevQueue localCommitQueue; /** Objects we need to copy from the remote repository. */ - private LinkedList workQueue; + private Deque workQueue; /** Databases we have not yet obtained the list of packs from. */ - private final LinkedList noPacksYet; + private final Deque noPacksYet; /** Databases we have not yet obtained the alternates from. */ - private final LinkedList noAlternatesYet; + private final Deque noAlternatesYet; /** Packs we have discovered, but have not yet fetched locally. */ - private final LinkedList unfetchedPacks; + private final Deque unfetchedPacks; /** * Packs whose indexes we have looked at in {@link #unfetchedPacks}. @@ -163,13 +164,13 @@ class WalkFetchConnection extends BaseFetchConnection { remotes = new ArrayList<>(); remotes.add(w); - unfetchedPacks = new LinkedList<>(); + unfetchedPacks = new ArrayDeque<>(); packsConsidered = new HashSet<>(); - noPacksYet = new LinkedList<>(); + noPacksYet = new ArrayDeque<>(); noPacksYet.add(w); - noAlternatesYet = new LinkedList<>(); + noAlternatesYet = new ArrayDeque<>(); noAlternatesYet.add(w); fetchErrors = new HashMap<>(); @@ -183,7 +184,7 @@ class WalkFetchConnection extends BaseFetchConnection { LOCALLY_SEEN = revWalk.newFlag("LOCALLY_SEEN"); //$NON-NLS-1$ localCommitQueue = new DateRevQueue(); - workQueue = new LinkedList<>(); + workQueue = new ArrayDeque<>(); } @Override @@ -567,7 +568,7 @@ class WalkFetchConnection extends BaseFetchConnection { private Iterator swapFetchQueue() { final Iterator r = workQueue.iterator(); - workQueue = new LinkedList<>(); + workQueue = new ArrayDeque<>(); return r; } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/http/JDKHttpConnection.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/http/JDKHttpConnection.java index 8e9be1dde8..e20acadc4a 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/http/JDKHttpConnection.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/http/JDKHttpConnection.java @@ -20,7 +20,7 @@ import java.net.URL; import java.security.KeyManagementException; import java.security.NoSuchAlgorithmException; import java.security.SecureRandom; -import java.util.LinkedList; +import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -152,7 +152,7 @@ public class JDKHttpConnection implements HttpConnection { private static List mapValuesToListIgnoreCase(String keyName, Map> m) { - List fields = new LinkedList<>(); + List fields = new ArrayList<>(); m.entrySet().stream().filter(e -> keyName.equalsIgnoreCase(e.getKey())) .filter(e -> e.getValue() != null) .forEach(e -> fields.addAll(e.getValue())); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/filter/IndexDiffFilter.java b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/filter/IndexDiffFilter.java index 699ff6b68b..cfdc4dd358 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/filter/IndexDiffFilter.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/filter/IndexDiffFilter.java @@ -10,8 +10,9 @@ package org.eclipse.jgit.treewalk.filter; import java.io.IOException; +import java.util.ArrayDeque; +import java.util.ArrayList; import java.util.HashSet; -import java.util.LinkedList; import java.util.List; import java.util.Set; @@ -62,9 +63,9 @@ public class IndexDiffFilter extends TreeFilter { private final Set ignoredPaths = new HashSet<>(); - private final LinkedList untrackedParentFolders = new LinkedList<>(); + private final ArrayDeque untrackedParentFolders = new ArrayDeque<>(); - private final LinkedList untrackedFolders = new LinkedList<>(); + private final ArrayDeque untrackedFolders = new ArrayDeque<>(); /** * Creates a new instance of this filter. Do not use an instance of this @@ -272,12 +273,14 @@ public class IndexDiffFilter extends TreeFilter { * empty list will be returned. */ public List getUntrackedFolders() { - LinkedList ret = new LinkedList<>(untrackedFolders); + ArrayList ret = new ArrayList<>(untrackedFolders); if (!untrackedParentFolders.isEmpty()) { String toBeAdded = untrackedParentFolders.getLast(); - while (!ret.isEmpty() && ret.getLast().startsWith(toBeAdded)) - ret.removeLast(); - ret.addLast(toBeAdded); + while (!ret.isEmpty() + && ret.get(ret.size() - 1).startsWith(toBeAdded)) { + ret.remove(ret.size() - 1); + } + ret.add(toBeAdded); } return ret; } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/io/UnionInputStream.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/io/UnionInputStream.java index b37f28b161..c3a1c4e3bb 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/io/UnionInputStream.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/io/UnionInputStream.java @@ -12,8 +12,9 @@ package org.eclipse.jgit.util.io; import java.io.IOException; import java.io.InputStream; +import java.util.ArrayDeque; +import java.util.Deque; import java.util.Iterator; -import java.util.LinkedList; /** * An InputStream which reads from one or more InputStreams. @@ -34,7 +35,7 @@ public class UnionInputStream extends InputStream { } }; - private final LinkedList streams = new LinkedList<>(); + private final Deque streams = new ArrayDeque<>(); /** * Create an empty InputStream that is currently at EOF state. diff --git a/tools/BUILD b/tools/BUILD index dbec43b7fa..38c7e7fb8f 100644 --- a/tools/BUILD +++ b/tools/BUILD @@ -222,7 +222,7 @@ java_package_configuration( "-Xep:JavaPeriodGetDays:ERROR", "-Xep:JavaTimeDefaultTimeZone:ERROR", "-Xep:JavaUtilDate:WARN", - "-Xep:JdkObsolete:WARN", + "-Xep:JdkObsolete:ERROR", "-Xep:JodaConstructors:ERROR", "-Xep:JodaDateTimeConstants:ERROR", "-Xep:JodaDurationWithMillis:ERROR", -- cgit v1.2.3 From 8a8e45dd27ff4b7cad0e2624e1b2bcce8b72ef72 Mon Sep 17 00:00:00 2001 From: Matthias Sohn Date: Sun, 28 Apr 2024 22:46:09 +0200 Subject: [errorprone] Fix pattern LongLiteralLowerCaseSuffix See https://errorprone.info/bugpattern/LongLiteralLowerCaseSuffix Change-Id: I139eadef5d66dfed2952ba9e1c91b3fe83259e97 --- .../tst/org/eclipse/jgit/revwalk/RevCommitParseTest.java | 4 ++-- .../tst/org/eclipse/jgit/transport/PushCertificateIdentTest.java | 4 ++-- .../org/eclipse/jgit/util/RawParseUtils_ParsePersonIdentTest.java | 6 +++--- tools/BUILD | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) (limited to 'tools') 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 82af34ded2..6872289a8b 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 class RevCommitParseTest extends RepositoryTestCase { 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/transport/PushCertificateIdentTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PushCertificateIdentTest.java index f5658abceb..cee023d5a9 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 class PushCertificateIdentTest { @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 class PushCertificateIdentTest { @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( 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 ee3ce8d98c..355bbbab16 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 class RawParseUtils_ParsePersonIdentTest { @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 class RawParseUtils_ParsePersonIdentTest { @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/tools/BUILD b/tools/BUILD index 38c7e7fb8f..2c7fd42732 100644 --- a/tools/BUILD +++ b/tools/BUILD @@ -251,7 +251,7 @@ java_package_configuration( "-Xep:LockOnBoxedPrimitive:ERROR", "-Xep:LogicalAssignment:ERROR", "-Xep:LongFloatConversion:ERROR", - "-Xep:LongLiteralLowerCaseSuffix:WARN", + "-Xep:LongLiteralLowerCaseSuffix:ERROR", "-Xep:LoopConditionChecker:ERROR", "-Xep:LoopOverCharArray:ERROR", "-Xep:LossyPrimitiveCompare:ERROR", -- cgit v1.2.3 From f1a9d25f40c30c8c0fc53cf1c811bde66abf11f0 Mon Sep 17 00:00:00 2001 From: Matthias Sohn Date: Mon, 29 Apr 2024 00:11:46 +0200 Subject: [errorprone] Fix pattern see UnusedVariable See https://errorprone.info/bugpattern/UnusedVariable Change-Id: I75d7602af31ed7d3264d2beab2d159cfbf29e7cb --- .../tst/org/eclipse/jgit/api/AddCommandTest.java | 17 +++++++++-------- .../org/eclipse/jgit/api/CommitAndLogCommandTest.java | 6 ++---- .../org/eclipse/jgit/api/PathCheckoutCommandTest.java | 8 ++++---- .../tst/org/eclipse/jgit/api/StashDropCommandTest.java | 6 ++---- .../org/eclipse/jgit/attributes/CGitAttributesTest.java | 3 +-- .../jgit/internal/storage/file/RefUpdateTest.java | 6 ++---- .../tst/org/eclipse/jgit/lib/ConfigTest.java | 10 ++++------ .../tst/org/eclipse/jgit/merge/MergerTest.java | 10 ++++++---- tools/BUILD | 2 +- 9 files changed, 31 insertions(+), 37 deletions(-) (limited to 'tools') 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 aa65985c55..3b0e184a42 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 @@ package org.eclipse.jgit.api; 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.assertNotEquals; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import static org.junit.Assume.assumeTrue; @@ -607,14 +608,14 @@ public class AddCommandTest extends RepositoryTestCase { try (Git git = new Git(db)) { DirCache dc = git.add().addFilepattern("a.txt").call(); - dc.getEntry(0).getObjectId(); + ObjectId oid = dc.getEntry(0).getObjectId(); try (PrintWriter writer = new PrintWriter(file, UTF_8.name())) { writer.print("other content"); } dc = git.add().addFilepattern("a.txt").call(); - + assertNotEquals(oid, dc.getEntry(0).getObjectId()); assertEquals( "[a.txt, mode:100644, content:other content]", indexState(CONTENT)); @@ -632,7 +633,7 @@ public class AddCommandTest extends RepositoryTestCase { try (Git git = new Git(db)) { DirCache dc = git.add().addFilepattern("a.txt").call(); - dc.getEntry(0).getObjectId(); + ObjectId oid = dc.getEntry(0).getObjectId(); git.commit().setMessage("commit a.txt").call(); @@ -641,7 +642,7 @@ public class AddCommandTest extends RepositoryTestCase { } dc = git.add().addFilepattern("a.txt").call(); - + assertNotEquals(oid, dc.getEntry(0).getObjectId()); assertEquals( "[a.txt, mode:100644, content:other content]", indexState(CONTENT)); @@ -659,12 +660,12 @@ public class AddCommandTest extends RepositoryTestCase { try (Git git = new Git(db)) { DirCache dc = git.add().addFilepattern("a.txt").call(); - dc.getEntry(0).getObjectId(); + ObjectId oid = dc.getEntry(0).getObjectId(); FileUtils.delete(file); // is supposed to do nothing dc = git.add().addFilepattern("a.txt").call(); - + assertEquals(oid, dc.getEntry(0).getObjectId()); assertEquals( "[a.txt, mode:100644, content:content]", indexState(CONTENT)); @@ -684,12 +685,12 @@ public class AddCommandTest extends RepositoryTestCase { git.commit().setMessage("commit a.txt").call(); - dc.getEntry(0).getObjectId(); + ObjectId oid = dc.getEntry(0).getObjectId(); FileUtils.delete(file); // is supposed to do nothing dc = git.add().addFilepattern("a.txt").call(); - + assertEquals(oid, dc.getEntry(0).getObjectId()); assertEquals( "[a.txt, mode:100644, content:content]", indexState(CONTENT)); 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 b7abba4209..57e5d4958f 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 class CommitAndLogCommandTest extends RepositoryTestCase { // 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); @@ -303,13 +302,12 @@ public class CommitAndLogCommandTest extends RepositoryTestCase { // 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); + 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/PathCheckoutCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PathCheckoutCommandTest.java index f52b715d39..cf952d2b77 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 class PathCheckoutCommandTest extends RepositoryTestCase { @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 class PathCheckoutCommandTest extends RepositoryTestCase { 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/StashDropCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/StashDropCommandTest.java index f9af968a7e..c81731d746 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 @@ -69,8 +69,7 @@ public class StashDropCommandTest extends RepositoryTestCase { RevCommit stashed = git.stashCreate().call(); assertNotNull(stashed); stashRef = git.getRepository().exactRef(Constants.R_STASH); - assertEquals(stashed, - git.getRepository().exactRef(Constants.R_STASH).getObjectId()); + assertEquals(stashed, stashRef.getObjectId()); try { assertNull(git.stashDrop().setStashRef(100).call()); fail("Exception not thrown"); @@ -88,8 +87,7 @@ public class StashDropCommandTest extends RepositoryTestCase { RevCommit stashed = git.stashCreate().call(); assertNotNull(stashed); stashRef = git.getRepository().exactRef(Constants.R_STASH); - assertEquals(stashed, - git.getRepository().exactRef(Constants.R_STASH).getObjectId()); + assertEquals(stashed, stashRef.getObjectId()); assertNull(git.stashDrop().call()); stashRef = git.getRepository().exactRef(Constants.R_STASH); assertNull(stashRef); 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 5638c1f7d9..562a515721 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 @@ public class CGitAttributesTest extends RepositoryTestCase { 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/internal/storage/file/RefUpdateTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/RefUpdateTest.java index 28d5ca726a..cb977bd601 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 class RefUpdateTest extends SampleDataRepositoryTestCase { @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 class RefUpdateTest extends SampleDataRepositoryTestCase { 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 class RefUpdateTest extends SampleDataRepositoryTestCase { @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 class RefUpdateTest extends SampleDataRepositoryTestCase { 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/lib/ConfigTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ConfigTest.java index 5c63c2df6b..31940a16f7 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 @@ -1567,7 +1567,6 @@ public class ConfigTest { @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")); @@ -1576,7 +1575,7 @@ public class ConfigTest { 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, @@ -1590,7 +1589,6 @@ public class ConfigTest { @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 @@ -1598,7 +1596,7 @@ public class ConfigTest { 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); @@ -1607,7 +1605,6 @@ public class ConfigTest { @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 @@ -1617,7 +1614,8 @@ public class ConfigTest { 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/merge/MergerTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/MergerTest.java index 3f99fe2b26..3a036acaca 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 @@ -1446,6 +1446,8 @@ public class MergerTest extends RepositoryTestCase { git.checkout().setName("master").call(); mergeResult = git.merge().include(commitX).setStrategy(strategy) .call(); + assertEquals(MergeResult.MergeStatus.MERGED, + mergeResult.getMergeStatus()); // Now, merge commit A and B (i.e. "master" and "second-branch"). // None of them have the file "a", so there is no conflict, BUT while @@ -1739,25 +1741,25 @@ public class MergerTest extends RepositoryTestCase { 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/tools/BUILD b/tools/BUILD index 2c7fd42732..90db119b4c 100644 --- a/tools/BUILD +++ b/tools/BUILD @@ -407,7 +407,7 @@ java_package_configuration( "-Xep:UnusedException:ERROR", "-Xep:UnusedMethod:WARN", "-Xep:UnusedNestedClass:ERROR", - "-Xep:UnusedVariable:WARN", + "-Xep:UnusedVariable:ERROR", "-Xep:URLEqualsHashCode:ERROR", "-Xep:UseBinds:ERROR", "-Xep:UseCorrectAssertInTests:WARN", -- cgit v1.2.3 From cdb43391b046cbb0d8ba008c0e038a46a8cc78d5 Mon Sep 17 00:00:00 2001 From: Matthias Sohn Date: Mon, 29 Apr 2024 00:29:30 +0200 Subject: [errorprone] Fix pattern CatchFail See https://errorprone.info/bugpattern/CatchFail Change-Id: If1c637a420c4e669a5bdbe4abcefc5c3a2b3a43b --- .../tst/org/eclipse/jgit/http/test/FileResolverTest.java | 4 ++-- .../tst/org/eclipse/jgit/api/RebaseCommandTest.java | 4 +++- .../tst/org/eclipse/jgit/dircache/DirCacheBuilderTest.java | 2 +- .../tst/org/eclipse/jgit/internal/storage/file/LockFileTest.java | 3 ++- .../tst/org/eclipse/jgit/lib/ThreadSafeProgressMonitorTest.java | 2 +- .../jgit/transport/UploadPackHandleDeletedPackFileTest.java | 6 +++--- .../tst/org/eclipse/jgit/util/FileUtilsTest.java | 8 ++++++-- org.eclipse.jgit.test/tst/org/eclipse/jgit/util/HookTest.java | 2 +- tools/BUILD | 2 +- 9 files changed, 20 insertions(+), 13 deletions(-) (limited to 'tools') 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 8d25c2e395..34c871ab06 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 class FileResolverTest extends LocalDiskRepositoryTestCase { 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 class FileResolverTest extends LocalDiskRepositoryTestCase { 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.test/tst/org/eclipse/jgit/api/RebaseCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/RebaseCommandTest.java index 987c98e232..02e3a2e06f 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 @@ -2650,7 +2650,9 @@ public class RebaseCommandTest extends RepositoryTestCase { 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/dircache/DirCacheBuilderTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache/DirCacheBuilderTest.java index 703d68b37c..61801106af 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 @@ public class DirCacheBuilderTest extends RepositoryTestCase { 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/file/LockFileTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/LockFileTest.java index 7eab1dcb09..953d624bfe 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,8 @@ public class LockFileTest extends RepositoryTestCase { 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/lib/ThreadSafeProgressMonitorTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ThreadSafeProgressMonitorTest.java index e21ff580bd..a5a6ce5d76 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 @@ public class ThreadSafeProgressMonitorTest { 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/transport/UploadPackHandleDeletedPackFileTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackHandleDeletedPackFileTest.java index 417ce61df2..118eb984d0 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackHandleDeletedPackFileTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackHandleDeletedPackFileTest.java @@ -9,10 +9,9 @@ */ package org.eclipse.jgit.transport; -import static org.junit.Assert.fail; import static org.eclipse.jgit.lib.Constants.HEAD; -import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import java.util.Arrays; import java.util.Collection; @@ -107,7 +106,8 @@ public class UploadPackHandleDeletedPackFileTest pack.getPackFile().create(packExt).delete(); } catch (Exception e) { - fail("GC or pack file removal failed"); + throw new AssertionError( + "GC or pack file removal failed", e); } return up; 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 2b1fb2ef04..5106540227 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,9 @@ public class FileUtilsTest { 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 +110,9 @@ public class FileUtilsTest { 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/HookTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/HookTest.java index 1231aefee0..b7490f0b1f 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 class HookTest extends RepositoryTestCase { 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/tools/BUILD b/tools/BUILD index 90db119b4c..22f6cf3571 100644 --- a/tools/BUILD +++ b/tools/BUILD @@ -76,7 +76,7 @@ java_package_configuration( "-Xep:CannotMockFinalClass:ERROR", "-Xep:CanonicalDuration:ERROR", "-Xep:CatchAndPrintStackTrace:WARN", - "-Xep:CatchFail:WARN", + "-Xep:CatchFail:ERROR", "-Xep:ChainedAssertionLosesContext:ERROR", "-Xep:ChainingConstructorIgnoresParameter:ERROR", "-Xep:CharacterGetNumericValue:ERROR", -- cgit v1.2.3 From 1d253988076e8848b8e30141229624cfc7b62c06 Mon Sep 17 00:00:00 2001 From: Matthias Sohn Date: Mon, 29 Apr 2024 00:42:46 +0200 Subject: [errorprone] Fix pattern ProtectedMembersInFinalClass See https://errorprone.info/bugpattern/ProtectedMembersInFinalClass Change-Id: I5993093ca012f091dfe8ee1f2099b9596c2ee697 --- .../tst/org/eclipse/jgit/util/http/HttpCookiesMatcher.java | 2 +- tools/BUILD | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'tools') 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 18faab5c9f..c1c72804da 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 @@ public final class HttpCookiesMatcher { } @SuppressWarnings("boxing") - protected static void describeCookie(Description description, + private static void describeCookie(Description description, HttpCookie cookie) { description.appendText("HttpCookie["); description.appendText("name: ").appendValue(cookie.getName()) diff --git a/tools/BUILD b/tools/BUILD index 22f6cf3571..9cb24aa361 100644 --- a/tools/BUILD +++ b/tools/BUILD @@ -323,7 +323,7 @@ java_package_configuration( "-Xep:PreferredInterfaceType:OFF", "-Xep:PrimitiveAtomicReference:ERROR", "-Xep:PrivateSecurityContractProtoAccess:ERROR", - "-Xep:ProtectedMembersInFinalClass:WARN", + "-Xep:ProtectedMembersInFinalClass:ERROR", "-Xep:ProtoBuilderReturnValueIgnored:ERROR", "-Xep:ProtocolBufferOrdinal:ERROR", "-Xep:ProtoDurationGetSecondsGetNano:ERROR", -- cgit v1.2.3 From 07e77293b1e84fddfdc5edbb378021a93427c971 Mon Sep 17 00:00:00 2001 From: Matthias Sohn Date: Mon, 29 Apr 2024 00:55:54 +0200 Subject: [errorprone] Fix pattern UseCorrectAssertInTests See https://errorprone.info/bugpattern/UseCorrectAssertInTests Change-Id: Iffde63ac795ad30c3e7774764cb8189cb089ed86 --- .../tst/org/eclipse/jgit/api/AddCommandTest.java | 8 +++++--- tools/BUILD | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'tools') 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 3b0e184a42..1c2e995bbb 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 @@ -14,6 +14,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.assertNotEquals; +import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import static org.junit.Assume.assumeTrue; @@ -879,7 +880,7 @@ public class AddCommandTest extends RepositoryTestCase { } } // 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. @@ -1260,7 +1261,7 @@ public class AddCommandTest extends RepositoryTestCase { "[git-link-dir, mode:160000]", indexState(0)); Set untrackedFiles = git.status().call().getUntracked(); - assert untrackedFiles.isEmpty(); + assertTrue(untrackedFiles.isEmpty()); } } @@ -1275,7 +1276,8 @@ public class AddCommandTest extends RepositoryTestCase { 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/tools/BUILD b/tools/BUILD index 9cb24aa361..546ca34b1a 100644 --- a/tools/BUILD +++ b/tools/BUILD @@ -410,7 +410,7 @@ java_package_configuration( "-Xep:UnusedVariable:ERROR", "-Xep:URLEqualsHashCode:ERROR", "-Xep:UseBinds:ERROR", - "-Xep:UseCorrectAssertInTests:WARN", + "-Xep:UseCorrectAssertInTests:ERROR", "-Xep:VariableNameSameAsType:ERROR", "-Xep:VarTypeName:ERROR", "-Xep:WaitNotInLoop:ERROR", -- cgit v1.2.3 From 85602eaa98aefefdf023317db02f774a80bfeda4 Mon Sep 17 00:00:00 2001 From: Matthias Sohn Date: Mon, 29 Apr 2024 01:11:16 +0200 Subject: [errorprone] Fix pattern BadImport See https://errorprone.info/bugpattern/BadImport Change-Id: I24e5a7a4a64d8b3cf2cc3d394090ce90e849f9f9 --- .../tst/org/eclipse/jgit/internal/storage/file/GcConcurrentTest.java | 5 ++--- .../tst/org/eclipse/jgit/lib/ObjectCheckerTest.java | 3 +-- .../tst/org/eclipse/jgit/patch/PatchCcErrorTest.java | 5 ++--- .../tst/org/eclipse/jgit/transport/SideBandOutputStreamTest.java | 4 ++-- tools/BUILD | 2 +- 5 files changed, 8 insertions(+), 11 deletions(-) (limited to 'tools') 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 96a064989b..8c1b4f7b65 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 class GcConcurrentTest extends GcTestCase { 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 class GcConcurrentTest extends GcTestCase { } catch (InterruptedException ignored) { // } - return valueOf(1); + return Integer.valueOf(1); } } } 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 5c44c9c44d..3ec4b6a073 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 class ObjectCheckerTest { 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/patch/PatchCcErrorTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/patch/PatchCcErrorTest.java index 71bda46ee5..8335c07b1f 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 class PatchCcErrorTest { 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 class PatchCcErrorTest { 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/transport/SideBandOutputStreamTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/SideBandOutputStreamTest.java index 3516ed01fc..444e958ae8 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,8 @@ public class SideBandOutputStreamTest { } 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/tools/BUILD b/tools/BUILD index 546ca34b1a..14e15795c7 100644 --- a/tools/BUILD +++ b/tools/BUILD @@ -62,7 +62,7 @@ java_package_configuration( "-Xep:AutoValueSubclassLeaked:WARN", "-Xep:BadAnnotationImplementation:ERROR", "-Xep:BadComparable:ERROR", - "-Xep:BadImport:WARN", + "-Xep:BadImport:ERROR", "-Xep:BadInstanceof:ERROR", "-Xep:BadShiftAmount:ERROR", "-Xep:BanSerializableRead:ERROR", -- cgit v1.2.3 From 8bc7f38489438251c1cf35eff3a2db1fd0bfa553 Mon Sep 17 00:00:00 2001 From: Matthias Sohn Date: Mon, 29 Apr 2024 01:37:28 +0200 Subject: [errorprone] Fix pattern FutureReturnValueIgnored See https://errorprone.info/bugpattern/FutureReturnValueIgnored Change-Id: I7225fd6388ce70ed5eea9e61b29bd10e1a927acb --- .../org/eclipse/jgit/internal/storage/file/GcKeepFilesTest.java | 8 ++++---- .../eclipse/jgit/internal/storage/pack/GcCommitSelectionTest.java | 4 ++-- .../jgit/transport/UploadPackHandleDeletedPackFileTest.java | 4 ++-- tools/BUILD | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) (limited to 'tools') 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 9a2935f136..e1b6778c0e 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 class GcKeepFilesTest extends GcTestCase { 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 @@ public class GcKeepFilesTest extends GcTestCase { .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 @@ public class GcKeepFilesTest extends GcTestCase { 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 @@ public class GcKeepFilesTest extends GcTestCase { .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/pack/GcCommitSelectionTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/pack/GcCommitSelectionTest.java index 0c09ad1510..ecf9a15b03 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 class GcCommitSelectionTest extends GcTestCase { 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 class GcCommitSelectionTest extends GcTestCase { 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/transport/UploadPackHandleDeletedPackFileTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackHandleDeletedPackFileTest.java index 118eb984d0..097b84974f 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackHandleDeletedPackFileTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackHandleDeletedPackFileTest.java @@ -102,7 +102,7 @@ public class UploadPackHandleDeletedPackFileTest try { addNewCommit(); - new GC(remote.getRepository()).gc(); + new GC(remote.getRepository()).gc().get(); pack.getPackFile().create(packExt).delete(); } catch (Exception e) { @@ -136,7 +136,7 @@ public class UploadPackHandleDeletedPackFileTest .create(); remote.update("master", commit0); - new GC(remote.getRepository()).gc(); // create pack files + new GC(remote.getRepository()).gc().get(); // create pack files head = remote.commit().message("1").parent(commit0) .add("test1.txt", remote.blob("1")) diff --git a/tools/BUILD b/tools/BUILD index 14e15795c7..4c3bffb9d2 100644 --- a/tools/BUILD +++ b/tools/BUILD @@ -158,7 +158,7 @@ java_package_configuration( "-Xep:FromTemporalAccessor:ERROR", "-Xep:FunctionalInterfaceClash:ERROR", "-Xep:FunctionalInterfaceMethodChanged:ERROR", - "-Xep:FutureReturnValueIgnored:WARN", + "-Xep:FutureReturnValueIgnored:ERROR", "-Xep:FuturesGetCheckedIllegalExceptionType:ERROR", "-Xep:GetClassOnAnnotation:ERROR", "-Xep:GetClassOnClass:ERROR", -- cgit v1.2.3 From cfe948ac7022510f47e22ee3c9d2f4ae3681b55c Mon Sep 17 00:00:00 2001 From: Matthias Sohn Date: Mon, 29 Apr 2024 01:54:01 +0200 Subject: [errorprone] Fix pattern CatchAndPrintStackTrace See https://errorprone.info/bugpattern/CatchAndPrintStackTrace Change-Id: I7a6698293d1485f384c275bf7e4dcddc529af4a1 --- .../attributes/merge/MergeGitAttributeTest.java | 25 +++++++++++----------- tools/BUILD | 2 +- 2 files changed, 14 insertions(+), 13 deletions(-) (limited to 'tools') 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 6b23de3320..009ca8a152 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 @@ -19,6 +19,7 @@ import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; +import java.io.UncheckedIOException; import java.nio.file.Files; import java.util.function.Consumer; @@ -97,19 +98,19 @@ public class MergeGitAttributeTest extends RepositoryTestCase { try { writeTrashFile("main.cat", "A\n" + "B\n" + "C\n" + "D\n"); } catch (IOException e) { - e.printStackTrace(); + throw new UncheckedIOException(e); } }, g -> { try { writeTrashFile("main.cat", "A\n" + "B\n" + "C\n" + "F\n"); } catch (IOException e) { - e.printStackTrace(); + throw new UncheckedIOException(e); } }, g -> { try { writeTrashFile("main.cat", "A\n" + "E\n" + "C\n" + "D\n"); } catch (IOException e) { - e.printStackTrace(); + throw new UncheckedIOException(e); } })) { checkoutBranch(REFS_HEADS_LEFT); @@ -139,19 +140,19 @@ public class MergeGitAttributeTest extends RepositoryTestCase { writeTrashFile(".gitattributes", "*.cat -merge"); writeTrashFile("main.cat", "A\n" + "B\n" + "C\n" + "D\n"); } catch (IOException e) { - e.printStackTrace(); + throw new UncheckedIOException(e); } }, g -> { try { writeTrashFile("main.cat", "A\n" + "B\n" + "C\n" + "F\n"); } catch (IOException e) { - e.printStackTrace(); + throw new UncheckedIOException(e); } }, g -> { try { writeTrashFile("main.cat", "A\n" + "E\n" + "C\n" + "D\n"); } catch (IOException e) { - e.printStackTrace(); + throw new UncheckedIOException(e); } })) { // Check that the merge attribute is unset @@ -184,19 +185,19 @@ public class MergeGitAttributeTest extends RepositoryTestCase { writeTrashFile(".gitattributes", "*.txt -merge"); writeTrashFile("main.cat", "A\n" + "B\n" + "C\n" + "D\n"); } catch (IOException e) { - e.printStackTrace(); + throw new UncheckedIOException(e); } }, g -> { try { writeTrashFile("main.cat", "A\n" + "B\n" + "C\n" + "F\n"); } catch (IOException e) { - e.printStackTrace(); + throw new UncheckedIOException(e); } }, g -> { try { writeTrashFile("main.cat", "A\n" + "E\n" + "C\n" + "D\n"); } catch (IOException e) { - e.printStackTrace(); + throw new UncheckedIOException(e); } })) { // Check that the merge attribute is unset @@ -228,19 +229,19 @@ public class MergeGitAttributeTest extends RepositoryTestCase { writeTrashFile(".gitattributes", "*.cat merge=binary"); writeTrashFile("main.cat", "A\n" + "B\n" + "C\n" + "D\n"); } catch (IOException e) { - e.printStackTrace(); + throw new UncheckedIOException(e); } }, g -> { try { writeTrashFile("main.cat", "A\n" + "B\n" + "C\n" + "F\n"); } catch (IOException e) { - e.printStackTrace(); + throw new UncheckedIOException(e); } }, g -> { try { writeTrashFile("main.cat", "A\n" + "E\n" + "C\n" + "D\n"); } catch (IOException e) { - e.printStackTrace(); + throw new UncheckedIOException(e); } })) { // Check that the merge attribute is set to binary diff --git a/tools/BUILD b/tools/BUILD index 4c3bffb9d2..17ff5afb5d 100644 --- a/tools/BUILD +++ b/tools/BUILD @@ -75,7 +75,7 @@ java_package_configuration( "-Xep:CacheLoaderNull:ERROR", "-Xep:CannotMockFinalClass:ERROR", "-Xep:CanonicalDuration:ERROR", - "-Xep:CatchAndPrintStackTrace:WARN", + "-Xep:CatchAndPrintStackTrace:ERROR", "-Xep:CatchFail:ERROR", "-Xep:ChainedAssertionLosesContext:ERROR", "-Xep:ChainingConstructorIgnoresParameter:ERROR", -- cgit v1.2.3 From a82cc38a981bececf7ca732317d444e8d37a3d1b Mon Sep 17 00:00:00 2001 From: Matthias Sohn Date: Mon, 29 Apr 2024 02:16:23 +0200 Subject: [errorprone] Fix pattern ModifiedButNotUsed See https://errorprone.info/bugpattern/ModifiedButNotUsed Change-Id: I3bd3f865d50a26af6c594391de5adf35230c984f --- org.eclipse.jgit.test/tst/org/eclipse/jgit/util/BlockListTest.java | 2 ++ org.eclipse.jgit.test/tst/org/eclipse/jgit/util/RefMapTest.java | 2 ++ tools/BUILD | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) (limited to 'tools') 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 a270ca8861..b8b9cbe558 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 @@ -296,6 +296,7 @@ public class BlockListTest { public void testAddRejectsBadIndexes() { BlockList list = new BlockList<>(4); list.add(Integer.valueOf(41)); + assertEquals(Integer.valueOf(41), list.get(0)); try { list.add(-1, Integer.valueOf(42)); @@ -316,6 +317,7 @@ public class BlockListTest { public void testRemoveRejectsBadIndexes() { BlockList list = new BlockList<>(4); list.add(Integer.valueOf(41)); + assertEquals(Integer.valueOf(41), list.get(0)); try { list.remove(-1); 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 627417d462..a8077fdb0c 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 @@ -268,6 +268,7 @@ public class RefMapTest { assertFalse(itr.hasNext()); } + @SuppressWarnings("ModifiedButNotUsed") @Test public void testPut_KeyMustMatchName_NoPrefix() { final Ref refA = newRef("refs/heads/A", ID_ONE); @@ -280,6 +281,7 @@ public class RefMapTest { } } + @SuppressWarnings("ModifiedButNotUsed") @Test public void testPut_KeyMustMatchName_WithPrefix() { final Ref refA = newRef("refs/heads/A", ID_ONE); diff --git a/tools/BUILD b/tools/BUILD index 17ff5afb5d..2ad281e64a 100644 --- a/tools/BUILD +++ b/tools/BUILD @@ -270,7 +270,7 @@ java_package_configuration( "-Xep:MixedDescriptors:ERROR", "-Xep:MixedMutabilityReturnType:WARN", "-Xep:MockitoUsage:ERROR", - "-Xep:ModifiedButNotUsed:WARN", + "-Xep:ModifiedButNotUsed:ERROR", "-Xep:ModifyCollectionInEnhancedForLoop:ERROR", "-Xep:ModifyingCollectionWithItself:ERROR", "-Xep:ModifySourceCollectionInStream:ERROR", -- cgit v1.2.3 From 98f329e93791a49068adc0bc2f5c81234fe2d943 Mon Sep 17 00:00:00 2001 From: David Ostrovsky Date: Tue, 17 Oct 2023 09:47:35 +0200 Subject: Bazel: Add support for JDK 21 There are two failing tests when switching to JDK 21. One failure is related to the changed behaviour related to the locale providers. Adapt `GitDateFormatterTest` to changes in unicode [1]. Second failure related to changed behaviour in URL.openConnection(), see: [2] for more details. Before JDK 20, some of the parsing/validation performed by the JDK built-in URLStreamHander implementations were delayed until URL::openConnection or URLConnection::connect was called. Starting JDK 20, some of these parsing/validations are now performed early, i.e. within URL constructors. IOW, the assumption made in HttpSupport.TesttestMalformedUri() isn't met any more: providing mailformed URI to the URL ctor now throws an exception starting with JDK 20. To rectify the problem, remove the offending test. Test plan: To build with JDK 21 and run the tests locally: $> bazel test --config=java21 //... To build with JDK 21 and run the tests on RBE: $> bazel test --config=remote21 --remote_instance_name=$PROJECT //... [1] https://bugs.openjdk.org/browse/JDK-8304925 [2] https://bugs.openjdk.org/browse/JDK-8293590 Change-Id: I796de67f7945d5f1fa5e8146f4ec8cbe9ac7bd3e --- .bazelrc | 15 ++++++++++++++- WORKSPACE | 20 ++++++++++++++++++++ .../org/eclipse/jgit/util/GitDateFormatterTest.java | 8 ++++++-- .../tst/org/eclipse/jgit/util/HttpSupportTest.java | 12 ------------ tools/BUILD | 14 +++++++++++++- 5 files changed, 53 insertions(+), 16 deletions(-) (limited to 'tools') diff --git a/.bazelrc b/.bazelrc index 51be79be28..7c71c4a9d0 100644 --- a/.bazelrc +++ b/.bazelrc @@ -21,7 +21,7 @@ build:remote11 --tool_java_language_version=11 build:remote11 --tool_java_runtime_version=remotejdk_11 build:remote11 --config=remote -# Builds using remote_jdk17, executes using remote_jdk11 or local_jdk +# Builds using remote_jdk17, executes using remote_jdk17 or local_jdk build:java17 --java_language_version=17 build:java17 --java_runtime_version=remotejdk_17 build:java17 --tool_java_language_version=17 @@ -34,6 +34,19 @@ build:remote17 --tool_java_language_version=17 build:remote17 --tool_java_runtime_version=remotejdk_17 build:remote17 --config=remote +# Builds using remote_jdk21, executes using remote_jdk21 or local_jdk +build:java21 --java_language_version=21 +build:java21 --java_runtime_version=remotejdk_21 +build:java21 --tool_java_language_version=21 +build:java21 --tool_java_runtime_version=remotejdk_21 + +# Builds and executes on RBE using remotejdk_21 +build:remote21 --java_language_version=21 +build:remote21 --java_runtime_version=remotejdk_21 +build:remote21 --tool_java_language_version=21 +build:remote21 --tool_java_runtime_version=remotejdk_21 +build:remote21 --config=remote + test --build_tests_only test --test_output=errors test --flaky_test_attempts=3 diff --git a/WORKSPACE b/WORKSPACE index b0d0ea01f0..07d4d5cd03 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -10,6 +10,18 @@ load( "maven_jar", ) +http_archive( + name = "rules_java", + sha256 = "4da3761f6855ad916568e2bfe86213ba6d2637f56b8360538a7fb6125abf6518", + urls = [ + "https://github.com/bazelbuild/rules_java/releases/download/7.5.0/rules_java-7.5.0.tar.gz", + ], +) + +load("@rules_java//java:repositories.bzl", "rules_java_dependencies", "rules_java_toolchains") + +rules_java_dependencies() + http_archive( name = "ubuntu2204_jdk17", sha256 = "8ea82b81c9707e535ff93ef5349d11e55b2a23c62bcc3b0faaec052144aed87d", @@ -24,6 +36,14 @@ register_toolchains("//tools:error_prone_warnings_toolchain_java11_definition") register_toolchains("//tools:error_prone_warnings_toolchain_java17_definition") +register_toolchains("//tools:error_prone_warnings_toolchain_java21_definition") + +# Order of registering toolchains matters. rules_java toolchains take precedence +# over the custom toolchains, so the default jdk21 toolchain gets picked +# (one without custom package_config). That's why the `rules_java_toolchains()` +# must be called after the `register_toolchain()` invocation. +rules_java_toolchains() + JMH_VERS = "1.37" maven_jar( diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/GitDateFormatterTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/GitDateFormatterTest.java index 0bd7e0bd61..6a531fe0e6 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/GitDateFormatterTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/GitDateFormatterTest.java @@ -89,15 +89,19 @@ public class GitDateFormatterTest { @Test public void LOCALE() { String date = new GitDateFormatter(Format.LOCALE).formatDate(ident); + System.out.println(date); assertTrue("Sep 20, 2011 7:09:25 PM -0400".equals(date) - || "Sep 20, 2011, 7:09:25 PM -0400".equals(date)); // JDK-8206961 + || "Sep 20, 2011, 7:09:25 PM -0400".equals(date) // JDK-8206961 + || "Sep 20, 2011, 7:09:25\u202FPM -0400".equals(date)); // JDK-8304925 } @Test public void LOCALELOCAL() { String date = new GitDateFormatter(Format.LOCALELOCAL) .formatDate(ident); + System.out.println(date); assertTrue("Sep 20, 2011 7:39:25 PM".equals(date) - || "Sep 20, 2011, 7:39:25 PM".equals(date)); // JDK-8206961 + || "Sep 20, 2011, 7:39:25 PM".equals(date) // JDK-8206961 + || "Sep 20, 2011, 7:39:25\u202FPM".equals(date)); // JDK-8304925 } } diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/HttpSupportTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/HttpSupportTest.java index cbe4eb2eb0..a3a5697ef4 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/HttpSupportTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/HttpSupportTest.java @@ -46,18 +46,6 @@ public class HttpSupportTest { } } - @Test - public void testMalformedUri() throws Exception { - // Valid URL, but backslash is not allowed in a URI in the userinfo part - // per RFC 3986: https://tools.ietf.org/html/rfc3986#section-3.2.1 . - // Test that conversion to URI to call the ProxySelector does not throw - // an exception. - Proxy proxy = HttpSupport.proxyFor(new TestProxySelector(), new URL( - "http://infor\\c.jones@somehost/somewhere/someproject.git")); - assertNotNull(proxy); - assertEquals(Proxy.Type.HTTP, proxy.type()); - } - @Test public void testCorrectUri() throws Exception { // Backslash escaped as %5C is correct. diff --git a/tools/BUILD b/tools/BUILD index 2ad281e64a..c7ec638645 100644 --- a/tools/BUILD +++ b/tools/BUILD @@ -17,7 +17,7 @@ default_java_toolchain( default_java_toolchain( name = "error_prone_warnings_toolchain_java17", configuration = dict(), - java_runtime = "@bazel_tools//tools/jdk:remotejdk_17", + java_runtime = "@rules_java//toolchains:remotejdk_17", package_configuration = [ ":error_prone", ], @@ -26,6 +26,18 @@ default_java_toolchain( visibility = ["//visibility:public"], ) +default_java_toolchain( + name = "error_prone_warnings_toolchain_java21", + configuration = dict(), + java_runtime = "@rules_java//toolchains:remotejdk_21", + package_configuration = [ + ":error_prone", + ], + source_version = "21", + target_version = "21", + visibility = ["//visibility:public"], +) + # Error Prone errors enabled by default; see ../.bazelrc for how this is # enabled. This warnings list is originally based on: # https://github.com/bazelbuild/BUILD_file_generator/blob/master/tools/bazel_defs/java.bzl -- cgit v1.2.3