This is an automated email from the ASF dual-hosted git repository.
tabish pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/qpid-protonj2.git
The following commit(s) were added to refs/heads/main by this push:
new f166dcbd PROTON-2802 Clean up some warnings in tests for auto closables
f166dcbd is described below
commit f166dcbd42f29d60af9ba49356aa149883ad7c67
Author: Timothy Bish <[email protected]>
AuthorDate: Mon Mar 18 16:54:26 2024 -0400
PROTON-2802 Clean up some warnings in tests for auto closables
Adds some supressions on auto closables in throws checks that trigger
false positive warnings about unclosed resources.
---
.../qpid/protonj2/client/impl/ReconnectStreamReceiverTest.java | 1 +
.../java/org/apache/qpid/protonj2/client/impl/SessionTest.java | 1 +
.../apache/qpid/protonj2/client/impl/StreamReceiverTest.java | 8 ++++++++
.../org/apache/qpid/protonj2/client/impl/StreamSenderTest.java | 6 ++++++
.../protonj2/buffer/impl/ProtonCompositeBufferImplTest.java | 10 +++++++++-
.../protonj2/buffer/netty/ProtonBufferToNetty5AdapterTest.java | 5 +++++
6 files changed, 30 insertions(+), 1 deletion(-)
diff --git
a/protonj2-client/src/test/java/org/apache/qpid/protonj2/client/impl/ReconnectStreamReceiverTest.java
b/protonj2-client/src/test/java/org/apache/qpid/protonj2/client/impl/ReconnectStreamReceiverTest.java
index bc5c3214..13173783 100644
---
a/protonj2-client/src/test/java/org/apache/qpid/protonj2/client/impl/ReconnectStreamReceiverTest.java
+++
b/protonj2-client/src/test/java/org/apache/qpid/protonj2/client/impl/ReconnectStreamReceiverTest.java
@@ -105,6 +105,7 @@ class ReconnectStreamReceiverTest extends
ImperativeClientTestCase {
}
}
+ @SuppressWarnings("resource")
@Test
public void testCannotReceiveFromStreamStartedBeforeReconnection() throws
Exception {
final byte[] payload = createEncodedMessage(new AmqpValue<>("Hello
World"));
diff --git
a/protonj2-client/src/test/java/org/apache/qpid/protonj2/client/impl/SessionTest.java
b/protonj2-client/src/test/java/org/apache/qpid/protonj2/client/impl/SessionTest.java
index 0d4cab58..148eb9d0 100644
---
a/protonj2-client/src/test/java/org/apache/qpid/protonj2/client/impl/SessionTest.java
+++
b/protonj2-client/src/test/java/org/apache/qpid/protonj2/client/impl/SessionTest.java
@@ -561,6 +561,7 @@ public class SessionTest extends ImperativeClientTestCase {
}
}
+ @SuppressWarnings("resource")
@Test
public void testCannotCreateResourcesFromClosedSession() throws Exception {
try (ProtonTestServer peer = new ProtonTestServer()) {
diff --git
a/protonj2-client/src/test/java/org/apache/qpid/protonj2/client/impl/StreamReceiverTest.java
b/protonj2-client/src/test/java/org/apache/qpid/protonj2/client/impl/StreamReceiverTest.java
index 5b89763b..680d33d6 100644
---
a/protonj2-client/src/test/java/org/apache/qpid/protonj2/client/impl/StreamReceiverTest.java
+++
b/protonj2-client/src/test/java/org/apache/qpid/protonj2/client/impl/StreamReceiverTest.java
@@ -1827,6 +1827,7 @@ class StreamReceiverTest extends ImperativeClientTestCase
{
}
}
+ @SuppressWarnings("resource")
@Test
public void testStreamReceiverSessionCannotCreateNewResources() throws
Exception {
try (ProtonTestServer peer = new ProtonTestServer()) {
@@ -1959,6 +1960,7 @@ class StreamReceiverTest extends ImperativeClientTestCase
{
}
}
+ @SuppressWarnings("resource")
@Test
public void testStreamReceiverMessageThrowsOnAnyMessageModificationAPI()
throws Exception {
final byte[] body = new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
@@ -2652,6 +2654,7 @@ class StreamReceiverTest extends ImperativeClientTestCase
{
}
}
+ @SuppressWarnings("resource")
@Test
public void testStreamDeliveryHandlesInvalidHeaderEncoding() throws
Exception {
final byte[] payload = createInvalidHeaderEncoding();
@@ -2701,6 +2704,7 @@ class StreamReceiverTest extends ImperativeClientTestCase
{
}
}
+ @SuppressWarnings("resource")
@Test
public void testStreamDeliveryHandlesInvalidDeliveryAnnotationsEncoding()
throws Exception {
final byte[] payload = createInvalidDeliveryAnnotationsEncoding();
@@ -2750,6 +2754,7 @@ class StreamReceiverTest extends ImperativeClientTestCase
{
}
}
+ @SuppressWarnings("resource")
@Test
public void testStreamDeliveryHandlesInvalidMessageAnnotationsEncoding()
throws Exception {
final byte[] payload = createInvalidMessageAnnotationsEncoding();
@@ -2799,6 +2804,7 @@ class StreamReceiverTest extends ImperativeClientTestCase
{
}
}
+ @SuppressWarnings("resource")
@Test
public void testStreamDeliveryHandlesInvalidPropertiesEncoding() throws
Exception {
final byte[] payload = createInvalidPropertiesEncoding();
@@ -2848,6 +2854,7 @@ class StreamReceiverTest extends ImperativeClientTestCase
{
}
}
+ @SuppressWarnings("resource")
@Test
public void
testStreamDeliveryHandlesInvalidApplicationPropertiesEncoding() throws
Exception {
final byte[] payload = createInvalidApplicationPropertiesEncoding();
@@ -2897,6 +2904,7 @@ class StreamReceiverTest extends ImperativeClientTestCase
{
}
}
+ @SuppressWarnings("resource")
@Test
public void
testStreamDeliveryHandlesInvalidHeaderEncodingDuringBodyStreamOpen() throws
Exception {
final byte[] payload = createInvalidHeaderEncoding();
diff --git
a/protonj2-client/src/test/java/org/apache/qpid/protonj2/client/impl/StreamSenderTest.java
b/protonj2-client/src/test/java/org/apache/qpid/protonj2/client/impl/StreamSenderTest.java
index 677f5f69..07d6d91f 100644
---
a/protonj2-client/src/test/java/org/apache/qpid/protonj2/client/impl/StreamSenderTest.java
+++
b/protonj2-client/src/test/java/org/apache/qpid/protonj2/client/impl/StreamSenderTest.java
@@ -296,6 +296,7 @@ public class StreamSenderTest extends
ImperativeClientTestCase {
}
}
+ @SuppressWarnings("resource")
@Test
public void testSendCustomMessageWithMultipleAmqpValueSections() throws
Exception {
try (ProtonTestServer peer = new ProtonTestServer()) {
@@ -395,6 +396,7 @@ public class StreamSenderTest extends
ImperativeClientTestCase {
}
}
+ @SuppressWarnings("resource")
@Test
public void testClearBodySectionsIsNoOpForStreamSenderMessage() throws
Exception {
try (ProtonTestServer peer = new ProtonTestServer()) {
@@ -1475,6 +1477,7 @@ public class StreamSenderTest extends
ImperativeClientTestCase {
}
}
+ @SuppressWarnings("resource")
@Test
void testRawOutputStreamFromMessageWritesUnmodifiedBytes() throws
Exception {
try (ProtonTestServer peer = new ProtonTestServer()) {
@@ -1673,6 +1676,7 @@ public class StreamSenderTest extends
ImperativeClientTestCase {
}
}
+ @SuppressWarnings("resource")
@Test
public void testStreamSenderWritesFooterAfterStreamClosed() throws
Exception {
try (ProtonTestServer peer = new ProtonTestServer()) {
@@ -2128,6 +2132,7 @@ public class StreamSenderTest extends
ImperativeClientTestCase {
}
}
+ @SuppressWarnings("resource")
@Test
void testMessageSendWhileStreamSendIsOpenShouldBlock() throws Exception {
try (ProtonTestServer peer = new ProtonTestServer()) {
@@ -2193,6 +2198,7 @@ public class StreamSenderTest extends
ImperativeClientTestCase {
}
}
+ @SuppressWarnings("resource")
@Test
public void testStreamSenderSessionCannotCreateNewResources() throws
Exception {
try (ProtonTestServer peer = new ProtonTestServer()) {
diff --git
a/protonj2/src/test/java/org/apache/qpid/protonj2/buffer/impl/ProtonCompositeBufferImplTest.java
b/protonj2/src/test/java/org/apache/qpid/protonj2/buffer/impl/ProtonCompositeBufferImplTest.java
index c404211b..ad113835 100644
---
a/protonj2/src/test/java/org/apache/qpid/protonj2/buffer/impl/ProtonCompositeBufferImplTest.java
+++
b/protonj2/src/test/java/org/apache/qpid/protonj2/buffer/impl/ProtonCompositeBufferImplTest.java
@@ -475,6 +475,7 @@ public class ProtonCompositeBufferImplTest extends
ProtonAbstractBufferTest {
}
}
+ @SuppressWarnings("resource")
@Test
public void testCompositeBuffersCannotHaveDuplicateComponents() {
try (ProtonBufferAllocator allocator = createProtonDefaultAllocator())
{
@@ -544,6 +545,7 @@ public class ProtonCompositeBufferImplTest extends
ProtonAbstractBufferTest {
}
}
+ @SuppressWarnings("resource")
@Test
@Disabled
public void testCompositeBufferMustNotBeAllowedToContainThemselves() {
@@ -595,7 +597,8 @@ public class ProtonCompositeBufferImplTest extends
ProtonAbstractBufferTest {
}
}
- @Test
+ @SuppressWarnings("resource")
+ @Test
public void testAppendingCompositeBufferToItselfMustThrow() {
try (ProtonBufferAllocator allocator = createProtonDefaultAllocator())
{
ProtonCompositeBuffer composite;
@@ -909,6 +912,7 @@ public class ProtonCompositeBufferImplTest extends
ProtonAbstractBufferTest {
}
}
+ @SuppressWarnings("resource")
@Test
public void testComposingReadOnlyAndWritableBuffersMustThrow() {
try (ProtonBufferAllocator allocator = createProtonDefaultAllocator())
{
@@ -937,6 +941,7 @@ public class ProtonCompositeBufferImplTest extends
ProtonAbstractBufferTest {
}
}
+ @SuppressWarnings("resource")
@Test
public void
testCompositeWritableBufferCannotBeExtendedWithReadOnlyBuffer() {
try (ProtonBufferAllocator allocator = createProtonDefaultAllocator();
@@ -948,6 +953,7 @@ public class ProtonCompositeBufferImplTest extends
ProtonAbstractBufferTest {
}
}
+ @SuppressWarnings("resource")
@Test
public void
testCompositeReadOnlyBufferCannotBeExtendedWithWritableBuffer() {
try (ProtonBufferAllocator allocator = createProtonDefaultAllocator();
@@ -1593,6 +1599,7 @@ public class ProtonCompositeBufferImplTest extends
ProtonAbstractBufferTest {
}
}
+ @SuppressWarnings("resource")
@Test
public void testSplitComponentsFloorMustThrowOnOutOfBounds() {
try (ProtonBufferAllocator allocator = createProtonDefaultAllocator();
@@ -1669,6 +1676,7 @@ public class ProtonCompositeBufferImplTest extends
ProtonAbstractBufferTest {
}
}
+ @SuppressWarnings("resource")
@Test
public void testSplitComponentsCeilMustThrowOnOutOfBounds() {
try (ProtonBufferAllocator allocator = createProtonDefaultAllocator();
diff --git
a/protonj2/src/test/java/org/apache/qpid/protonj2/buffer/netty/ProtonBufferToNetty5AdapterTest.java
b/protonj2/src/test/java/org/apache/qpid/protonj2/buffer/netty/ProtonBufferToNetty5AdapterTest.java
index 5a99fc1d..4a957bea 100644
---
a/protonj2/src/test/java/org/apache/qpid/protonj2/buffer/netty/ProtonBufferToNetty5AdapterTest.java
+++
b/protonj2/src/test/java/org/apache/qpid/protonj2/buffer/netty/ProtonBufferToNetty5AdapterTest.java
@@ -265,6 +265,7 @@ public class ProtonBufferToNetty5AdapterTest {
}
}
+ @SuppressWarnings("resource")
@Test
public void
testOffsettedSetOfByteMustBoundsCheckWhenWriteOffsetIsNegative() {
try (Buffer buf = createProtonNetty5Buffer(8).fill((byte) 0)) {
@@ -277,6 +278,7 @@ public class ProtonBufferToNetty5AdapterTest {
}
}
+ @SuppressWarnings("resource")
@Test
public void
testOffsettedSetOfByteMustBoundsCheckWhenWriteOffsetAndSizeIsBeyondCapacity() {
try (Buffer buf = createProtonNetty5Buffer(8).fill((byte) 0)) {
@@ -306,6 +308,7 @@ public class ProtonBufferToNetty5AdapterTest {
}
}
+ @SuppressWarnings("resource")
@Test
public void
testOffsettedSetOfUnsignedByteMustBoundsCheckWhenWriteOffsetIsNegative() {
try (Buffer buf = createProtonNetty5Buffer(8).fill((byte) 0)) {
@@ -318,6 +321,7 @@ public class ProtonBufferToNetty5AdapterTest {
}
}
+ @SuppressWarnings("resource")
@Test
public void
testOffsettedSetOfUnsignedByteMustBoundsCheckWhenWriteOffsetAndSizeIsBeyondCapacity()
{
try (Buffer buf = createProtonNetty5Buffer(8).fill((byte) 0)) {
@@ -1493,6 +1497,7 @@ public class ProtonBufferToNetty5AdapterTest {
return bs;
}
+ @SuppressWarnings("resource")
private static void verifyInaccessible(Buffer buf) {
verifyReadInaccessible(buf);
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]