Skip to content

Commit 6081714

Browse files
author
Simon MacMullen
committed
1) Only reopen the channel
2) Fix another race 3) Use basic.qos consistently after publish 4) Reduce duplication
1 parent 64c4d20 commit 6081714

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

test/src/com/rabbitmq/client/test/server/Permissions.java

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ public void with(String name) throws IOException {
190190
channel.basicPublish(name, "", null, "foo".getBytes());
191191
//followed by a dummy synchronous command in order
192192
//to catch any errors
193-
((AMQChannel)channel).exnWrappingRpc(new AMQImpl.Channel.Flow(true));
193+
channel.basicQos(0);
194194
}});
195195
}
196196

@@ -277,7 +277,7 @@ public void with(String _) throws IOException {
277277
expectExceptionRun(AMQP.ACCESS_REFUSED, new WithName() {
278278
public void with(String _) throws IOException {
279279
channel.basicPublish("write", "", null, "foo".getBytes());
280-
channel.queueDeclare();
280+
channel.basicQos(0);
281281
}}
282282
);
283283
expectExceptionRun(AMQP.ACCESS_REFUSED, new WithName() {
@@ -299,15 +299,11 @@ protected void expectExceptionRun(int exceptionCode, WithName action)
299299
action.with("");
300300
fail();
301301
} catch (IOException e) {
302-
ShutdownSignalException sse = (ShutdownSignalException)e.getCause();
303-
if (sse.isHardError()) {
304-
fail("Got a hard-error. Was expecting soft-error: " + exceptionCode);
305-
} else {
306-
AMQP.Channel.Close closeMethod =
307-
(AMQP.Channel.Close) ((Command)sse.getReason()).getMethod();
308-
assertEquals(exceptionCode, closeMethod.getReplyCode());
309-
}
310-
channel = channel.getConnection().createChannel();
302+
checkShutdownSignal(exceptionCode, e);
303+
openChannel();
304+
} catch (AlreadyClosedException e) {
305+
checkShutdownSignal(exceptionCode, e);
306+
openChannel();
311307
}
312308
}
313309

@@ -349,11 +345,9 @@ protected void runTest(boolean exp, String name, WithName test)
349345
assertTrue(msg, exp);
350346
} catch (IOException e) {
351347
checkShutdownSignal(AMQP.ACCESS_REFUSED, e);
352-
openConnection();
353348
openChannel();
354349
} catch (AlreadyClosedException e) {
355350
checkShutdownSignal(AMQP.ACCESS_REFUSED, e);
356-
openConnection();
357351
openChannel();
358352
}
359353
}

0 commit comments

Comments
 (0)