-
Notifications
You must be signed in to change notification settings - Fork 315
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
client: add AutoCloseable #244
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,11 +48,12 @@ public interface Watch extends CloseableClient { | |
/** | ||
* Interface of Watcher. | ||
*/ | ||
interface Watcher { | ||
interface Watcher extends AutoCloseable { | ||
|
||
/** | ||
* closes this watcher and all its resources. | ||
**/ | ||
@Override | ||
void close(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. AutoCloseable::close() throws an exception, I do not think we should change the signature There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the point is whether to throw out exception on We uses There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so lgtm :) |
||
|
||
/** | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,10 +16,12 @@ | |
|
||
package com.coreos.jetcd.internal.impl; | ||
|
||
public interface CloseableClient { | ||
public interface CloseableClient extends AutoCloseable { | ||
|
||
/** | ||
* close the client and release its resources. | ||
*/ | ||
@Override | ||
default void close() { | ||
// noop | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as before |
||
} | ||
|
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.
why
extends
notimplement
theAutoCloseable
?if we
@Override
theclose()
fromAutoCloseable
, how come ourclose()
doesn'tthrow Exception
?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.
Interface can only
extends
another interface. notimplement
.The overriding method can throw those checked exceptions, which have less scope than the exception(s) declared in the overridden method.
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.
now i understand what you were doing. pretty cool java trick.