Skip to content

Commit d91e021

Browse files
committed
[Java] Simplify isValidFrame check.
1 parent dd2656b commit d91e021

1 file changed

Lines changed: 5 additions & 11 deletions

File tree

aeron-driver/src/main/java/io/aeron/driver/media/UdpChannelTransport.java

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -395,20 +395,14 @@ public boolean isMulticast()
395395
*/
396396
public boolean isValidFrame(final UnsafeBuffer buffer, final int length)
397397
{
398-
boolean isFrameValid = true;
399-
400-
if (frameVersion(buffer, 0) != HeaderFlyweight.CURRENT_VERSION)
401-
{
402-
isFrameValid = false;
403-
invalidPackets.increment();
404-
}
405-
else if (length < HeaderFlyweight.MIN_HEADER_LENGTH)
398+
if (length >= HeaderFlyweight.MIN_HEADER_LENGTH &&
399+
frameVersion(buffer, 0) == HeaderFlyweight.CURRENT_VERSION)
406400
{
407-
isFrameValid = false;
408-
invalidPackets.increment();
401+
return true;
409402
}
410403

411-
return isFrameValid;
404+
invalidPackets.increment();
405+
return false;
412406
}
413407

414408
/**

0 commit comments

Comments
 (0)