summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2024-04-29 00:29:30 +0200
committerMatthias Sohn <matthias.sohn@sap.com>2024-04-29 15:20:39 +0200
commitcdb43391b046cbb0d8ba008c0e038a46a8cc78d5 (patch)
tree65be06186c0c31e29186cbf532e41da8184cad7a
parentf1a9d25f40c30c8c0fc53cf1c811bde66abf11f0 (diff)
downloadjgit-cdb43391b046cbb0d8ba008c0e038a46a8cc78d5.tar.gz
jgit-cdb43391b046cbb0d8ba008c0e038a46a8cc78d5.zip
[errorprone] Fix pattern CatchFail
See https://errorprone.info/bugpattern/CatchFail Change-Id: If1c637a420c4e669a5bdbe4abcefc5c3a2b3a43b
-rw-r--r--org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/FileResolverTest.java4
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/api/RebaseCommandTest.java4
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache/DirCacheBuilderTest.java2
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/LockFileTest.java3
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ThreadSafeProgressMonitorTest.java2
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackHandleDeletedPackFileTest.java6
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/util/FileUtilsTest.java8
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/util/HookTest.java2
-rw-r--r--tools/BUILD2
9 files changed, 20 insertions, 13 deletions
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",