NamedRevBlob.blobAsString: rewrite without try/catch block
This commit is contained in:
parent
20e6ba3f84
commit
32027ef6e1
1 changed files with 3 additions and 9 deletions
|
@ -30,8 +30,6 @@ import org.eclipse.jgit.lib.ObjectLoader;
|
|||
import org.eclipse.jgit.lib.Repository;
|
||||
import org.eclipse.jgit.revwalk.RevBlob;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Represents the key/value pairs read from the tree.
|
||||
*
|
||||
|
@ -52,13 +50,9 @@ class NamedRevBlob {
|
|||
* @return a string
|
||||
*/
|
||||
Result<String> blobAsString() {
|
||||
try {
|
||||
return Result.ok(repository.open(revBlob.getId(), Constants.OBJ_BLOB))
|
||||
return Result.of(() -> repository.open(revBlob.getId(), Constants.OBJ_BLOB))
|
||||
.map(ObjectLoader::getBytes)
|
||||
.map(String::new);
|
||||
} catch (IOException e) {
|
||||
return Result.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue