Skip to content

Commit 5edfb82

Browse files
Cosmetics, remove unused code
* The Address[] constructor is not used by user apps.
1 parent 5a2a5fd commit 5edfb82

File tree

1 file changed

+34
-40
lines changed

1 file changed

+34
-40
lines changed

src/main/java/com/rabbitmq/client/impl/recovery/RecoveryAwareAMQConnectionFactory.java

Lines changed: 34 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -7,52 +7,46 @@
77

88
import java.io.IOException;
99
import java.util.ArrayList;
10-
import java.util.Arrays;
1110
import java.util.Collections;
1211
import java.util.List;
1312
import java.util.concurrent.TimeoutException;
1413

1514
public class RecoveryAwareAMQConnectionFactory {
16-
private final ConnectionParams params;
17-
private final FrameHandlerFactory factory;
18-
private final List<Address> addrs;
19-
20-
public RecoveryAwareAMQConnectionFactory(ConnectionParams params, FrameHandlerFactory factory, Address[] addrs) {
21-
this.params = params;
22-
this.factory = factory;
23-
this.addrs = Arrays.asList(addrs);
24-
}
25-
26-
public RecoveryAwareAMQConnectionFactory(ConnectionParams params, FrameHandlerFactory factory, List<Address> addrs){
27-
this.params = params;
28-
this.factory = factory;
29-
this.addrs = addrs;
30-
}
31-
/**
32-
* @return an interface to the connection
33-
* @throws java.io.IOException if it encounters a problem
34-
*/
35-
RecoveryAwareAMQConnection newConnection() throws IOException, TimeoutException {
36-
IOException lastException = null;
37-
List<Address> shuffled = shuffle(addrs);
38-
39-
for (Address addr : shuffled) {
40-
try {
41-
FrameHandler frameHandler = factory.create(addr);
42-
RecoveryAwareAMQConnection conn = new RecoveryAwareAMQConnection(params, frameHandler);
43-
conn.start();
44-
return conn;
45-
} catch (IOException e) {
46-
lastException = e;
47-
}
15+
private final ConnectionParams params;
16+
private final FrameHandlerFactory factory;
17+
private final List<Address> addrs;
18+
19+
public RecoveryAwareAMQConnectionFactory(ConnectionParams params, FrameHandlerFactory factory, List<Address> addrs) {
20+
this.params = params;
21+
this.factory = factory;
22+
this.addrs = addrs;
4823
}
4924

50-
throw (lastException != null) ? lastException : new IOException("failed to connect");
51-
}
25+
/**
26+
* @return an interface to the connection
27+
* @throws java.io.IOException if it encounters a problem
28+
*/
29+
RecoveryAwareAMQConnection newConnection() throws IOException, TimeoutException {
30+
IOException lastException = null;
31+
List<Address> shuffled = shuffle(addrs);
32+
33+
for (Address addr : shuffled) {
34+
try {
35+
FrameHandler frameHandler = factory.create(addr);
36+
RecoveryAwareAMQConnection conn = new RecoveryAwareAMQConnection(params, frameHandler);
37+
conn.start();
38+
return conn;
39+
} catch (IOException e) {
40+
lastException = e;
41+
}
42+
}
43+
44+
throw (lastException != null) ? lastException : new IOException("failed to connect");
45+
}
5246

53-
private List<Address> shuffle(List<Address> addrs) {
54-
List<Address> list = new ArrayList<Address>(addrs);
55-
Collections.shuffle(list);
56-
return list;
57-
}
47+
private List<Address> shuffle(List<Address> addrs) {
48+
List<Address> list = new ArrayList<Address>(addrs);
49+
Collections.shuffle(list);
50+
return list;
51+
}
5852
}

0 commit comments

Comments
 (0)