From 62d16a9146010e0ade2d543d37bd094122a28e5e Mon Sep 17 00:00:00 2001 From: David Pursehouse Date: Thu, 5 Dec 2019 09:42:52 +0900 Subject: [PATCH 1/2] MergedReftable: Remove unnecessary semicolon Change-Id: I67d2b8ba3cd8f94363cea864918c8ed6026f2d18 Signed-off-by: David Pursehouse --- .../eclipse/jgit/internal/storage/reftable/MergedReftable.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/MergedReftable.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/MergedReftable.java index 6c312ca7a..0144453cd 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/MergedReftable.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/MergedReftable.java @@ -104,7 +104,7 @@ public class MergedReftable extends Reftable { boolean has = true; for (int i = 0; has && i < tables.length; i++) { has = has && tables[i].hasObjectMap(); - }; + } return has; } From b24ec8f7159469340e4519b42bf5a57a44b75c38 Mon Sep 17 00:00:00 2001 From: David Pursehouse Date: Thu, 5 Dec 2019 09:54:14 +0900 Subject: [PATCH 2/2] ReftableTest: Clean up boxing warnings on usage of String.format Passing int as an argument to String.format causes a warning: The expression of type int is boxed into Integer Most of these are already suppressed, but there are a couple that are not. Add suppressions for those. For the existing ones, move the suppression scope from the method to the actual usage. Where necessary extract the usage out to a local variable. Change-Id: I7a7ff6dec49467e4b5c58d27a231c74e6e1c5437 Signed-off-by: David Pursehouse --- .../storage/reftable/ReftableTest.java | 42 ++++++++++++------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/reftable/ReftableTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/reftable/ReftableTest.java index daf540c41..ec8b7593f 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/reftable/ReftableTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/reftable/ReftableTest.java @@ -149,12 +149,13 @@ public class ReftableTest { assertEquals(expBytes, table.length); } - @SuppressWarnings("boxing") @Test public void estimateCurrentBytesWithIndex() throws IOException { List refs = new ArrayList<>(); for (int i = 1; i <= 5670; i++) { - refs.add(ref(String.format("refs/heads/%04d", i), i)); + @SuppressWarnings("boxing") + Ref ref = ref(String.format("refs/heads/%04d", i), i); + refs.add(ref); } ReftableConfig cfg = new ReftableConfig(); @@ -229,7 +230,9 @@ public class ReftableTest { // Fill up 5 blocks. int N = 256 * 5 / 25; for (int i= 0; i < N; i++) { - refs.add(ref(String.format("%02d/xxxxxxxxxx", i), i)); + @SuppressWarnings("boxing") + Ref ref = ref(String.format("%02d/xxxxxxxxxx", i), i); + refs.add(ref); } byte[] table = write(refs, cfg); @@ -425,12 +428,13 @@ public class ReftableTest { } } - @SuppressWarnings("boxing") @Test public void indexScan() throws IOException { List refs = new ArrayList<>(); for (int i = 1; i <= 5670; i++) { - refs.add(ref(String.format("refs/heads/%04d", i), i)); + @SuppressWarnings("boxing") + Ref ref = ref(String.format("refs/heads/%04d", i), i); + refs.add(ref); } byte[] table = write(refs); @@ -439,12 +443,13 @@ public class ReftableTest { assertScan(refs, read(table)); } - @SuppressWarnings("boxing") @Test public void indexSeek() throws IOException { List refs = new ArrayList<>(); for (int i = 1; i <= 5670; i++) { - refs.add(ref(String.format("refs/heads/%04d", i), i)); + @SuppressWarnings("boxing") + Ref ref = ref(String.format("refs/heads/%04d", i), i); + refs.add(ref); } byte[] table = write(refs); @@ -453,12 +458,13 @@ public class ReftableTest { assertSeek(refs, read(table)); } - @SuppressWarnings("boxing") @Test public void noIndexScan() throws IOException { List refs = new ArrayList<>(); for (int i = 1; i <= 567; i++) { - refs.add(ref(String.format("refs/heads/%03d", i), i)); + @SuppressWarnings("boxing") + Ref ref = ref(String.format("refs/heads/%03d", i), i); + refs.add(ref); } byte[] table = write(refs); @@ -468,12 +474,13 @@ public class ReftableTest { assertScan(refs, read(table)); } - @SuppressWarnings("boxing") @Test public void noIndexSeek() throws IOException { List refs = new ArrayList<>(); for (int i = 1; i <= 567; i++) { - refs.add(ref(String.format("refs/heads/%03d", i), i)); + @SuppressWarnings("boxing") + Ref ref = ref(String.format("refs/heads/%03d", i), i); + refs.add(ref); } byte[] table = write(refs); @@ -646,6 +653,7 @@ public class ReftableTest { // Fill out the 1st ref block. List names = new ArrayList<>(); for (int i = 0; i < 4; i++) { + @SuppressWarnings("boxing") String name = new String(new char[220]).replace("\0", String.format("%c", i + 'a')); names.add(name); writer.writeRef(ref(name, i)); @@ -785,7 +793,6 @@ public class ReftableTest { } } - @SuppressWarnings("boxing") @Test public void logScan() throws IOException { ReftableConfig cfg = new ReftableConfig(); @@ -798,6 +805,7 @@ public class ReftableTest { List refs = new ArrayList<>(); for (int i = 1; i <= 5670; i++) { + @SuppressWarnings("boxing") Ref ref = ref(String.format("refs/heads/%04d", i), i); refs.add(ref); writer.writeRef(ref); @@ -830,12 +838,13 @@ public class ReftableTest { } } - @SuppressWarnings("boxing") @Test public void byObjectIdOneRefNoIndex() throws IOException { List refs = new ArrayList<>(); for (int i = 1; i <= 200; i++) { - refs.add(ref(String.format("refs/heads/%02d", i), i)); + @SuppressWarnings("boxing") + Ref ref = ref(String.format("refs/heads/%02d", i), i); + refs.add(ref); } refs.add(ref("refs/heads/master", 100)); @@ -863,12 +872,13 @@ public class ReftableTest { } } - @SuppressWarnings("boxing") @Test public void byObjectIdOneRefWithIndex() throws IOException { List refs = new ArrayList<>(); for (int i = 1; i <= 5200; i++) { - refs.add(ref(String.format("refs/heads/%02d", i), i)); + @SuppressWarnings("boxing") + Ref ref = ref(String.format("refs/heads/%02d", i), i); + refs.add(ref); } refs.add(ref("refs/heads/master", 100));