-
Notifications
You must be signed in to change notification settings - Fork 316
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
Conversation
|
||
/** | ||
* closes this watcher and all its resources. | ||
**/ | ||
@Override | ||
void 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.
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 comment
The reason will be displayed to describe this comment to others. Learn more.
I think the point is whether to throw out exception on Watch#close
, so far it’s prohibited.
We uses AutoCloseable
just for try-with-resource
, it should not be a constraint.
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.
so lgtm :)
/** | ||
* 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 comment
The reason will be displayed to describe this comment to others. Learn more.
Same as before
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.rules.Timeout; | ||
|
||
import java.util.Arrays; |
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 move imports around?
@@ -26,6 +24,8 @@ | |||
import org.junit.Test; | |||
import org.junit.rules.Timeout; | |||
|
|||
import static org.assertj.core.api.Assertions.assertThat; |
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.
prefer not move imports order
@@ -48,11 +48,12 @@ | |||
/** | |||
* Interface of Watcher. | |||
*/ | |||
interface Watcher { | |||
interface Watcher extends AutoCloseable { |
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
not implement
the AutoCloseable
?
if we @Override
the close()
from AutoCloseable
, how come our close()
doesn't throw 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.
bb44f5f
to
6c45182
Compare
lgtm |
for #239
I think
Client
,CloseableClient
andWatcher
should extendsAutoCloseable
.but i can't make sure it's necessary for
KeepAlive
andKeepAliveListener
, because i don't know how to use them.