Skip to content

Commit 85a473e

Browse files
author
Steve Powell
committed
Remove methods Utility.use() and Utility.emptyStatement() and all uses.
1 parent 56d92ba commit 85a473e

File tree

4 files changed

+20
-51
lines changed

4 files changed

+20
-51
lines changed

src/com/rabbitmq/client/impl/AMQConnection.java

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -578,9 +578,7 @@ public boolean processControlCommand(Command c) throws IOException
578578
// Already shutting down, so just send back a CloseOk.
579579
try {
580580
_channel0.quiescingTransmit(new AMQP.Connection.CloseOk.Builder().build());
581-
} catch (IOException ioe) {
582-
Utility.emptyStatement();
583-
}
581+
} catch (IOException ioe) { } // ignore
584582
return true;
585583
} else if (method instanceof AMQP.Connection.CloseOk) {
586584
// It's our final "RPC". Time to shut down.
@@ -599,9 +597,7 @@ public void handleConnectionClose(Command closeCommand) {
599597
ShutdownSignalException sse = shutdown(closeCommand, false, null, false);
600598
try {
601599
_channel0.quiescingTransmit(new AMQP.Connection.CloseOk.Builder().build());
602-
} catch (IOException ioe) {
603-
Utility.emptyStatement();
604-
}
600+
} catch (IOException _) { } // ignore
605601
_brokerInitiatedShutdown = true;
606602
Thread scw = new SocketCloseWait(sse);
607603
scw.setName("AMQP Connection Closing Monitor " +
@@ -708,9 +704,7 @@ public void abort(int closeCode, String closeMessage, int timeout)
708704
{
709705
try {
710706
close(closeCode, closeMessage, true, null, timeout, true);
711-
} catch (IOException e) {
712-
Utility.emptyStatement();
713-
}
707+
} catch (IOException _) { } // ignore
714708
}
715709

716710
/**

src/com/rabbitmq/client/impl/ChannelN.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,8 @@ public ChannelN(AMQConnection connection, int channelNumber,
121121
* @throws IOException if any problem is encountered
122122
*/
123123
public void open() throws IOException {
124-
// wait for the Channel.OpenOk response, then ignore it
125-
Channel.OpenOk openOk =
126-
(Channel.OpenOk) exnWrappingRpc(new Channel.Open(UNSPECIFIED_OUT_OF_BAND)).getMethod();
127-
Utility.use(openOk);
124+
// wait for the Channel.OpenOk response, and ignore it
125+
exnWrappingRpc(new Channel.Open(UNSPECIFIED_OUT_OF_BAND));
128126
}
129127

130128
public void addReturnListener(ReturnListener listener) {
@@ -909,8 +907,7 @@ public void basicCancel(final String consumerTag)
909907
{
910908
BlockingRpcContinuation<Consumer> k = new BlockingRpcContinuation<Consumer>() {
911909
public Consumer transformReply(AMQCommand replyCommand) {
912-
Basic.CancelOk dummy = (Basic.CancelOk) replyCommand.getMethod();
913-
Utility.use(dummy);
910+
replyCommand.getMethod(); // discard result
914911
Consumer callback = _consumers.remove(consumerTag);
915912
// We need to call back inside the connection thread
916913
// in order avoid races with 'deliver' commands
@@ -922,8 +919,7 @@ public Consumer transformReply(AMQCommand replyCommand) {
922919
rpc(new Basic.Cancel(consumerTag, false), k);
923920

924921
try {
925-
Consumer callback = k.getReply();
926-
Utility.use(callback);
922+
k.getReply(); // discard result
927923
} catch(ShutdownSignalException ex) {
928924
throw wrap(ex);
929925
}

src/com/rabbitmq/utility/Utility.java

Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ public ThrowableCreatedElsewhere(Throwable throwable) {
3333
this.setStackTrace(throwable.getStackTrace());
3434
}
3535

36-
@Override public Throwable fillInStackTrace(){
37-
return this;
38-
}
36+
@Override public Throwable fillInStackTrace(){
37+
return this;
38+
}
3939
}
4040

4141
public static <T extends Throwable & SensibleClone<T>> T fixStackTrace(T throwable) {
@@ -44,19 +44,19 @@ public static <T extends Throwable & SensibleClone<T>> T fixStackTrace(T throwab
4444
if(throwable.getCause() == null) {
4545
// We'd like to preserve the original stack trace in the cause.
4646
// Unfortunately Java doesn't let you set the cause once it's been
47-
// set once. This means we have to choose between either
47+
// set once. This means we have to choose between either
4848
// - not preserving the type
4949
// - sometimes losing the original stack trace
5050
// - performing nasty reflective voodoo which may or may not work
5151
// We only lose the original stack trace when there's a root cause
52-
// which will hopefully be enlightening enough on its own that it
53-
// doesn't matter too much.
52+
// which will hopefully be enlightening enough on its own that it
53+
// doesn't matter too much.
5454
try {
5555
throwable.initCause(new ThrowableCreatedElsewhere(throwable));
5656
} catch(IllegalStateException e) {
57-
// This exception was explicitly initialised with a null cause.
58-
// Alas this means we can't set the cause even though it has none.
59-
// Thanks.
57+
// This exception was explicitly initialised with a null cause.
58+
// Alas this means we can't set the cause even though it has none.
59+
// Thanks.
6060
}
6161
}
6262

@@ -70,7 +70,7 @@ public static <T extends Throwable & SensibleClone<T>> T fixStackTrace(T throwab
7070
return throwable;
7171
}
7272

73-
73+
7474
public static String makeStackTrace(Throwable throwable) {
7575
ByteArrayOutputStream baOutStream = new ByteArrayOutputStream();
7676
PrintStream printStream = new PrintStream(baOutStream, false);
@@ -80,22 +80,4 @@ public static String makeStackTrace(Throwable throwable) {
8080
printStream.close(); // closes baOutStream
8181
return text;
8282
}
83-
84-
/**
85-
* Used to indicate that we are not, in fact, using a variable, also to silence compiler warnings.
86-
*
87-
* @param value the object we're pretending to use
88-
*/
89-
public static void use(Object value) {
90-
if (value != null) {
91-
return;
92-
}
93-
}
94-
95-
/**
96-
* Similarly, for situations where an empty statement is required
97-
*/
98-
public static void emptyStatement() {
99-
use(null);
100-
}
10183
}

test/src/com/rabbitmq/examples/TestMain.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
import com.rabbitmq.client.impl.FrameHandler;
4040
import com.rabbitmq.client.impl.SocketFrameHandler;
4141
import com.rabbitmq.utility.BlockingCell;
42-
import com.rabbitmq.utility.Utility;
4342

4443
public class TestMain {
4544
public static void main(String[] args) throws IOException, URISyntaxException {
@@ -199,9 +198,7 @@ public static void runProducerConsumerTest(String uri, int commitEvery)
199198
public static void sleep(int ms) {
200199
try {
201200
Thread.sleep(ms);
202-
} catch (InterruptedException ie) {
203-
Utility.emptyStatement();
204-
}
201+
} catch (InterruptedException _) { } // ignore
205202
}
206203

207204
private Connection _connection;
@@ -232,7 +229,7 @@ public void run() throws IOException {
232229
final int batchSize = 5;
233230

234231
_ch1 = createChannel();
235-
232+
236233
String queueName =_ch1.queueDeclare().getQueue();
237234

238235
sendLotsOfTrivialMessages(batchSize, queueName);
@@ -488,7 +485,7 @@ public void tryBasicReturn() throws IOException {
488485
unsetChannelReturnListener();
489486

490487
log("Completed basic.return testing.");
491-
488+
492489
}
493490

494491
private void unsetChannelReturnListener() {

0 commit comments

Comments
 (0)