Skip to content

Make channels instantiated with a user-provided number recoverable #671

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

Merged
merged 1 commit into from
Feb 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,13 @@ public Channel createChannel() throws IOException {
*/
@Override
public Channel createChannel(int channelNumber) throws IOException {
return delegate.createChannel(channelNumber);
RecoveryAwareChannelN ch = (RecoveryAwareChannelN) delegate.createChannel(channelNumber);
// No Sonar: the channel could be null
if (ch == null) { //NOSONAR
return null;
} else {
return this.wrapChannel(ch);
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,22 @@ public void handleUnblocked() throws IOException {
expectChannelRecovery(ch2);
}

@Test public void channelRecoveryWithUserProvidedChannelIDs() throws IOException, InterruptedException {
int n1 = 11;
Channel ch1 = connection.createChannel(n1);
int n2 = 22;
Channel ch2 = connection.createChannel(n2);

assertThat(ch1.isOpen()).isTrue();
assertThat(ch2.isOpen()).isTrue();
closeAndWaitForRecovery();
expectChannelRecovery(ch1);
expectChannelRecovery(ch2);

assertThat(ch1.getChannelNumber()).isEqualTo(n1);
assertThat(ch2.getChannelNumber()).isEqualTo(n2);
}

@Test public void returnListenerRecovery() throws IOException, InterruptedException {
final CountDownLatch latch = new CountDownLatch(1);
channel.addReturnListener(new ReturnListener() {
Expand Down