Skip to content

Commit

Permalink
PROTON-2802 Clean up some warnings in tests for auto closables
Browse files Browse the repository at this point in the history
Adds some supressions on auto closables in throws checks that trigger
false positive warnings about unclosed resources.
  • Loading branch information
tabish121 committed Mar 18, 2024
1 parent b5bc7fe commit f166dcb
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ public void testStreamReceiverRecoversAndDeliveryReceived() throws Exception {
}
}

@SuppressWarnings("resource")
@Test
public void testCannotReceiveFromStreamStartedBeforeReconnection() throws Exception {
final byte[] payload = createEncodedMessage(new AmqpValue<>("Hello World"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,7 @@ private void doTestCloseWithErrorCondition(boolean sync) throws Exception {
}
}

@SuppressWarnings("resource")
@Test
public void testCannotCreateResourcesFromClosedSession() throws Exception {
try (ProtonTestServer peer = new ProtonTestServer()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1827,6 +1827,7 @@ private void testReadBytesFromBodyInputStreamWithSplitSingleByteTransfers(int op
}
}

@SuppressWarnings("resource")
@Test
public void testStreamReceiverSessionCannotCreateNewResources() throws Exception {
try (ProtonTestServer peer = new ProtonTestServer()) {
Expand Down Expand Up @@ -1959,6 +1960,7 @@ private void testReadPayloadInChunksFromLargerMessage(boolean readWithArgs) thro
}
}

@SuppressWarnings("resource")
@Test
public void testStreamReceiverMessageThrowsOnAnyMessageModificationAPI() throws Exception {
final byte[] body = new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
Expand Down Expand Up @@ -2652,6 +2654,7 @@ public void testReadBytesFromBodyInputStreamWithinTransactedSession() throws Exc
}
}

@SuppressWarnings("resource")
@Test
public void testStreamDeliveryHandlesInvalidHeaderEncoding() throws Exception {
final byte[] payload = createInvalidHeaderEncoding();
Expand Down Expand Up @@ -2701,6 +2704,7 @@ public void testStreamDeliveryHandlesInvalidHeaderEncoding() throws Exception {
}
}

@SuppressWarnings("resource")
@Test
public void testStreamDeliveryHandlesInvalidDeliveryAnnotationsEncoding() throws Exception {
final byte[] payload = createInvalidDeliveryAnnotationsEncoding();
Expand Down Expand Up @@ -2750,6 +2754,7 @@ public void testStreamDeliveryHandlesInvalidDeliveryAnnotationsEncoding() throws
}
}

@SuppressWarnings("resource")
@Test
public void testStreamDeliveryHandlesInvalidMessageAnnotationsEncoding() throws Exception {
final byte[] payload = createInvalidMessageAnnotationsEncoding();
Expand Down Expand Up @@ -2799,6 +2804,7 @@ public void testStreamDeliveryHandlesInvalidMessageAnnotationsEncoding() throws
}
}

@SuppressWarnings("resource")
@Test
public void testStreamDeliveryHandlesInvalidPropertiesEncoding() throws Exception {
final byte[] payload = createInvalidPropertiesEncoding();
Expand Down Expand Up @@ -2848,6 +2854,7 @@ public void testStreamDeliveryHandlesInvalidPropertiesEncoding() throws Exceptio
}
}

@SuppressWarnings("resource")
@Test
public void testStreamDeliveryHandlesInvalidApplicationPropertiesEncoding() throws Exception {
final byte[] payload = createInvalidApplicationPropertiesEncoding();
Expand Down Expand Up @@ -2897,6 +2904,7 @@ public void testStreamDeliveryHandlesInvalidApplicationPropertiesEncoding() thro
}
}

@SuppressWarnings("resource")
@Test
public void testStreamDeliveryHandlesInvalidHeaderEncodingDuringBodyStreamOpen() throws Exception {
final byte[] payload = createInvalidHeaderEncoding();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ public void testOpenStreamSenderAppliesConfiguredSessionOutgoingWindow() throws
}
}

@SuppressWarnings("resource")
@Test
public void testSendCustomMessageWithMultipleAmqpValueSections() throws Exception {
try (ProtonTestServer peer = new ProtonTestServer()) {
Expand Down Expand Up @@ -395,6 +396,7 @@ public void testSendCustomMessageWithMultipleAmqpValueSections() throws Exceptio
}
}

@SuppressWarnings("resource")
@Test
public void testClearBodySectionsIsNoOpForStreamSenderMessage() throws Exception {
try (ProtonTestServer peer = new ProtonTestServer()) {
Expand Down Expand Up @@ -1475,6 +1477,7 @@ void testCompleteStreamClosureCausesTransferCompleted() throws Exception {
}
}

@SuppressWarnings("resource")
@Test
void testRawOutputStreamFromMessageWritesUnmodifiedBytes() throws Exception {
try (ProtonTestServer peer = new ProtonTestServer()) {
Expand Down Expand Up @@ -1673,6 +1676,7 @@ public void testStreamSenderMessageWithDeliveryAnnotations() throws Exception {
}
}

@SuppressWarnings("resource")
@Test
public void testStreamSenderWritesFooterAfterStreamClosed() throws Exception {
try (ProtonTestServer peer = new ProtonTestServer()) {
Expand Down Expand Up @@ -2128,6 +2132,7 @@ void testConcurrentMessageSendWaitingOnSplitFramedSendToCompleteIsSentAfterCredi
}
}

@SuppressWarnings("resource")
@Test
void testMessageSendWhileStreamSendIsOpenShouldBlock() throws Exception {
try (ProtonTestServer peer = new ProtonTestServer()) {
Expand Down Expand Up @@ -2193,6 +2198,7 @@ void testMessageSendWhileStreamSendIsOpenShouldBlock() throws Exception {
}
}

@SuppressWarnings("resource")
@Test
public void testStreamSenderSessionCannotCreateNewResources() throws Exception {
try (ProtonTestServer peer = new ProtonTestServer()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,7 @@ public void testSetAndGetLongsAcrossMultipleArrays() {
}
}

@SuppressWarnings("resource")
@Test
public void testCompositeBuffersCannotHaveDuplicateComponents() {
try (ProtonBufferAllocator allocator = createProtonDefaultAllocator()) {
Expand Down Expand Up @@ -544,6 +545,7 @@ public void testCompositeBufferFromBufferWithHole() {
}
}

@SuppressWarnings("resource")
@Test
@Disabled
public void testCompositeBufferMustNotBeAllowedToContainThemselves() {
Expand Down Expand Up @@ -595,7 +597,8 @@ public void testAppendingToNonOwnedCompositeBufferMustThrow() {
}
}

@Test
@SuppressWarnings("resource")
@Test
public void testAppendingCompositeBufferToItselfMustThrow() {
try (ProtonBufferAllocator allocator = createProtonDefaultAllocator()) {
ProtonCompositeBuffer composite;
Expand Down Expand Up @@ -909,6 +912,7 @@ public void testComposingReadOnlyBuffersMustCreateReadOnlyCompositeBuffer() {
}
}

@SuppressWarnings("resource")
@Test
public void testComposingReadOnlyAndWritableBuffersMustThrow() {
try (ProtonBufferAllocator allocator = createProtonDefaultAllocator()) {
Expand Down Expand Up @@ -937,6 +941,7 @@ public void testComposingReadOnlyAndWritableBuffersMustThrow() {
}
}

@SuppressWarnings("resource")
@Test
public void testCompositeWritableBufferCannotBeExtendedWithReadOnlyBuffer() {
try (ProtonBufferAllocator allocator = createProtonDefaultAllocator();
Expand All @@ -948,6 +953,7 @@ public void testCompositeWritableBufferCannotBeExtendedWithReadOnlyBuffer() {
}
}

@SuppressWarnings("resource")
@Test
public void testCompositeReadOnlyBufferCannotBeExtendedWithWritableBuffer() {
try (ProtonBufferAllocator allocator = createProtonDefaultAllocator();
Expand Down Expand Up @@ -1593,6 +1599,7 @@ public void testEqualsWhenContentRemainingIsSubsetOfSingleChunkInMultiArrayBuffe
}
}

@SuppressWarnings("resource")
@Test
public void testSplitComponentsFloorMustThrowOnOutOfBounds() {
try (ProtonBufferAllocator allocator = createProtonDefaultAllocator();
Expand Down Expand Up @@ -1669,6 +1676,7 @@ public void testSplitComponentsFloorMustGiveBufferWithFirstComponentForOffsetOnF
}
}

@SuppressWarnings("resource")
@Test
public void testSplitComponentsCeilMustThrowOnOutOfBounds() {
try (ProtonBufferAllocator allocator = createProtonDefaultAllocator();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ public void testOffsettedGetOfUnsignedByteReadOnlyMustBoundsCheckWhenReadOffsetI
}
}

@SuppressWarnings("resource")
@Test
public void testOffsettedSetOfByteMustBoundsCheckWhenWriteOffsetIsNegative() {
try (Buffer buf = createProtonNetty5Buffer(8).fill((byte) 0)) {
Expand All @@ -277,6 +278,7 @@ public void testOffsettedSetOfByteMustBoundsCheckWhenWriteOffsetIsNegative() {
}
}

@SuppressWarnings("resource")
@Test
public void testOffsettedSetOfByteMustBoundsCheckWhenWriteOffsetAndSizeIsBeyondCapacity() {
try (Buffer buf = createProtonNetty5Buffer(8).fill((byte) 0)) {
Expand Down Expand Up @@ -306,6 +308,7 @@ public void testOffsettedSetOfByteMustHaveDefaultEndianByteOrder() {
}
}

@SuppressWarnings("resource")
@Test
public void testOffsettedSetOfUnsignedByteMustBoundsCheckWhenWriteOffsetIsNegative() {
try (Buffer buf = createProtonNetty5Buffer(8).fill((byte) 0)) {
Expand All @@ -318,6 +321,7 @@ public void testOffsettedSetOfUnsignedByteMustBoundsCheckWhenWriteOffsetIsNegati
}
}

@SuppressWarnings("resource")
@Test
public void testOffsettedSetOfUnsignedByteMustBoundsCheckWhenWriteOffsetAndSizeIsBeyondCapacity() {
try (Buffer buf = createProtonNetty5Buffer(8).fill((byte) 0)) {
Expand Down Expand Up @@ -1493,6 +1497,7 @@ public static byte[] readByteArray(Buffer buf) {
return bs;
}

@SuppressWarnings("resource")
private static void verifyInaccessible(Buffer buf) {
verifyReadInaccessible(buf);

Expand Down

0 comments on commit f166dcb

Please sign in to comment.