@@ -73,9 +73,14 @@ public void ensuresThatSetupPayloadCanBeRetained() {
73
73
@ Test
74
74
public void ensuresThatMonoFromRSocketConnectorCanBeUsedForMultipleSubscriptions () {
75
75
Payload setupPayload = ByteBufPayload .create ("TestData" , "TestMetadata" );
76
-
77
76
Assertions .assertThat (setupPayload .refCnt ()).isOne ();
78
77
78
+ // Keep the data and metadata around so we can try changing them independently
79
+ ByteBuf dataBuf = setupPayload .data ();
80
+ ByteBuf metadataBuf = setupPayload .metadata ();
81
+ dataBuf .retain ();
82
+ metadataBuf .retain ();
83
+
79
84
TestClientTransport testClientTransport = new TestClientTransport ();
80
85
Mono <RSocket > connectionMono =
81
86
RSocketConnector .create ().setupPayload (setupPayload ).connect (testClientTransport );
@@ -92,6 +97,15 @@ public void ensuresThatMonoFromRSocketConnectorCanBeUsedForMultipleSubscriptions
92
97
.expectComplete ()
93
98
.verify (Duration .ofMillis (100 ));
94
99
100
+ // Changing the original data and metadata should not impact the SetupPayload
101
+ dataBuf .writerIndex (dataBuf .readerIndex ());
102
+ dataBuf .writeChar ('d' );
103
+ dataBuf .release ();
104
+
105
+ metadataBuf .writerIndex (metadataBuf .readerIndex ());
106
+ metadataBuf .writeChar ('m' );
107
+ metadataBuf .release ();
108
+
95
109
Assertions .assertThat (testClientTransport .testConnection ().getSent ())
96
110
.hasSize (2 )
97
111
.allMatch (
@@ -100,7 +114,11 @@ public void ensuresThatMonoFromRSocketConnectorCanBeUsedForMultipleSubscriptions
100
114
return payload .getDataUtf8 ().equals ("TestData" )
101
115
&& payload .getMetadataUtf8 ().equals ("TestMetadata" );
102
116
})
103
- .allMatch (ReferenceCounted ::release );
117
+ .allMatch (
118
+ byteBuf -> {
119
+ System .out .println ("calling release " + byteBuf .refCnt ());
120
+ return byteBuf .release ();
121
+ });
104
122
Assertions .assertThat (setupPayload .refCnt ()).isZero ();
105
123
}
106
124
0 commit comments