Author: frm Date: Wed Jan 17 15:08:16 2018 New Revision: 1821379 URL: http://svn.apache.org/viewvc?rev=1821379&view=rev Log: OAK-7171 - Let the history command properly propagate errors
Backport r1821375 from trunk. Modified: jackrabbit/oak/branches/1.8/ (props changed) jackrabbit/oak/branches/1.8/oak-run/src/main/java/org/apache/jackrabbit/oak/run/HistoryCommand.java jackrabbit/oak/branches/1.8/oak-run/src/main/java/org/apache/jackrabbit/oak/run/SegmentTarUtils.java jackrabbit/oak/branches/1.8/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/tool/History.java Propchange: jackrabbit/oak/branches/1.8/ ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Wed Jan 17 15:08:16 2018 @@ -1,3 +1,3 @@ /jackrabbit/oak/branches/1.0:1665962 -/jackrabbit/oak/trunk:1820660-1820661,1820859,1820861,1820878,1820888,1820947,1821130,1821140-1821141,1821240,1821258,1821362,1821370 +/jackrabbit/oak/trunk:1820660-1820661,1820859,1820861,1820878,1820888,1820947,1821130,1821140-1821141,1821240,1821258,1821362,1821370,1821375 /jackrabbit/trunk:1345480 Modified: jackrabbit/oak/branches/1.8/oak-run/src/main/java/org/apache/jackrabbit/oak/run/HistoryCommand.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.8/oak-run/src/main/java/org/apache/jackrabbit/oak/run/HistoryCommand.java?rev=1821379&r1=1821378&r2=1821379&view=diff ============================================================================== --- jackrabbit/oak/branches/1.8/oak-run/src/main/java/org/apache/jackrabbit/oak/run/HistoryCommand.java (original) +++ jackrabbit/oak/branches/1.8/oak-run/src/main/java/org/apache/jackrabbit/oak/run/HistoryCommand.java Wed Jan 17 15:08:16 2018 @@ -25,6 +25,7 @@ import joptsimple.OptionParser; import joptsimple.OptionSet; import joptsimple.OptionSpec; import org.apache.jackrabbit.oak.run.commons.Command; +import org.apache.jackrabbit.oak.segment.tool.History; class HistoryCommand implements Command { @@ -56,7 +57,14 @@ class HistoryCommand implements Command String journalName = journalArg.value(options); File journal = new File(isValidFileStoreOrFail(directory), journalName); - SegmentTarUtils.history(directory, journal, path, depth); + int returnCode = History.builder() + .withPath(directory) + .withJournal(journal) + .withNode(path) + .withDepth(depth) + .build() + .run(); + System.exit(returnCode); } } \ No newline at end of file Modified: jackrabbit/oak/branches/1.8/oak-run/src/main/java/org/apache/jackrabbit/oak/run/SegmentTarUtils.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.8/oak-run/src/main/java/org/apache/jackrabbit/oak/run/SegmentTarUtils.java?rev=1821379&r1=1821378&r2=1821379&view=diff ============================================================================== --- jackrabbit/oak/branches/1.8/oak-run/src/main/java/org/apache/jackrabbit/oak/run/SegmentTarUtils.java (original) +++ jackrabbit/oak/branches/1.8/oak-run/src/main/java/org/apache/jackrabbit/oak/run/SegmentTarUtils.java Wed Jan 17 15:08:16 2018 @@ -38,7 +38,6 @@ import org.apache.jackrabbit.oak.segment import org.apache.jackrabbit.oak.segment.tool.Backup; import org.apache.jackrabbit.oak.segment.tool.Check; import org.apache.jackrabbit.oak.segment.tool.Diff; -import org.apache.jackrabbit.oak.segment.tool.History; import org.apache.jackrabbit.oak.segment.tool.Restore; import org.apache.jackrabbit.oak.segment.tool.Revisions; import org.apache.jackrabbit.oak.spi.state.NodeStore; @@ -85,17 +84,7 @@ final class SegmentTarUtils { .run(); } - static void history(File directory, File journal, String path, int depth) { - History.builder() - .withPath(directory) - .withJournal(journal) - .withNode(path) - .withDepth(depth) - .build() - .run(); - } - - static void check(File dir, String journalFileName, long debugLevel, boolean checkBinaries, Set<String> filterPaths, boolean ioStatistics, + static void check(File dir, String journalFileName, long debugLevel, boolean checkBinaries, Set<String> filterPaths, boolean ioStatistics, PrintWriter outWriter, PrintWriter errWriter) { Check.builder() .withPath(dir) Modified: jackrabbit/oak/branches/1.8/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/tool/History.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.8/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/tool/History.java?rev=1821379&r1=1821378&r2=1821379&view=diff ============================================================================== --- jackrabbit/oak/branches/1.8/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/tool/History.java (original) +++ jackrabbit/oak/branches/1.8/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/tool/History.java Wed Jan 17 15:08:16 2018 @@ -30,7 +30,7 @@ import org.apache.jackrabbit.oak.segment * Prints the revision history of an existing segment store. Optionally, it can * narrow to the output to the history of a single node. */ -public class History implements Runnable { +public class History { /** * Create a builder for the {@link History} command. @@ -110,9 +110,9 @@ public class History implements Runnable /** * Create an executable version of the {@link History} command. * - * @return an instance of {@link Runnable}. + * @return an instance of {@link History}. */ - public Runnable build() { + public History build() { checkNotNull(path); checkNotNull(journal); checkNotNull(node); @@ -136,12 +136,13 @@ public class History implements Runnable this.depth = builder.depth; } - @Override - public void run() { + public int run() { try { run(new RevisionHistory(path).getHistory(journal, node)); + return 0; } catch (Exception e) { - e.printStackTrace(); + e.printStackTrace(System.err); + return 1; } }