Conversation
…replacement and switch tests to new class
Commit-Check ✔️ |
…Closeable interface to Closer and test it
…) - add Closeable interface to Closer and test it" This reverts commit 5912f06.
…Closeable interface to Closer and test it
thomasmueller
requested changes
Mar 14, 2025
oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/pio/Closer.java
Outdated
Show resolved
Hide resolved
oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/pio/Closer.java
Show resolved
Hide resolved
rishabhdaim
reviewed
Mar 14, 2025
oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/pio/Closer.java
Outdated
Show resolved
Hide resolved
Contributor
Author
|
I believe all comments were based on misunderstandings about what Guava does; see again d254e8f which has the same tests running with Guava. @thomasmueller - every time we instantiate a collection with a non-default size, readers of the code will ask themselves: why? and does it really matter here? |
Contributor
Author
|
Things IMHO left to do:
Note that once this is in (and used throughout); we can get rid of the entire Guava common.io package. |
… Sonar happier wrt naming conventions
…row() just silences the close() method
thomasmueller
approved these changes
Mar 14, 2025
mbaedke
reviewed
Mar 14, 2025
oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/pio/Closer.java
Show resolved
Hide resolved
mbaedke
reviewed
Mar 14, 2025
| fail("should not throw but got: " + e); | ||
| } | ||
| } | ||
| } |
Contributor
There was a problem hiding this comment.
public void compareClosers() {
// when rethrow was called, Exceptions that happened upon close will be swallowed
com.google.common.io.Closer guavaCloser = com.google.common.io.Closer.create();
Closer oakCloser = Closer.create();
try {
throw oakCloser.rethrow(new InterruptedException());
} catch (Exception e) {}
try {
throw guavaCloser.rethrow(new InterruptedException());
} catch (Exception e) {}
try {
oakCloser.register(() -> { throw new RuntimeException(); });
oakCloser.close();
} catch (Exception e) {
fail("should not throw but got: " + e);
}
try {
guavaCloser.register(() -> { throw new RuntimeException(); });
guavaCloser.close();
} catch (Exception e) {
fail("should not throw but got: " + e);
}
}
would currently fail.
mbaedke
requested changes
Mar 14, 2025
Contributor
mbaedke
left a comment
There was a problem hiding this comment.
RuntimeException are not yet treated correctly, see inline comments.
…e unchecked exceptions thrown by Closeables when rethrow was called
|
mbaedke
approved these changes
Mar 17, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Note
1b60437
which added tests for Guava Closer. The Oak implementation only was written after tests were there.