KeyRemover.insertTree: rewrite without try/catch block
This commit is contained in:
parent
88bbfd428b
commit
20e6ba3f84
1 changed files with 3 additions and 6 deletions
|
@ -26,7 +26,6 @@ import net.kemitix.mon.maybe.Maybe;
|
||||||
import net.kemitix.mon.result.Result;
|
import net.kemitix.mon.result.Result;
|
||||||
import org.eclipse.jgit.lib.*;
|
import org.eclipse.jgit.lib.*;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
@ -101,10 +100,8 @@ class KeyRemover {
|
||||||
* @return the name of the tree object.
|
* @return the name of the tree object.
|
||||||
*/
|
*/
|
||||||
private Result<ObjectId> insertTree(final TreeFormatter treeFormatter) {
|
private Result<ObjectId> insertTree(final TreeFormatter treeFormatter) {
|
||||||
try (ObjectInserter inserter = repository.getObjectDatabase().newInserter()) {
|
return Result.ok(repository.getObjectDatabase())
|
||||||
return Result.ok(inserter.insert(treeFormatter));
|
.map(ObjectDatabase::newInserter)
|
||||||
} catch (IOException e) {
|
.andThen(inserter -> () -> inserter.insert(treeFormatter));
|
||||||
return Result.error(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue