Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try.withResources using the variable multiple times #2933

Open
xenoterracide opened this issue Nov 14, 2024 · 1 comment
Open

Try.withResources using the variable multiple times #2933

xenoterracide opened this issue Nov 14, 2024 · 1 comment
Milestone

Comments

@xenoterracide
Copy link

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

@pivovarit pivovarit added this to the v0.10.6 milestone Nov 14, 2024
@pivovarit
Copy link
Member

That's a great point. Thanks! Targeting next release (0.10.6 or 0.11.0)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants