-
Notifications
You must be signed in to change notification settings - Fork 25.1k
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
Ensure TestHttpChannel.close() is idempotent #96564
Conversation
Pinging @elastic/es-core-infra (Team:Core/Infra) |
I can see an argument for leaving it as-is - it's for testing purposes only, and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While I agree that throwing an ISE is the wrong reaction to double-closing, I'd rather we asserted that this never happens. Yes technically these things should be idempotent according to the JDK docs, but in practice we should consider it a logic error if we're double-closing stuff.
I've added an assertion failure to the close. In practice, asserts are always turned on for tests, so this will still fail, but it turns the failure into an |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@elasticmachine update branch |
Closeable.close
states thatclose
is idempotent - you can call it on an already-closed object and it doesn't do anything. This change makesTestHttpChannel.close()
follow this contract.