From 42588cb03e484565c24298ac834e8d0921dee9ec Mon Sep 17 00:00:00 2001 From: Brian Clozel Date: Wed, 26 Aug 2015 14:33:25 +0200 Subject: [PATCH] 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 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 --- .../socket/sockjs/client/UndertowXhrTransport.java | 13 +++++++------ .../web/socket/UndertowTestServer.java | 4 ++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/client/UndertowXhrTransport.java b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/client/UndertowXhrTransport.java index ad475eef37..f328857545 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/client/UndertowXhrTransport.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/client/UndertowXhrTransport.java @@ -35,14 +35,11 @@ import io.undertow.util.HeaderMap; import io.undertow.util.HttpString; import io.undertow.util.Methods; import io.undertow.util.StringReadChannelListener; -import org.xnio.ByteBufferSlicePool; import org.xnio.ChannelListener; import org.xnio.ChannelListeners; import org.xnio.IoUtils; import org.xnio.OptionMap; import org.xnio.Options; -import org.xnio.Pool; -import org.xnio.Pooled; import org.xnio.Xnio; import org.xnio.XnioWorker; import org.xnio.channels.StreamSinkChannel; @@ -96,19 +93,21 @@ public class UndertowXhrTransport extends AbstractXhrTransport implements XhrTra private final XnioWorker worker; - private final Pool bufferPool; + @SuppressWarnings("deprecation") + private final org.xnio.Pool bufferPool; public UndertowXhrTransport() throws IOException { this(OptionMap.builder().parse(Options.WORKER_NAME, "SockJSClient").getMap()); } + @SuppressWarnings("deprecation") public UndertowXhrTransport(OptionMap optionMap) throws IOException { Assert.notNull(optionMap, "OptionMap is required"); this.optionMap = optionMap; this.httpClient = UndertowClient.getInstance(); this.worker = Xnio.getInstance().createWorker(optionMap); - this.bufferPool = new ByteBufferSlicePool(1048, 1048); + this.bufferPool = new org.xnio.ByteBufferSlicePool(1048, 1048); } @@ -306,6 +305,7 @@ public class UndertowXhrTransport extends AbstractXhrTransport implements XhrTra public void completed(ClientExchange result) { result.setResponseListener(new ClientCallback() { @Override + @SuppressWarnings("deprecation") public void completed(final ClientExchange result) { responses.add(result.getResponse()); new StringReadChannelListener(result.getConnection().getBufferPool()) { @@ -389,6 +389,7 @@ public class UndertowXhrTransport extends AbstractXhrTransport implements XhrTra } @Override + @SuppressWarnings("deprecation") public void handleEvent(StreamSourceChannel channel) { if (this.session.isDisconnected()) { if (logger.isDebugEnabled()) { @@ -398,7 +399,7 @@ public class UndertowXhrTransport extends AbstractXhrTransport implements XhrTra throw new SockJsException("Session closed.", this.session.getId(), null); } - Pooled pooled = this.connection.getBufferPool().allocate(); + org.xnio.Pooled pooled = this.connection.getBufferPool().allocate(); try { int r; do { diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/UndertowTestServer.java b/spring-websocket/src/test/java/org/springframework/web/socket/UndertowTestServer.java index 7e2d009670..f5cbd3c294 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/UndertowTestServer.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/UndertowTestServer.java @@ -38,7 +38,6 @@ import org.springframework.util.SocketUtils; import org.springframework.web.context.WebApplicationContext; import org.springframework.web.servlet.DispatcherServlet; -import org.xnio.ByteBufferSlicePool; import org.xnio.OptionMap; import org.xnio.Xnio; @@ -70,6 +69,7 @@ public class UndertowTestServer implements WebSocketTestServer { } @Override + @SuppressWarnings("deprecation") public void deployConfig(WebApplicationContext wac, Filter... filters) { Assert.state(this.port != -1, "setup() was never called"); DispatcherServletInstanceFactory servletFactory = new DispatcherServletInstanceFactory(wac); @@ -78,7 +78,7 @@ public class UndertowTestServer implements WebSocketTestServer { WebSocketDeploymentInfo info = new WebSocketDeploymentInfo(); try { info.setWorker(Xnio.getInstance().createWorker(OptionMap.EMPTY)); - info.setBuffers(new ByteBufferSlicePool(1024,1024)); + info.setBuffers(new org.xnio.ByteBufferSlicePool(1024,1024)); } catch (IOException ex) { throw new IllegalStateException(ex);