Skip to content

Commit 42588cb

Browse files
committed
Prepare Undertow 1.3.0 compatibility
Xnio 3.4.0 will introduce a new source of ByteBuffers: ByteBufferPool. Previously this feature was offered by Pooled/Pool/ByteBufferSlicePool; those classes are now marked as deprecated. As of 1.3.0.Beta9, Undertow still implements the following method in its ClientConnection interface, using those deprecated types: Pool<ByteBuffer> getBufferPool(); This commit prepares compatibility by suppressing warnings in order to avoid build failures in our build. Once appropriate changes are made in Undertow, a specific implementation with new types could be introduced. Issue: SPR-13366
1 parent e05fb49 commit 42588cb

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

spring-websocket/src/main/java/org/springframework/web/socket/sockjs/client/UndertowXhrTransport.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,11 @@
3535
import io.undertow.util.HttpString;
3636
import io.undertow.util.Methods;
3737
import io.undertow.util.StringReadChannelListener;
38-
import org.xnio.ByteBufferSlicePool;
3938
import org.xnio.ChannelListener;
4039
import org.xnio.ChannelListeners;
4140
import org.xnio.IoUtils;
4241
import org.xnio.OptionMap;
4342
import org.xnio.Options;
44-
import org.xnio.Pool;
45-
import org.xnio.Pooled;
4643
import org.xnio.Xnio;
4744
import org.xnio.XnioWorker;
4845
import org.xnio.channels.StreamSinkChannel;
@@ -96,19 +93,21 @@ public class UndertowXhrTransport extends AbstractXhrTransport implements XhrTra
9693

9794
private final XnioWorker worker;
9895

99-
private final Pool<ByteBuffer> bufferPool;
96+
@SuppressWarnings("deprecation")
97+
private final org.xnio.Pool<ByteBuffer> bufferPool;
10098

10199

102100
public UndertowXhrTransport() throws IOException {
103101
this(OptionMap.builder().parse(Options.WORKER_NAME, "SockJSClient").getMap());
104102
}
105103

104+
@SuppressWarnings("deprecation")
106105
public UndertowXhrTransport(OptionMap optionMap) throws IOException {
107106
Assert.notNull(optionMap, "OptionMap is required");
108107
this.optionMap = optionMap;
109108
this.httpClient = UndertowClient.getInstance();
110109
this.worker = Xnio.getInstance().createWorker(optionMap);
111-
this.bufferPool = new ByteBufferSlicePool(1048, 1048);
110+
this.bufferPool = new org.xnio.ByteBufferSlicePool(1048, 1048);
112111
}
113112

114113

@@ -306,6 +305,7 @@ private ClientCallback<ClientExchange> createRequestCallback(final String body,
306305
public void completed(ClientExchange result) {
307306
result.setResponseListener(new ClientCallback<ClientExchange>() {
308307
@Override
308+
@SuppressWarnings("deprecation")
309309
public void completed(final ClientExchange result) {
310310
responses.add(result.getResponse());
311311
new StringReadChannelListener(result.getConnection().getBufferPool()) {
@@ -389,6 +389,7 @@ public void setup(StreamSourceChannel channel) {
389389
}
390390

391391
@Override
392+
@SuppressWarnings("deprecation")
392393
public void handleEvent(StreamSourceChannel channel) {
393394
if (this.session.isDisconnected()) {
394395
if (logger.isDebugEnabled()) {
@@ -398,7 +399,7 @@ public void handleEvent(StreamSourceChannel channel) {
398399
throw new SockJsException("Session closed.", this.session.getId(), null);
399400
}
400401

401-
Pooled<ByteBuffer> pooled = this.connection.getBufferPool().allocate();
402+
org.xnio.Pooled<ByteBuffer> pooled = this.connection.getBufferPool().allocate();
402403
try {
403404
int r;
404405
do {

spring-websocket/src/test/java/org/springframework/web/socket/UndertowTestServer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
import org.springframework.web.context.WebApplicationContext;
3939
import org.springframework.web.servlet.DispatcherServlet;
4040

41-
import org.xnio.ByteBufferSlicePool;
4241
import org.xnio.OptionMap;
4342
import org.xnio.Xnio;
4443

@@ -70,6 +69,7 @@ public int getPort() {
7069
}
7170

7271
@Override
72+
@SuppressWarnings("deprecation")
7373
public void deployConfig(WebApplicationContext wac, Filter... filters) {
7474
Assert.state(this.port != -1, "setup() was never called");
7575
DispatcherServletInstanceFactory servletFactory = new DispatcherServletInstanceFactory(wac);
@@ -78,7 +78,7 @@ public void deployConfig(WebApplicationContext wac, Filter... filters) {
7878
WebSocketDeploymentInfo info = new WebSocketDeploymentInfo();
7979
try {
8080
info.setWorker(Xnio.getInstance().createWorker(OptionMap.EMPTY));
81-
info.setBuffers(new ByteBufferSlicePool(1024,1024));
81+
info.setBuffers(new org.xnio.ByteBufferSlicePool(1024,1024));
8282
}
8383
catch (IOException ex) {
8484
throw new IllegalStateException(ex);

0 commit comments

Comments
 (0)