vavr
vavr copied to clipboard
Try.withResources using the variable multiple times
I'd like to see the javadoc improved on the Try.withResources I'm making the assumption here that the autoclosable Git will be opened twice, once each at the get* and as such this is safe. It's unclear in the documentation when the close happens and when it's safe to chain. So I'm assuming it's at the terminal operation when you no longer have a Try. It'd be nice if that was clear in the javadoc.
var git = Try.withResources(() -> Git.open(new File("")));
git.of(g -> g.getRepository().resolve("HEAD")).get();
git.of(g -> g.getRepository().newObjectReader())
.mapTry(objectReader -> objectReader.abbreviate(this.getObjectIdFor(Constants.HEAD).get(), 8))
.map(AbbreviatedObjectId::name)
.getOrNull();
javadoc for 0.10.5
That's a great point. Thanks! Targeting next release (0.10.6 or 0.11.0)