Skip to content

Commit 76ad2ab

Browse files
committed
Replace casts to ByteBuffer after ByteBuffer.flip()
Prepare code compatibility for newer Java versions that introduced overrides for ByteBuffer.flip() returning ByteBuffer instead of Buffer. [closes #340]
1 parent abcf179 commit 76ad2ab

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

src/main/java/io/r2dbc/postgresql/message/frontend/GSSResponse.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ public final class GSSResponse implements FrontendMessage {
4646
*/
4747
public GSSResponse(ByteBuffer data) {
4848
Assert.requireNonNull(data, "data must not be null");
49-
50-
this.data = (ByteBuffer) data.flip();
49+
data.flip();
50+
this.data = data;
5151
}
5252

5353
@Override

src/main/java/io/r2dbc/postgresql/message/frontend/SASLInitialResponse.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,12 @@ public final class SASLInitialResponse implements FrontendMessage {
5050
* @throws IllegalArgumentException if {@code name} is {@code null}
5151
*/
5252
public SASLInitialResponse(@Nullable ByteBuffer initialResponse, String name) {
53-
this.initialResponse = initialResponse == null ? null : (ByteBuffer) initialResponse.flip();
53+
if (initialResponse == null) {
54+
this.initialResponse = null;
55+
} else {
56+
initialResponse.flip();
57+
this.initialResponse = initialResponse;
58+
}
5459
this.name = Assert.requireNonNull(name, "name must not be null");
5560
}
5661

src/main/java/io/r2dbc/postgresql/message/frontend/SASLResponse.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ public final class SASLResponse implements FrontendMessage {
4646
*/
4747
public SASLResponse(ByteBuffer data) {
4848
Assert.requireNonNull(data, "data must not be null");
49-
50-
this.data = (ByteBuffer) data.flip();
49+
data.flip();
50+
this.data = data;
5151
}
5252

5353
@Override

0 commit comments

Comments
 (0)