From 389f79697015b0079ba3533db0b7f83ec7553a77 Mon Sep 17 00:00:00 2001 From: HuangXin Date: Sat, 9 Oct 2021 11:45:10 +0800 Subject: [PATCH] =?UTF-8?q?OCT=20REM:=201.=20=E4=BF=AE=E5=A4=8DUndertow?= =?UTF-8?q?=E5=90=AF=E5=8A=A8Pool=E8=AD=A6=E5=91=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../config/UndertowPoolCustomizer.java | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/main/java/com/dispose/config/UndertowPoolCustomizer.java diff --git a/src/main/java/com/dispose/config/UndertowPoolCustomizer.java b/src/main/java/com/dispose/config/UndertowPoolCustomizer.java new file mode 100644 index 00000000..db07f635 --- /dev/null +++ b/src/main/java/com/dispose/config/UndertowPoolCustomizer.java @@ -0,0 +1,30 @@ +package com.dispose.config; + +import io.undertow.server.DefaultByteBufferPool; +import io.undertow.websockets.jsr.WebSocketDeploymentInfo; +import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory; +import org.springframework.boot.web.server.WebServerFactoryCustomizer; +import org.springframework.stereotype.Component; + +/** + * The type Undertow pool customizer. + * + * @author + */ +@Component +public class UndertowPoolCustomizer implements WebServerFactoryCustomizer { + + /** + * Customize. + * + * @param factory the factory + */ + @Override + public void customize(UndertowServletWebServerFactory factory) { + factory.addDeploymentInfoCustomizers(deploymentInfo -> { + WebSocketDeploymentInfo webSocketDeploymentInfo = new WebSocketDeploymentInfo(); + webSocketDeploymentInfo.setBuffers(new DefaultByteBufferPool(false, 1024)); + deploymentInfo.addServletContextAttribute("io.undertow.websockets.jsr.WebSocketDeploymentInfo", webSocketDeploymentInfo); + }); + } +}