Skip to content

Commit

Permalink
[Java]: fix hasDestination check to avoid situation of 1 destination …
Browse files Browse the repository at this point in the history
…but not at 0. Use subscriptionUdpChannel where needed & use transportIndex for multicast implicit check on creating images.
  • Loading branch information
tmontgomery committed Jul 12, 2022
1 parent 68feef7 commit b545e22
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ void onCreatePublicationImage(
rcvPos = ReceiverPos.allocate(tempBuffer, countersManager, registrationId, sessionId, streamId, uri);

final boolean treatAsMulticast = subscription.group() == INFER ?
channelEndpoint.udpChannel().isMulticast() : subscription.group() == FORCE_TRUE;
channelEndpoint.udpChannel(transportIndex).isMulticast() : subscription.group() == FORCE_TRUE;

final PublicationImage image = new PublicationImage(
registrationId,
Expand Down Expand Up @@ -582,7 +582,7 @@ void cleanupSubscriptionLink(final SubscriptionLink subscription)
if (channelEndpoint.shouldBeClosed())
{
receiverProxy.closeReceiveChannelEndpoint(channelEndpoint);
receiveChannelEndpointByChannelMap.remove(channelEndpoint.udpChannel().canonicalForm());
receiveChannelEndpointByChannelMap.remove(channelEndpoint.subscriptionUdpChannel().canonicalForm());
channelEndpoint.closeIndicators();
}
}
Expand Down Expand Up @@ -1502,7 +1502,8 @@ private void validateChannelSendTimestampOffset(
private void validateReceiveTimestampOffset(
final UdpChannel udpChannel, final ReceiveChannelEndpoint channelEndpoint)
{
if (udpChannel.channelReceiveTimestampOffset() != channelEndpoint.udpChannel().channelReceiveTimestampOffset())
if (udpChannel.channelReceiveTimestampOffset() !=
channelEndpoint.subscriptionUdpChannel().channelReceiveTimestampOffset())
{
throw new InvalidChannelException(
"option conflicts with existing subscription: " + CHANNEL_RECEIVE_TIMESTAMP_OFFSET_PARAM_NAME + "=" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ void removeDestination(final int transportIndex)

boolean hasDestination(final int transportIndex)
{
return numDestinations > transportIndex && null != transports[transportIndex];
return transports.length > transportIndex && null != transports[transportIndex];
}

ReceiveDestinationTransport transport(final int transportIndex)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public int sendTo(final ByteBuffer buffer, final InetSocketAddress remoteAddress
*/
public String originalUriString()
{
return udpChannel().originalUriString();
return subscriptionUdpChannel().originalUriString();
}

/**
Expand Down

0 comments on commit b545e22

Please sign in to comment.