8000 implements java.io.Closeable · liborange/rabbitmq-java-client@fd27f27 · GitHub
[go: up one dir, main page]

Skip to content

Commit fd27f27

Browse files
committed
implements java.io.Closeable
1 parent 335c161 commit fd27f27

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed

src/com/rabbitmq/client/Channel.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package com.rabbitmq.client;
1818

19+
import java.io.Closeable;
1920
import java.io.IOException;
2021
import java.util.Map;
2122
import java.util.concurrent.TimeoutException;
@@ -58,7 +59,7 @@
5859
*
5960
*/
6061

61-
public interface Channel extends ShutdownNotifier {
62+
public interface Channel extends ShutdownNotifier, Closeable {
6263
/**
6364
* Retrieve this channel's channel number.
6465
* @return the channel number
@@ -77,6 +78,7 @@ public interface Channel extends ShutdownNotifier {
7778
*
7879
* @throws java.io.IOException if an error is encountered
7980
*/
81+
@Override
8082
void close() throws IOException, TimeoutException;
8183

8284
/**

src/com/rabbitmq/client/Connection.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package com.rabbitmq.client;
1818

19+
import java.io.Closeable;
1920
import java.io.IOException;
2021
import java.net.InetAddress;
2122
import java.util.Map;
@@ -50,7 +51,7 @@
5051
* Current implementations are thread-safe for code at the client API level,
5152
* and in fact thread-safe internally except for code within RPC calls.
5253
*/
53-
public interface Connection extends ShutdownNotifier { // rename to AMQPConnection later, this is a temporary name
54+
public interface Connection extends ShutdownNotifier, Closeable { // rename to AMQPConnection later, this is a temporary name
5455
/**
5556
* Retrieve the host.
5657
* @return the hostname of the peer we're connected to.
@@ -123,6 +124,7 @@ public interface Connection extends ShutdownNotifier { // rename to AMQPConnecti
123124
*
124125
* @throws IOException if an I/O problem is encountered
125126
*/
127+
@Override
126128
void close() throws IOException;
127129

128130
/**

src/com/rabbitmq/client/RpcClient.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
import java.io.ByteArrayInputStream;
2121
import java.io.ByteArrayOutputStream;
22+
import java.io.Closeable;
2223
import java.io.DataInputStream;
2324
import java.io.DataOutputStream;
2425
import java.io.EOFException;
@@ -41,7 +42,7 @@
4142
* It simply provides a mechanism for sending a message to an exchange with a given routing key,
4243
* and waiting for a response.
4344
*/
44-
public class RpcClient {
45+
public class RpcClient extends Closeable {
4546
/** Channel we are communicating on */
4647
private final Channel _channel;
4748
/** Exchange to send requests to */
@@ -113,6 +114,7 @@ public void checkConsumer() throws IOException {
113114
* Public API - cancels the consumer, thus deleting the temporary queue, and marks the RpcClient as closed.
114115
* @throws IOException if an error is encountered
115116
*/
117+
@Override
116118
public void close() throws IOException {
117119
if (_consumer != null) {
118120
_channel.basicCancel(_consumer.getConsumerTag());

src/com/rabbitmq/client/RpcServer.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,14 @@
1717

1818
package com.rabbitmq.client;
1919

20+
import java.io.Closeable;
2021
import java.io.IOException;
2122

2223
/**
2324
* Class which manages a request queue for a simple RPC-style service.
2425
* The class is agnostic about the format of RPC arguments / return values.
2526
*/
26-
public class RpcServer {
27+
public class RpcServer extends Closeable {
2728
/** Channel we are communicating on */
2829
private final Channel _channel;
2930
/** Queue to receive requests from */
@@ -66,6 +67,7 @@ public RpcServer(Channel channel, String queueName)
6667
* it was a temporary queue, and marks the RpcServer as closed.
6768
* @throws IOException if an error is encountered
6869
*/
70+
@Override
6971
public void close()
7072
throws IOException
7173
{

0 commit comments

Comments
 (0)
0