diff options
author | Matthias Sohn <matthias.sohn@sap.com> | 2021-05-11 01:00:31 +0200 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2021-05-11 01:00:31 +0200 |
commit | cf76a92e0484161e657f394e7ce75db8a8b1d9ef (patch) | |
tree | 1e5f80190b8b665db0d3d1534b9e5a9f7d6f1fdf | |
parent | e6192c56af76189c27096ad81b38a4b64b250a26 (diff) | |
parent | 1aff4369b0152daa583b9f245f2c049f2108c040 (diff) | |
download | jgit-cf76a92e0484161e657f394e7ce75db8a8b1d9ef.tar.gz jgit-cf76a92e0484161e657f394e7ce75db8a8b1d9ef.zip |
Merge branch 'stable-5.12'
* stable-5.12:
LockFile: create OutputStream only when needed
Remove ReftableNumbersNotIncreasingException
Change-Id: I9d85187d00771beef908f1136015d059024f4118
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileReftableStack.java | 37 | ||||
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/LockFile.java | 24 |
2 files changed, 12 insertions, 49 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileReftableStack.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileReftableStack.java index b5e3927bcc..f02c8613a0 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileReftableStack.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileReftableStack.java @@ -131,33 +131,6 @@ public class FileReftableStack implements AutoCloseable { return stats; } - /** Thrown if the update indices in the stack are not monotonic */ - public static class ReftableNumbersNotIncreasingException - extends RuntimeException { - private static final long serialVersionUID = 1L; - - String name; - - long lastMax; - - long min; - - ReftableNumbersNotIncreasingException(String name, long lastMax, - long min) { - this.name = name; - this.lastMax = lastMax; - this.min = min; - } - - @SuppressWarnings({ "nls", "boxing" }) - @Override - public String toString() { - return String.format( - "ReftableNumbersNotIncreasingException %s: min %d, lastMax %d", - name, min, lastMax); - } - } - /** * Reloads the stack, potentially reusing opened reftableReaders. * @@ -176,7 +149,6 @@ public class FileReftableStack implements AutoCloseable { List<ReftableReader> newTables = new ArrayList<>(); List<StackEntry> newStack = new ArrayList<>(stack.size() + 1); try { - ReftableReader last = null; for (String name : names) { StackEntry entry = new StackEntry(); entry.name = name; @@ -194,15 +166,6 @@ public class FileReftableStack implements AutoCloseable { newTables.add(t); } - if (last != null) { - // TODO: move this to MergedReftable - if (last.maxUpdateIndex() >= t.minUpdateIndex()) { - throw new ReftableNumbersNotIncreasingException(name, - last.maxUpdateIndex(), t.minUpdateIndex()); - } - } - last = t; - entry.reftableReader = t; newStack.add(entry); } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/LockFile.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/LockFile.java index ab407a6ae9..f57581a299 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/LockFile.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/LockFile.java @@ -218,14 +218,14 @@ public class LockFile { int r; while ((r = fis.read(buf)) >= 0) { out.write(buf, 0, r); - } - } - } catch (FileNotFoundException fnfe) { - if (ref.exists()) { - throw fnfe; } - // Don't worry about a file that doesn't exist yet, it - // conceptually has no current content to copy. + } + } catch (FileNotFoundException fnfe) { + if (ref.exists()) { + throw fnfe; + } + // Don't worry about a file that doesn't exist yet, it + // conceptually has no current content to copy. } } catch (IOException | RuntimeException | Error ioe) { unlock(); @@ -322,9 +322,9 @@ public class LockFile { if (out == null) { os = getStream(); if (fsync) { - out = Channels.newOutputStream(os.getChannel()); + out = Channels.newOutputStream(os.getChannel()); } else { - out = os; + out = os; } } return out; @@ -359,10 +359,10 @@ public class LockFile { } if (out != null) { if (fsync) { - os.getChannel().force(true); + os.getChannel().force(true); } - out.close(); - os = null; + out.close(); + os = null; } written = true; } catch (IOException | RuntimeException | Error ioe) { |