]> source.dussan.org Git - jgit.git/commitdiff
reftable: remove assert calls 26/151426/2
authorHan-Wen Nienhuys <hanwen@google.com>
Tue, 22 Oct 2019 09:56:45 +0000 (11:56 +0200)
committerHan-Wen Nienhuys <hanwen@google.com>
Tue, 22 Oct 2019 09:59:24 +0000 (11:59 +0200)
The effect of assert is defined by compiler flags, so this code
introduced a potential vector for corruption.

Change-Id: I12197432e4351a5bd4aa24d352a19937721845c3
Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsReftableDatabase.java
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/ReftableDatabase.java

index 2497719196127cccab010c4f91215a61921c7359..2ad3ae7e62df969560a9a1764ac08e1bfffa8f12 100644 (file)
@@ -163,7 +163,9 @@ public class DfsReftableDatabase extends DfsRefDatabase {
         *             if tables cannot be opened.
         */
        protected DfsReftableStack stack() throws IOException {
-               assert getLock().isLocked();
+               if (!getLock().isLocked()) {
+                       throw new IllegalStateException("most hold lock to access stack"); //$NON-NLS-1$
+               }
                DfsObjDatabase odb = getRepository().getObjectDatabase();
 
                if (ctx == null) {
index ce6ddb9cc69e7ef50a31516544b7492b3e5bf64e..2753c0280033c554c7563cc2dbb2f949c466e347 100644 (file)
@@ -138,7 +138,10 @@ public abstract class ReftableDatabase {
         *             on I/O problems
         */
        private Reftable reader() throws IOException {
-               assert lock.isLocked();
+               if (!lock.isLocked()) {
+                       throw new IllegalStateException(
+                                       "must hold lock to access merged table"); //$NON-NLS-1$
+               }
                if (mergedTables == null) {
                        mergedTables = openMergedReftable();
                }