Skip to content

Commit 90409cb

Browse files
committed
Renamed Undertow10BufferSupport to UndertowXnioBufferSupport
Issue: SPR-13366
1 parent 7f700cc commit 90409cb

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

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

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969

7070
/**
7171
* An XHR transport based on Undertow's {@link io.undertow.client.UndertowClient}.
72-
* Compatible with Undertow from version 1.0 to 1.3.
72+
* Compatible with Undertow 1.0 to 1.3, as of Spring Framework 4.2.2.
7373
*
7474
* <p>When used for testing purposes (e.g. load testing) or for specific use cases
7575
* (like HTTPS configuration), a custom OptionMap should be provided:
@@ -92,11 +92,11 @@
9292
*/
9393
public class UndertowXhrTransport extends AbstractXhrTransport {
9494

95-
private static final boolean undertow13Present = ClassUtils.isPresent("io.undertow.connector.ByteBufferPool",
96-
UndertowXhrTransport.class.getClassLoader());
97-
9895
private static final AttachmentKey<String> RESPONSE_BODY = AttachmentKey.create(String.class);
9996

97+
private static final boolean undertow13Present = ClassUtils.isPresent(
98+
"io.undertow.connector.ByteBufferPool", UndertowXhrTransport.class.getClassLoader());
99+
100100

101101
private final OptionMap optionMap;
102102

@@ -116,12 +116,8 @@ public UndertowXhrTransport(OptionMap optionMap) throws IOException {
116116
this.optionMap = optionMap;
117117
this.httpClient = UndertowClient.getInstance();
118118
this.worker = Xnio.getInstance().createWorker(optionMap);
119-
if (undertow13Present) {
120-
this.undertowBufferSupport = new Undertow13BufferSupport();
121-
}
122-
else {
123-
this.undertowBufferSupport = new Undertow10BufferSupport();
124-
}
119+
this.undertowBufferSupport =
120+
(undertow13Present ? new Undertow13BufferSupport() : new UndertowXnioBufferSupport());
125121
}
126122

127123

@@ -490,6 +486,7 @@ public void onFailure(Throwable failure) {
490486
}
491487
}
492488

489+
493490
private interface UndertowBufferSupport {
494491

495492
Object allocatePooledResource();
@@ -505,15 +502,16 @@ IoFuture<ClientConnection> httpClientConnect(UndertowClient httpClient, final UR
505502
final XnioWorker worker, OptionMap options);
506503
}
507504

508-
private class Undertow10BufferSupport implements UndertowBufferSupport {
505+
506+
private class UndertowXnioBufferSupport implements UndertowBufferSupport {
509507

510508
private final org.xnio.Pool<ByteBuffer> xnioBufferPool;
511509

512510
private final Method httpClientConnectCallbackMethod;
513511

514512
private final Method httpClientConnectMethod;
515513

516-
public Undertow10BufferSupport() {
514+
public UndertowXnioBufferSupport() {
517515
this.xnioBufferPool = new org.xnio.ByteBufferSlicePool(1048, 1048);
518516
this.httpClientConnectCallbackMethod = ReflectionUtils.findMethod(UndertowClient.class, "connect",
519517
ClientCallback.class, URI.class, XnioWorker.class, Pool.class, OptionMap.class);
@@ -543,7 +541,6 @@ public void httpClientConnect(UndertowClient httpClient, ClientCallback<ClientCo
543541
XnioWorker worker, OptionMap options) {
544542
ReflectionUtils.invokeMethod(httpClientConnectCallbackMethod, httpClient, listener, uri, worker,
545543
this.xnioBufferPool, options);
546-
547544
}
548545

549546
@Override
@@ -555,6 +552,7 @@ public IoFuture<ClientConnection> httpClientConnect(UndertowClient httpClient, U
555552
}
556553
}
557554

555+
558556
private class Undertow13BufferSupport implements UndertowBufferSupport {
559557

560558
private final ByteBufferPool undertowBufferPool;

0 commit comments

Comments
 (0)