-
Notifications
You must be signed in to change notification settings - Fork 32
Making Optimizely Autocloseable #296
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
Conversation
Pull Request Test Coverage Report for Build 1024
💛 - Coveralls |
Pull Request Test Coverage Report for Build 1042
💛 - Coveralls |
32ced5e
to
12d3483
Compare
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.
We should be catching these exceptions else close()
isn't guaranteed for all closeables.
verify((Closeable) mockCloseableProjectConfigManager).close(); | ||
} | ||
|
||
@Test(expected = IOException.class) |
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.
We don't want to throw an exception. I think we should be catching all exceptions.
public void close() { | ||
if (eventHandler instanceof Closeable) { | ||
try { | ||
((Closeable) eventHandler).close(); |
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.
Maybe best to create a tryClose(Object obj) method.
private void tryClose(Object obj) {
if (!(obj instanceof Closeable)) {
return;
}
try {
((Closeable) obj).close();
} catch (Exception e) {
logger.warn("Unexpected exception on trying to close {}.", obj);
}
}
* | ||
* <b>NOTE:</b> There is a chance that this could be long running if the implementations of close are long running. | ||
*/ | ||
@Override |
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.
Nit, spacing is not consistent.
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
Making Optimizely
Autocloseable
and calling close onEventHandler
andProjectConfigManager
if they areCloseable
themselves.