This is an automated email from the ASF dual-hosted git repository. albumenj pushed a commit to branch 3.3 in repository https://gitbox.apache.org/repos/asf/dubbo.git
The following commit(s) were added to refs/heads/3.3 by this push: new 9600dc9ce6 Remove triple parameter in metadata (#14518) 9600dc9ce6 is described below commit 9600dc9ce67121579bb4680a5121e674791c2858 Author: TomlongTK <longqian...@maoyan.com> AuthorDate: Mon Aug 26 09:54:32 2024 +0800 Remove triple parameter in metadata (#14518) * Remove triple parameter in metadata * Refine default value get * Remove triple default value test * Remove unused import --------- Co-authored-by: Sean Yang <oxs...@gmail.com> --- .../dubbo/common/constants/CommonConstants.java | 2 + .../org/apache/dubbo/config/ProtocolConfig.java | 15 +-- .../apache/dubbo/config/context/ConfigManager.java | 27 ++++- .../apache/dubbo/config/nested/Http3Config.java | 64 ++++++---- .../org/apache/dubbo/config/nested/RestConfig.java | 34 ++++++ .../apache/dubbo/config/nested/TripleConfig.java | 129 ++++++++++++++------- .../apache/dubbo/config/ProtocolConfigTest.java | 26 ----- .../dubbo/config/bootstrap/DubboBootstrapTest.java | 24 ++-- .../integration/DefaultServiceURLCustomizer.java | 12 +- .../http12/netty4/h1/NettyHttp1Channel.java | 4 +- .../http12/netty4/h2/NettyH2StreamChannel.java | 2 +- .../dubbo/remoting/transport/netty4/Helper.java | 21 ++-- .../protocol/tri/TriHttp2RemoteFlowController.java | 2 +- .../rpc/protocol/tri/TripleHttp2Protocol.java | 38 +++--- .../rpc/protocol/tri/rest/cors/CorsUtils.java | 24 ++-- .../tri/rest/mapping/ContentNegotiator.java | 4 +- .../mapping/DefaultRequestMappingRegistry.java | 30 +++-- 17 files changed, 282 insertions(+), 176 deletions(-) diff --git a/dubbo-common/src/main/java/org/apache/dubbo/common/constants/CommonConstants.java b/dubbo-common/src/main/java/org/apache/dubbo/common/constants/CommonConstants.java index 61537707e3..b13782dfc6 100644 --- a/dubbo-common/src/main/java/org/apache/dubbo/common/constants/CommonConstants.java +++ b/dubbo-common/src/main/java/org/apache/dubbo/common/constants/CommonConstants.java @@ -635,6 +635,8 @@ public interface CommonConstants { String DUBBO_VERSIONS_KEY = "META-INF/dubbo-versions"; + String TRIPLE_PREFIX = "triple."; + /** * System-related VM properties */ diff --git a/dubbo-common/src/main/java/org/apache/dubbo/config/ProtocolConfig.java b/dubbo-common/src/main/java/org/apache/dubbo/config/ProtocolConfig.java index 08ca552351..0d04ef328e 100644 --- a/dubbo-common/src/main/java/org/apache/dubbo/config/ProtocolConfig.java +++ b/dubbo-common/src/main/java/org/apache/dubbo/config/ProtocolConfig.java @@ -36,8 +36,6 @@ import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_UNEXP /** * Configuration for the protocol. - * - * @export */ public class ProtocolConfig extends AbstractConfig { @@ -282,11 +280,6 @@ public class ProtocolConfig extends AbstractConfig { .getBean(PreferSerializationProvider.class) .getPreferSerialization(); } - - if (triple == null) { - triple = new TripleConfig(); - } - triple.checkDefault(); } @Parameter(excluded = true) @@ -635,6 +628,14 @@ public class ProtocolConfig extends AbstractConfig { return triple; } + @Parameter(excluded = true) + public TripleConfig getTripleOrDefault() { + if (triple == null) { + triple = new TripleConfig(); + } + return triple; + } + public void setTriple(TripleConfig triple) { this.triple = triple; } diff --git a/dubbo-common/src/main/java/org/apache/dubbo/config/context/ConfigManager.java b/dubbo-common/src/main/java/org/apache/dubbo/config/context/ConfigManager.java index 296f846668..7113d67d5e 100644 --- a/dubbo-common/src/main/java/org/apache/dubbo/config/context/ConfigManager.java +++ b/dubbo-common/src/main/java/org/apache/dubbo/config/context/ConfigManager.java @@ -73,8 +73,16 @@ public class ConfigManager extends AbstractConfigManager implements ApplicationE TracingConfig.class)); } - public static ProtocolConfig getProtocol(URL url) { - return url.getOrDefaultApplicationModel().getApplicationConfigManager().getOrAddProtocol(url.getProtocol()); + public static ProtocolConfig getProtocolOrDefault(URL url) { + return getProtocolOrDefault(url.getOrDefaultApplicationModel(), url.getProtocol()); + } + + public static ProtocolConfig getProtocolOrDefault(String idOrName) { + return getProtocolOrDefault(ApplicationModel.defaultModel(), idOrName); + } + + private static ProtocolConfig getProtocolOrDefault(ApplicationModel applicationModel, String idOrName) { + return applicationModel.getApplicationConfigManager().getOrAddProtocol(idOrName); } // ApplicationConfig correlative methods @@ -204,10 +212,19 @@ public class ConfigManager extends AbstractConfigManager implements ApplicationE if (protocol.isPresent()) { return protocol.get(); } - ProtocolConfig protocolConfig = new ProtocolConfig(idOrName); - addProtocol(protocolConfig); + + // Avoiding default protocol configuration overriding custom protocol configuration + // due to `getOrAddProtocol` being called when they are not loaded + idOrName = idOrName + ".default"; + protocol = getProtocol(idOrName); + if (protocol.isPresent()) { + return protocol.get(); + } + + ProtocolConfig protocolConfig = addConfig(new ProtocolConfig(idOrName)); + // addProtocol triggers refresh when other protocols exist in the ConfigManager. - // So refresh is only done when ProtocolConfig is not refreshed. + // so refresh is only done when ProtocolConfig is not refreshed. if (!protocolConfig.isRefreshed()) { protocolConfig.refresh(); } diff --git a/dubbo-common/src/main/java/org/apache/dubbo/config/nested/Http3Config.java b/dubbo-common/src/main/java/org/apache/dubbo/config/nested/Http3Config.java index 03a05012d1..72871e0924 100644 --- a/dubbo-common/src/main/java/org/apache/dubbo/config/nested/Http3Config.java +++ b/dubbo-common/src/main/java/org/apache/dubbo/config/nested/Http3Config.java @@ -16,12 +16,21 @@ */ package org.apache.dubbo.config.nested; +import org.apache.dubbo.config.support.Parameter; + import java.io.Serializable; public class Http3Config implements Serializable { private static final long serialVersionUID = -4443828713331129834L; + public static final int DEFAULT_INITIAL_MAX_DATA = 8_388_608; + public static final int DEFAULT_INITIAL_MAX_STREAM_DATA_BIDI_LOCAL = 1_048_576; + public static final int DEFAULT_INITIAL_MAX_STREAM_DATA_BIDI_REMOTE = 1_048_576; + public static final int DEFAULT_INITIAL_MAX_STREAM_DATA_UNI = 1_048_576; + public static final long DEFAULT_INITIAL_MAX_STREAMS_BIDI = 1_073_741_824; + public static final long DEFAULT_INITIAL_MAX_STREAMS_UNI = 1_073_741_824; + /** * Whether to enable HTTP/3 support * <p>The default value is false. @@ -142,6 +151,11 @@ public class Http3Config implements Serializable { return initialMaxData; } + @Parameter(excluded = true) + public int getInitialMaxDataOrDefault() { + return initialMaxData == null ? DEFAULT_INITIAL_MAX_DATA : initialMaxData; + } + public void setInitialMaxData(Integer initialMaxData) { this.initialMaxData = initialMaxData; } @@ -166,6 +180,13 @@ public class Http3Config implements Serializable { return initialMaxStreamDataBidiLocal; } + @Parameter(excluded = true) + public int getInitialMaxStreamDataBidiLocalOrDefault() { + return initialMaxStreamDataBidiLocal == null + ? DEFAULT_INITIAL_MAX_STREAM_DATA_BIDI_LOCAL + : initialMaxStreamDataBidiLocal; + } + public void setInitialMaxStreamDataBidiLocal(Integer initialMaxStreamDataBidiLocal) { this.initialMaxStreamDataBidiLocal = initialMaxStreamDataBidiLocal; } @@ -174,6 +195,13 @@ public class Http3Config implements Serializable { return initialMaxStreamDataBidiRemote; } + @Parameter(excluded = true) + public int getInitialMaxStreamDataBidiRemoteOrDefault() { + return initialMaxStreamDataBidiRemote == null + ? DEFAULT_INITIAL_MAX_STREAM_DATA_BIDI_REMOTE + : initialMaxStreamDataBidiRemote; + } + public void setInitialMaxStreamDataBidiRemote(Integer initialMaxStreamDataBidiRemote) { this.initialMaxStreamDataBidiRemote = initialMaxStreamDataBidiRemote; } @@ -182,6 +210,11 @@ public class Http3Config implements Serializable { return initialMaxStreamDataUni; } + @Parameter(excluded = true) + public int getInitialMaxStreamDataUniOrDefault() { + return initialMaxStreamDataUni == null ? DEFAULT_INITIAL_MAX_STREAM_DATA_UNI : initialMaxStreamDataUni; + } + public void setInitialMaxStreamDataUni(Integer initialMaxStreamDataUni) { this.initialMaxStreamDataUni = initialMaxStreamDataUni; } @@ -190,6 +223,11 @@ public class Http3Config implements Serializable { return initialMaxStreamsBidi; } + @Parameter(excluded = true) + public long getInitialMaxStreamsBidiOrDefault() { + return initialMaxStreamsBidi == null ? DEFAULT_INITIAL_MAX_STREAMS_BIDI : initialMaxStreamsBidi; + } + public void setInitialMaxStreamsBidi(Long initialMaxStreamsBidi) { this.initialMaxStreamsBidi = initialMaxStreamsBidi; } @@ -198,6 +236,11 @@ public class Http3Config implements Serializable { return initialMaxStreamsUni; } + @Parameter(excluded = true) + public long getInitialMaxStreamsUniOrDefault() { + return initialMaxStreamsUni == null ? DEFAULT_INITIAL_MAX_STREAMS_UNI : initialMaxStreamsUni; + } + public void setInitialMaxStreamsUni(Long initialMaxStreamsUni) { this.initialMaxStreamsUni = initialMaxStreamsUni; } @@ -241,25 +284,4 @@ public class Http3Config implements Serializable { public void setCcAlgorithm(String ccAlgorithm) { this.ccAlgorithm = ccAlgorithm; } - - public void checkDefault() { - if (initialMaxData == null) { - initialMaxData = 1 << 23; - } - if (initialMaxStreamDataBidiLocal == null) { - initialMaxStreamDataBidiLocal = 1 << 20; - } - if (initialMaxStreamDataBidiRemote == null) { - initialMaxStreamDataBidiRemote = 1 << 20; - } - if (initialMaxStreamDataUni == null) { - initialMaxStreamDataUni = 1 << 20; - } - if (initialMaxStreamsBidi == null) { - initialMaxStreamsBidi = (long) 1 << 30; - } - if (initialMaxStreamsUni == null) { - initialMaxStreamsUni = (long) 1 << 30; - } - } } diff --git a/dubbo-common/src/main/java/org/apache/dubbo/config/nested/RestConfig.java b/dubbo-common/src/main/java/org/apache/dubbo/config/nested/RestConfig.java index 51d0a236f5..88011e19bb 100644 --- a/dubbo-common/src/main/java/org/apache/dubbo/config/nested/RestConfig.java +++ b/dubbo-common/src/main/java/org/apache/dubbo/config/nested/RestConfig.java @@ -17,6 +17,7 @@ package org.apache.dubbo.config.nested; import org.apache.dubbo.config.support.Nested; +import org.apache.dubbo.config.support.Parameter; import java.io.Serializable; @@ -27,6 +28,11 @@ public class RestConfig implements Serializable { private static final long serialVersionUID = -8068568976367034755L; + public static final boolean DEFAULT_TRAILING_SLASH_MATCH = true; + public static final boolean DEFAULT_SUFFIX_PATTERN_MATCH = true; + public static final boolean DEFAULT_CASE_SENSITIVE_MATCH = true; + public static final String DEFAULT_FORMAT_PARAMETER_NAME = "format"; + /** * Whether path matching should be match paths with a trailing slash. * If enabled, a method mapped to "/users" also matches to "/users/". @@ -66,6 +72,11 @@ public class RestConfig implements Serializable { return trailingSlashMatch; } + @Parameter(excluded = true) + public boolean getTrailingSlashMatchOrDefault() { + return trailingSlashMatch == null ? DEFAULT_TRAILING_SLASH_MATCH : trailingSlashMatch; + } + public void setTrailingSlashMatch(Boolean trailingSlashMatch) { this.trailingSlashMatch = trailingSlashMatch; } @@ -74,6 +85,11 @@ public class RestConfig implements Serializable { return suffixPatternMatch; } + @Parameter(excluded = true) + public boolean getSuffixPatternMatchOrDefault() { + return suffixPatternMatch == null ? DEFAULT_SUFFIX_PATTERN_MATCH : suffixPatternMatch; + } + public void setSuffixPatternMatch(Boolean suffixPatternMatch) { this.suffixPatternMatch = suffixPatternMatch; } @@ -82,6 +98,11 @@ public class RestConfig implements Serializable { return caseSensitiveMatch; } + @Parameter(excluded = true) + public boolean getCaseSensitiveMatchOrDefault() { + return caseSensitiveMatch == null ? DEFAULT_CASE_SENSITIVE_MATCH : caseSensitiveMatch; + } + public void setCaseSensitiveMatch(Boolean caseSensitiveMatch) { this.caseSensitiveMatch = caseSensitiveMatch; } @@ -90,6 +111,11 @@ public class RestConfig implements Serializable { return formatParameterName; } + @Parameter(excluded = true) + public String getFormatParameterNameOrDefault() { + return formatParameterName == null ? DEFAULT_FORMAT_PARAMETER_NAME : formatParameterName; + } + public void setFormatParameterName(String formatParameterName) { this.formatParameterName = formatParameterName; } @@ -98,6 +124,14 @@ public class RestConfig implements Serializable { return cors; } + @Parameter(excluded = true) + public CorsConfig getCorsOrDefault() { + if (cors == null) { + cors = new CorsConfig(); + } + return cors; + } + public void setCors(CorsConfig cors) { this.cors = cors; } diff --git a/dubbo-common/src/main/java/org/apache/dubbo/config/nested/TripleConfig.java b/dubbo-common/src/main/java/org/apache/dubbo/config/nested/TripleConfig.java index 745e528639..2cf3d79543 100644 --- a/dubbo-common/src/main/java/org/apache/dubbo/config/nested/TripleConfig.java +++ b/dubbo-common/src/main/java/org/apache/dubbo/config/nested/TripleConfig.java @@ -17,6 +17,7 @@ package org.apache.dubbo.config.nested; import org.apache.dubbo.config.support.Nested; +import org.apache.dubbo.config.support.Parameter; import java.io.Serializable; @@ -27,6 +28,19 @@ public class TripleConfig implements Serializable { private static final long serialVersionUID = -3682252713701362155L; + public static final int DEFAULT_MAX_BODY_SIZE = 8_388_608; + public static final int DEFAULT_MAX_RESPONSE_BODY_SIZE = 8_388_608; + public static final int DEFAULT_MAX_CHUNK_SIZE = 8_388_608; + public static final int DEFAULT_MAX_HEADER_SIZE = 8_192; + public static final int DEFAULT_MAX_INITIAL_LINE_LENGTH = 4_096; + public static final int DEFAULT_INITIAL_BUFFER_SIZE = 16_384; + public static final int DEFAULT_HEADER_TABLE_SIZE = 4_096; + public static final boolean DEFAULT_ENABLE_PUSH = false; + public static final int DEFAULT_MAX_CONCURRENT_STREAMS = Integer.MAX_VALUE; + public static final int DEFAULT_INITIAL_WINDOW_SIZE = 8_388_608; + public static final int DEFAULT_MAX_FRAME_SIZE = 8_388_608; + public static final int DEFAULT_MAX_HEADER_LIST_SIZE = 32_768; + /** * Whether enable verbose mode. * When true, the application will produce detailed logging output @@ -143,6 +157,11 @@ public class TripleConfig implements Serializable { return maxBodySize; } + @Parameter(excluded = true) + public int getMaxBodySizeOrDefault() { + return maxBodySize == null ? DEFAULT_MAX_BODY_SIZE : maxBodySize; + } + public void setMaxBodySize(Integer maxBodySize) { this.maxBodySize = maxBodySize; } @@ -151,6 +170,11 @@ public class TripleConfig implements Serializable { return maxResponseBodySize; } + @Parameter(excluded = true) + public int getMaxResponseBodySizeOrDefault() { + return maxResponseBodySize == null ? DEFAULT_MAX_RESPONSE_BODY_SIZE : maxResponseBodySize; + } + public void setMaxResponseBodySize(Integer maxResponseBodySize) { this.maxResponseBodySize = maxResponseBodySize; } @@ -159,6 +183,11 @@ public class TripleConfig implements Serializable { return maxChunkSize; } + @Parameter(excluded = true) + public int getMaxChunkSizeOrDefault() { + return maxChunkSize == null ? DEFAULT_MAX_CHUNK_SIZE : maxChunkSize; + } + public void setMaxChunkSize(Integer maxChunkSize) { this.maxChunkSize = maxChunkSize; } @@ -167,6 +196,11 @@ public class TripleConfig implements Serializable { return maxHeaderSize; } + @Parameter(excluded = true) + public int getMaxHeaderSizeOrDefault() { + return maxHeaderSize == null ? DEFAULT_MAX_HEADER_SIZE : maxHeaderSize; + } + public void setMaxHeaderSize(Integer maxHeaderSize) { this.maxHeaderSize = maxHeaderSize; } @@ -175,6 +209,11 @@ public class TripleConfig implements Serializable { return maxInitialLineLength; } + @Parameter(excluded = true) + public int getMaxInitialLineLengthOrDefault() { + return maxInitialLineLength == null ? DEFAULT_MAX_INITIAL_LINE_LENGTH : maxInitialLineLength; + } + public void setMaxInitialLineLength(Integer maxInitialLineLength) { this.maxInitialLineLength = maxInitialLineLength; } @@ -183,6 +222,11 @@ public class TripleConfig implements Serializable { return initialBufferSize; } + @Parameter(excluded = true) + public int getInitialBufferSizeOrDefault() { + return initialBufferSize == null ? DEFAULT_INITIAL_BUFFER_SIZE : initialBufferSize; + } + public void setInitialBufferSize(Integer initialBufferSize) { this.initialBufferSize = initialBufferSize; } @@ -191,6 +235,11 @@ public class TripleConfig implements Serializable { return headerTableSize; } + @Parameter(excluded = true) + public int getHeaderTableSizeOrDefault() { + return headerTableSize == null ? DEFAULT_HEADER_TABLE_SIZE : headerTableSize; + } + public void setHeaderTableSize(Integer headerTableSize) { this.headerTableSize = headerTableSize; } @@ -199,6 +248,11 @@ public class TripleConfig implements Serializable { return enablePush; } + @Parameter(excluded = true) + public boolean getEnablePushOrDefault() { + return enablePush == null ? DEFAULT_ENABLE_PUSH : enablePush; + } + public void setEnablePush(Boolean enablePush) { this.enablePush = enablePush; } @@ -207,6 +261,11 @@ public class TripleConfig implements Serializable { return maxConcurrentStreams; } + @Parameter(excluded = true) + public int getMaxConcurrentStreamsOrDefault() { + return maxConcurrentStreams == null ? DEFAULT_MAX_CONCURRENT_STREAMS : maxConcurrentStreams; + } + public void setMaxConcurrentStreams(Integer maxConcurrentStreams) { this.maxConcurrentStreams = maxConcurrentStreams; } @@ -215,6 +274,11 @@ public class TripleConfig implements Serializable { return initialWindowSize; } + @Parameter(excluded = true) + public int getInitialWindowSizeOrDefault() { + return initialWindowSize == null ? DEFAULT_INITIAL_WINDOW_SIZE : initialWindowSize; + } + public void setInitialWindowSize(Integer initialWindowSize) { this.initialWindowSize = initialWindowSize; } @@ -223,6 +287,11 @@ public class TripleConfig implements Serializable { return maxFrameSize; } + @Parameter(excluded = true) + public int getMaxFrameSizeOrDefault() { + return maxFrameSize == null ? DEFAULT_MAX_FRAME_SIZE : maxFrameSize; + } + public void setMaxFrameSize(Integer maxFrameSize) { this.maxFrameSize = maxFrameSize; } @@ -231,6 +300,11 @@ public class TripleConfig implements Serializable { return maxHeaderListSize; } + @Parameter(excluded = true) + public int getMaxHeaderListSizeOrDefault() { + return maxHeaderListSize == null ? DEFAULT_MAX_HEADER_LIST_SIZE : maxHeaderListSize; + } + public void setMaxHeaderListSize(Integer maxHeaderListSize) { this.maxHeaderListSize = maxHeaderListSize; } @@ -239,6 +313,14 @@ public class TripleConfig implements Serializable { return rest; } + @Parameter(excluded = true) + public RestConfig getRestOrDefault() { + if (rest == null) { + rest = new RestConfig(); + } + return rest; + } + public void setRest(RestConfig rest) { this.rest = rest; } @@ -247,6 +329,14 @@ public class TripleConfig implements Serializable { return http3; } + @Parameter(excluded = true) + public Http3Config getHttp3OrDefault() { + if (http3 == null) { + http3 = new Http3Config(); + } + return http3; + } + public void setHttp3(Http3Config http3) { this.http3 = http3; } @@ -258,43 +348,4 @@ public class TripleConfig implements Serializable { public void setServlet(ServletConfig servlet) { this.servlet = servlet; } - - public void checkDefault() { - if (maxBodySize == null) { - maxBodySize = 1 << 23; - } - if (maxResponseBodySize == null) { - maxResponseBodySize = 1 << 23; - } - if (maxChunkSize == null) { - maxChunkSize = 1 << 23; - } - if (maxHeaderSize == null) { - maxHeaderSize = 8192; - } - if (maxInitialLineLength == null) { - maxInitialLineLength = 4096; - } - if (initialBufferSize == null) { - initialBufferSize = 16384; - } - if (headerTableSize == null) { - headerTableSize = 4096; - } - if (enablePush == null) { - enablePush = false; - } - if (maxConcurrentStreams == null) { - maxConcurrentStreams = Integer.MAX_VALUE; - } - if (initialWindowSize == null) { - initialWindowSize = 1 << 23; - } - if (maxFrameSize == null) { - maxFrameSize = 1 << 23; - } - if (maxHeaderListSize == null) { - maxHeaderListSize = 1 << 15; - } - } } diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/ProtocolConfigTest.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/ProtocolConfigTest.java index ef198ebf6c..31e3679c27 100644 --- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/ProtocolConfigTest.java +++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/ProtocolConfigTest.java @@ -35,8 +35,6 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.hasEntry; import static org.hamcrest.Matchers.is; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNull; class ProtocolConfigTest { @@ -57,30 +55,6 @@ class ProtocolConfigTest { DubboBootstrap.reset(); } - @Test - void testDefaultTripleConfig() { - ProtocolConfig protocol = new ProtocolConfig(); - protocol.refresh(); - Map<String, String> parameters = new HashMap<>(); - ProtocolConfig.appendParameters(parameters, protocol); - assertThat(parameters.isEmpty(), is(false)); - // http2 default config - assertEquals(4096, Integer.parseInt(parameters.get("triple.header.table.size"))); - assertFalse(Boolean.parseBoolean(parameters.get("triple.enable.push"))); - assertEquals(Integer.MAX_VALUE, Integer.parseInt(parameters.get("triple.max.concurrent.streams"))); - assertEquals(1 << 23, Integer.parseInt(parameters.get("triple.initial.window.size"))); - assertEquals(1 << 23, Integer.parseInt(parameters.get("triple.max.frame.size"))); - assertEquals(1 << 15, Integer.parseInt(parameters.get("triple.max.header.list.size"))); - - // http1 default config - assertEquals(1 << 23, Integer.parseInt(parameters.get("triple.max.body.size"))); - assertEquals(1 << 23, Integer.parseInt(parameters.get("triple.max.response.body.size"))); - assertEquals(1 << 23, Integer.parseInt(parameters.get("triple.max.chunk.size"))); - assertEquals(8192, Integer.parseInt(parameters.get("triple.max.header.size"))); - assertEquals(4096, Integer.parseInt(parameters.get("triple.max.initial.line.length"))); - assertEquals(16384, Integer.parseInt(parameters.get("triple.initial.buffer.size"))); - } - @Test void testName() { ProtocolConfig protocol = new ProtocolConfig(); diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/bootstrap/DubboBootstrapTest.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/bootstrap/DubboBootstrapTest.java index d46740eb95..05ea205238 100644 --- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/bootstrap/DubboBootstrapTest.java +++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/bootstrap/DubboBootstrapTest.java @@ -502,20 +502,20 @@ class DubboBootstrapTest { .orElse(null); // check custom value - Assertions.assertEquals(50, tripleConfig.getMaxBodySize()); - Assertions.assertEquals(100, tripleConfig.getMaxResponseBodySize()); + Assertions.assertEquals(50, tripleConfig.getMaxBodySizeOrDefault()); + Assertions.assertEquals(100, tripleConfig.getMaxResponseBodySizeOrDefault()); // check default value - Assertions.assertEquals(1 << 23, tripleConfig.getMaxChunkSize()); - Assertions.assertEquals(8192, tripleConfig.getMaxHeaderSize()); - Assertions.assertEquals(4096, tripleConfig.getMaxInitialLineLength()); - Assertions.assertEquals(16384, tripleConfig.getInitialBufferSize()); - Assertions.assertEquals(4096, tripleConfig.getHeaderTableSize()); - Assertions.assertFalse(tripleConfig.getEnablePush()); - Assertions.assertEquals(Integer.MAX_VALUE, tripleConfig.getMaxConcurrentStreams()); - Assertions.assertEquals(1 << 23, tripleConfig.getInitialWindowSize()); - Assertions.assertEquals(1 << 23, tripleConfig.getMaxFrameSize()); - Assertions.assertEquals(1 << 15, tripleConfig.getMaxHeaderListSize()); + Assertions.assertEquals(1 << 23, tripleConfig.getMaxChunkSizeOrDefault()); + Assertions.assertEquals(8192, tripleConfig.getMaxHeaderSizeOrDefault()); + Assertions.assertEquals(4096, tripleConfig.getMaxInitialLineLengthOrDefault()); + Assertions.assertEquals(16384, tripleConfig.getInitialBufferSizeOrDefault()); + Assertions.assertEquals(4096, tripleConfig.getHeaderTableSizeOrDefault()); + Assertions.assertFalse(tripleConfig.getEnablePushOrDefault()); + Assertions.assertEquals(Integer.MAX_VALUE, tripleConfig.getMaxConcurrentStreamsOrDefault()); + Assertions.assertEquals(1 << 23, tripleConfig.getInitialWindowSizeOrDefault()); + Assertions.assertEquals(1 << 23, tripleConfig.getMaxFrameSizeOrDefault()); + Assertions.assertEquals(1 << 15, tripleConfig.getMaxHeaderListSizeOrDefault()); } private ExporterDeployListener getListener(ApplicationModel model) { diff --git a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/DefaultServiceURLCustomizer.java b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/DefaultServiceURLCustomizer.java index 2473df54b7..f900abe245 100644 --- a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/DefaultServiceURLCustomizer.java +++ b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/DefaultServiceURLCustomizer.java @@ -42,6 +42,7 @@ import static org.apache.dubbo.common.constants.CommonConstants.REGISTRY_LOCAL_F import static org.apache.dubbo.common.constants.CommonConstants.THREADPOOL_KEY; import static org.apache.dubbo.common.constants.CommonConstants.THREADS_KEY; import static org.apache.dubbo.common.constants.CommonConstants.THREAD_NAME_KEY; +import static org.apache.dubbo.common.constants.CommonConstants.TRIPLE_PREFIX; import static org.apache.dubbo.common.constants.FilterConstants.VALIDATION_KEY; import static org.apache.dubbo.common.constants.QosConstants.ACCEPT_FOREIGN_IP; import static org.apache.dubbo.common.constants.QosConstants.QOS_ENABLE; @@ -80,6 +81,8 @@ public class DefaultServiceURLCustomizer implements ServiceURLCustomizer { THREADS_KEY }; + private static final String[] excludedPrefixes = new String[] {HIDE_KEY_PREFIX, TRIPLE_PREFIX}; + @Override public URL customize(URL serviceURL, ApplicationModel applicationModel) { boolean simplified = (boolean) serviceURL.getAttribute(SIMPLIFIED_KEY, false); @@ -112,7 +115,14 @@ public class DefaultServiceURLCustomizer implements ServiceURLCustomizer { Map<String, String> params = url.getParameters(); if (CollectionUtils.isNotEmptyMap(params)) { return params.keySet().stream() - .filter(k -> k.startsWith(HIDE_KEY_PREFIX)) + .filter(k -> { + for (String excludedPrefix : excludedPrefixes) { + if (k.startsWith(excludedPrefix)) { + return true; + } + } + return false; + }) .toArray(String[]::new); } return new String[0]; diff --git a/dubbo-remoting/dubbo-remoting-http12/src/main/java/org/apache/dubbo/remoting/http12/netty4/h1/NettyHttp1Channel.java b/dubbo-remoting/dubbo-remoting-http12/src/main/java/org/apache/dubbo/remoting/http12/netty4/h1/NettyHttp1Channel.java index 086dde1afd..19d0c807d0 100644 --- a/dubbo-remoting/dubbo-remoting-http12/src/main/java/org/apache/dubbo/remoting/http12/netty4/h1/NettyHttp1Channel.java +++ b/dubbo-remoting/dubbo-remoting-http12/src/main/java/org/apache/dubbo/remoting/http12/netty4/h1/NettyHttp1Channel.java @@ -56,8 +56,8 @@ public class NettyHttp1Channel implements HttpChannel { @Override public HttpOutputMessage newOutputMessage() { - return new Http1OutputMessage( - new LimitedByteBufOutputStream(channel.alloc().buffer(), tripleConfig.getMaxResponseBodySize())); + return new Http1OutputMessage(new LimitedByteBufOutputStream( + channel.alloc().buffer(), tripleConfig.getMaxResponseBodySizeOrDefault())); } @Override diff --git a/dubbo-remoting/dubbo-remoting-http12/src/main/java/org/apache/dubbo/remoting/http12/netty4/h2/NettyH2StreamChannel.java b/dubbo-remoting/dubbo-remoting-http12/src/main/java/org/apache/dubbo/remoting/http12/netty4/h2/NettyH2StreamChannel.java index edebd985cc..c28449d28b 100644 --- a/dubbo-remoting/dubbo-remoting-http12/src/main/java/org/apache/dubbo/remoting/http12/netty4/h2/NettyH2StreamChannel.java +++ b/dubbo-remoting/dubbo-remoting-http12/src/main/java/org/apache/dubbo/remoting/http12/netty4/h2/NettyH2StreamChannel.java @@ -63,7 +63,7 @@ public class NettyH2StreamChannel implements H2StreamChannel { public Http2OutputMessage newOutputMessage(boolean endStream) { ByteBuf buffer = http2StreamChannel.alloc().buffer(); ByteBufOutputStream outputStream = - new LimitedByteBufOutputStream(buffer, tripleConfig.getMaxResponseBodySize()); + new LimitedByteBufOutputStream(buffer, tripleConfig.getMaxResponseBodySizeOrDefault()); return new Http2OutputMessageFrame(outputStream, endStream); } diff --git a/dubbo-remoting/dubbo-remoting-http3/src/main/java/org/apache/dubbo/remoting/transport/netty4/Helper.java b/dubbo-remoting/dubbo-remoting-http3/src/main/java/org/apache/dubbo/remoting/transport/netty4/Helper.java index 6df29c4f06..654831fa14 100644 --- a/dubbo-remoting/dubbo-remoting-http3/src/main/java/org/apache/dubbo/remoting/transport/netty4/Helper.java +++ b/dubbo-remoting/dubbo-remoting-http3/src/main/java/org/apache/dubbo/remoting/transport/netty4/Helper.java @@ -19,7 +19,6 @@ package org.apache.dubbo.remoting.transport.netty4; import org.apache.dubbo.common.URL; import org.apache.dubbo.config.context.ConfigManager; import org.apache.dubbo.config.nested.Http3Config; -import org.apache.dubbo.config.nested.TripleConfig; import io.netty.incubator.codec.quic.QuicCodecBuilder; import io.netty.incubator.codec.quic.QuicCongestionControlAlgorithm; @@ -30,18 +29,14 @@ final class Helper { @SuppressWarnings("unchecked") static <T extends QuicCodecBuilder<T>> T configCodec(QuicCodecBuilder<T> builder, URL url) { - TripleConfig tripleConfig = ConfigManager.getProtocol(url).getTriple(); - Http3Config config = tripleConfig.getHttp3(); - if (config == null) { - config = new Http3Config(); - } - config.checkDefault(); - builder.initialMaxData(config.getInitialMaxData()) - .initialMaxStreamDataBidirectionalLocal(config.getInitialMaxStreamDataBidiLocal()) - .initialMaxStreamDataBidirectionalRemote(config.getInitialMaxStreamDataBidiRemote()) - .initialMaxStreamDataUnidirectional(config.getInitialMaxStreamDataUni()) - .initialMaxStreamsBidirectional(config.getInitialMaxStreamsBidi()) - .initialMaxStreamsUnidirectional(config.getInitialMaxStreamsUni()); + Http3Config config = + ConfigManager.getProtocolOrDefault(url).getTripleOrDefault().getHttp3OrDefault(); + builder.initialMaxData(config.getInitialMaxDataOrDefault()) + .initialMaxStreamDataBidirectionalLocal(config.getInitialMaxStreamDataBidiLocalOrDefault()) + .initialMaxStreamDataBidirectionalRemote(config.getInitialMaxStreamDataBidiRemoteOrDefault()) + .initialMaxStreamDataUnidirectional(config.getInitialMaxStreamDataUniOrDefault()) + .initialMaxStreamsBidirectional(config.getInitialMaxStreamsBidiOrDefault()) + .initialMaxStreamsUnidirectional(config.getInitialMaxStreamsUniOrDefault()); if (config.getRecvQueueLen() != null && config.getSendQueueLen() != null) { builder.datagram(config.getRecvQueueLen(), config.getSendQueueLen()); diff --git a/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/TriHttp2RemoteFlowController.java b/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/TriHttp2RemoteFlowController.java index e2eb02f6f0..fc08bc94cc 100644 --- a/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/TriHttp2RemoteFlowController.java +++ b/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/TriHttp2RemoteFlowController.java @@ -82,7 +82,7 @@ public class TriHttp2RemoteFlowController implements Http2RemoteFlowController { TripleConfig config) { this.connection = checkNotNull(connection, "connection"); this.streamByteDistributor = checkNotNull(streamByteDistributor, "streamWriteDistributor"); - this.initialWindowSize = config.getInitialWindowSize(); + this.initialWindowSize = config.getInitialWindowSizeOrDefault(); // Add a flow state for the connection. stateKey = connection.newKey(); diff --git a/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/TripleHttp2Protocol.java b/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/TripleHttp2Protocol.java index aeb3e7f3be..a04f4a9d21 100644 --- a/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/TripleHttp2Protocol.java +++ b/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/TripleHttp2Protocol.java @@ -87,16 +87,16 @@ public class TripleHttp2Protocol extends AbstractWireProtocol implements ScopeMo @Override public void configClientPipeline(URL url, ChannelOperator operator, ContextOperator contextOperator) { - TripleConfig tripleConfig = ConfigManager.getProtocol(url).getTriple(); + TripleConfig tripleConfig = ConfigManager.getProtocolOrDefault(url).getTripleOrDefault(); Http2FrameCodec codec = Http2FrameCodecBuilder.forClient() .gracefulShutdownTimeoutMillis(10000) .initialSettings(new Http2Settings() - .headerTableSize(tripleConfig.getHeaderTableSize()) - .pushEnabled(tripleConfig.getEnablePush()) - .maxConcurrentStreams(tripleConfig.getMaxConcurrentStreams()) - .initialWindowSize(tripleConfig.getInitialWindowSize()) - .maxFrameSize(tripleConfig.getMaxFrameSize()) - .maxHeaderListSize(tripleConfig.getMaxHeaderListSize())) + .headerTableSize(tripleConfig.getHeaderTableSizeOrDefault()) + .pushEnabled(tripleConfig.getEnablePushOrDefault()) + .maxConcurrentStreams(tripleConfig.getMaxConcurrentStreamsOrDefault()) + .initialWindowSize(tripleConfig.getInitialWindowSizeOrDefault()) + .maxFrameSize(tripleConfig.getMaxFrameSizeOrDefault()) + .maxHeaderListSize(tripleConfig.getMaxHeaderListSizeOrDefault())) .frameLogger(CLIENT_LOGGER) .validateHeaders(false) .build(); @@ -132,13 +132,13 @@ public class TripleHttp2Protocol extends AbstractWireProtocol implements ScopeMo @SuppressWarnings("deprecation") private void configurerHttp1Handlers(URL url, List<ChannelHandler> handlers) { - TripleConfig tripleConfig = ConfigManager.getProtocol(url).getTriple(); + TripleConfig tripleConfig = ConfigManager.getProtocolOrDefault(url).getTripleOrDefault(); HttpServerCodec sourceCodec = new HttpServerCodec( - tripleConfig.getMaxInitialLineLength(), - tripleConfig.getMaxHeaderSize(), - tripleConfig.getMaxChunkSize(), + tripleConfig.getMaxInitialLineLengthOrDefault(), + tripleConfig.getMaxHeaderSizeOrDefault(), + tripleConfig.getMaxChunkSizeOrDefault(), false, - tripleConfig.getInitialBufferSize()); + tripleConfig.getInitialBufferSizeOrDefault()); handlers.add(new ChannelHandlerPretender(sourceCodec)); // Triple protocol http1 upgrade support handlers.add(new ChannelHandlerPretender(new HttpServerUpgradeHandler( @@ -160,7 +160,7 @@ public class TripleHttp2Protocol extends AbstractWireProtocol implements ScopeMo // If the upgrade was successful, remove the message from the output list // so that it's not propagated to the next handler. This request will // be propagated as a user event instead. - handlers.add(new ChannelHandlerPretender(new HttpObjectAggregator(tripleConfig.getMaxBodySize()))); + handlers.add(new ChannelHandlerPretender(new HttpObjectAggregator(tripleConfig.getMaxBodySizeOrDefault()))); handlers.add(new ChannelHandlerPretender(new NettyHttp1Codec())); handlers.add(new ChannelHandlerPretender(new NettyHttp1ConnectionHandler( url, frameworkModel, tripleConfig, DefaultHttp11ServerTransportListenerFactory.INSTANCE))); @@ -179,7 +179,7 @@ public class TripleHttp2Protocol extends AbstractWireProtocol implements ScopeMo } private void configurerHttp2Handlers(URL url, List<ChannelHandler> handlers) { - TripleConfig tripleConfig = ConfigManager.getProtocol(url).getTriple(); + TripleConfig tripleConfig = ConfigManager.getProtocolOrDefault(url).getTripleOrDefault(); Http2FrameCodec codec = buildHttp2FrameCodec(tripleConfig); Http2MultiplexHandler handler = buildHttp2MultiplexHandler(url, tripleConfig); handlers.add(new ChannelHandlerPretender(new HttpWriteQueueHandler())); @@ -196,11 +196,11 @@ public class TripleHttp2Protocol extends AbstractWireProtocol implements ScopeMo connection.remote().flowController(new TriHttp2RemoteFlowController(connection, tripleConfig))) .gracefulShutdownTimeoutMillis(10000) .initialSettings(new Http2Settings() - .headerTableSize(tripleConfig.getHeaderTableSize()) - .maxConcurrentStreams(tripleConfig.getMaxConcurrentStreams()) - .initialWindowSize(tripleConfig.getInitialWindowSize()) - .maxFrameSize(tripleConfig.getMaxFrameSize()) - .maxHeaderListSize(tripleConfig.getMaxHeaderListSize())) + .headerTableSize(tripleConfig.getHeaderTableSizeOrDefault()) + .maxConcurrentStreams(tripleConfig.getMaxConcurrentStreamsOrDefault()) + .initialWindowSize(tripleConfig.getInitialWindowSizeOrDefault()) + .maxFrameSize(tripleConfig.getMaxFrameSizeOrDefault()) + .maxHeaderListSize(tripleConfig.getMaxHeaderListSizeOrDefault())) .frameLogger(SERVER_LOGGER) .validateHeaders(false) .build(); diff --git a/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/rest/cors/CorsUtils.java b/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/rest/cors/CorsUtils.java index a9aab0bd91..a71cf9ec00 100644 --- a/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/rest/cors/CorsUtils.java +++ b/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/rest/cors/CorsUtils.java @@ -17,10 +17,11 @@ package org.apache.dubbo.rpc.protocol.tri.rest.cors; import org.apache.dubbo.common.config.Configuration; -import org.apache.dubbo.common.config.ConfigurationUtils; +import org.apache.dubbo.common.constants.CommonConstants; import org.apache.dubbo.common.utils.StringUtils; +import org.apache.dubbo.config.context.ConfigManager; +import org.apache.dubbo.config.nested.CorsConfig; import org.apache.dubbo.rpc.model.FrameworkModel; -import org.apache.dubbo.rpc.protocol.tri.rest.RestConstants; import org.apache.dubbo.rpc.protocol.tri.rest.mapping.meta.CorsMeta; public class CorsUtils { @@ -28,16 +29,17 @@ public class CorsUtils { private CorsUtils() {} public static CorsMeta getGlobalCorsMeta(FrameworkModel frameworkModel) { - Configuration config = ConfigurationUtils.getGlobalConfiguration(frameworkModel.defaultApplication()); - - String maxAge = config.getString(RestConstants.MAX_AGE); + CorsConfig config = ConfigManager.getProtocolOrDefault(CommonConstants.TRIPLE) + .getTripleOrDefault() + .getRestOrDefault() + .getCorsOrDefault(); return CorsMeta.builder() - .allowedOrigins(getValues(config, RestConstants.ALLOWED_ORIGINS)) - .allowedMethods(getValues(config, RestConstants.ALLOWED_METHODS)) - .allowedHeaders(getValues(config, RestConstants.ALLOWED_HEADERS)) - .allowCredentials(config.getString(RestConstants.ALLOW_CREDENTIALS)) - .exposedHeaders(getValues(config, RestConstants.EXPOSED_HEADERS)) - .maxAge(maxAge == null ? null : Long.valueOf(maxAge)) + .allowedOrigins(config.getAllowedOrigins()) + .allowedMethods(config.getAllowedMethods()) + .allowedHeaders(config.getAllowedHeaders()) + .allowCredentials(config.getAllowCredentials()) + .exposedHeaders(config.getExposedHeaders()) + .maxAge(config.getMaxAge()) .build(); } diff --git a/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/rest/mapping/ContentNegotiator.java b/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/rest/mapping/ContentNegotiator.java index e92b0bd564..acc27fafee 100644 --- a/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/rest/mapping/ContentNegotiator.java +++ b/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/rest/mapping/ContentNegotiator.java @@ -30,6 +30,8 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import static org.apache.dubbo.config.nested.RestConfig.DEFAULT_FORMAT_PARAMETER_NAME; + public class ContentNegotiator { private final FrameworkModel frameworkModel; @@ -119,7 +121,7 @@ public class ContentNegotiator { String parameterName = this.parameterName; if (parameterName == null) { Configuration conf = ConfigurationUtils.getGlobalConfiguration(frameworkModel.defaultApplication()); - parameterName = conf.getString(RestConstants.FORMAT_PARAMETER_NAME_KEY, "format"); + parameterName = conf.getString(RestConstants.FORMAT_PARAMETER_NAME_KEY, DEFAULT_FORMAT_PARAMETER_NAME); this.parameterName = parameterName; } return parameterName; diff --git a/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/rest/mapping/DefaultRequestMappingRegistry.java b/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/rest/mapping/DefaultRequestMappingRegistry.java index eb7eb2e49c..44b034d17c 100644 --- a/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/rest/mapping/DefaultRequestMappingRegistry.java +++ b/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/rest/mapping/DefaultRequestMappingRegistry.java @@ -17,10 +17,9 @@ package org.apache.dubbo.rpc.protocol.tri.rest.mapping; import org.apache.dubbo.common.URL; -import org.apache.dubbo.common.config.Configuration; -import org.apache.dubbo.common.config.ConfigurationUtils; import org.apache.dubbo.common.logger.FluentLogger; import org.apache.dubbo.common.utils.ClassUtils; +import org.apache.dubbo.config.context.ConfigManager; import org.apache.dubbo.config.nested.RestConfig; import org.apache.dubbo.remoting.http12.HttpRequest; import org.apache.dubbo.remoting.http12.message.MethodMetadata; @@ -71,15 +70,12 @@ public final class DefaultRequestMappingRegistry implements RequestMappingRegist contentNegotiator = frameworkModel.getBeanFactory().getOrRegisterBean(ContentNegotiator.class); } - private void init() { - Configuration conf = ConfigurationUtils.getGlobalConfiguration(frameworkModel.defaultApplication()); - restConfig = new RestConfig(); - restConfig.setSuffixPatternMatch(conf.getBoolean(RestConstants.SUFFIX_PATTERN_MATCH_KEY, true)); - restConfig.setTrailingSlashMatch(conf.getBoolean(RestConstants.TRAILING_SLASH_MATCH_KEY, true)); - restConfig.setCaseSensitiveMatch(conf.getBoolean(RestConstants.CASE_SENSITIVE_MATCH_KEY, true)); - + private void init(Invoker<?> invoker) { + restConfig = ConfigManager.getProtocolOrDefault(invoker.getUrl()) + .getTripleOrDefault() + .getRestOrDefault(); resolvers = frameworkModel.getActivateExtensions(RequestMappingResolver.class); - tree = new RadixTree<>(restConfig.getCaseSensitiveMatch()); + tree = new RadixTree<>(restConfig.getCaseSensitiveMatchOrDefault()); } @Override @@ -88,7 +84,7 @@ public final class DefaultRequestMappingRegistry implements RequestMappingRegist lock.writeLock().lock(); try { if (initialized.compareAndSet(false, true)) { - init(); + init(invoker); } } finally { lock.writeLock().unlock(); @@ -208,13 +204,13 @@ public final class DefaultRequestMappingRegistry implements RequestMappingRegist request.setAttribute(RestConstants.PATH_ATTRIBUTE, path); List<Candidate> candidates = new ArrayList<>(); - boolean cs = restConfig.getCaseSensitiveMatch(); + boolean cs = restConfig.getCaseSensitiveMatchOrDefault(); tryMatch(request, new KeyString(path, cs), candidates); if (candidates.isEmpty()) { int end = path.length(); - if (restConfig.getTrailingSlashMatch()) { + if (restConfig.getTrailingSlashMatchOrDefault()) { if (path.charAt(end - 1) == '/') { end--; tryMatch(request, new KeyString(path, end, cs), candidates); @@ -227,7 +223,7 @@ public final class DefaultRequestMappingRegistry implements RequestMappingRegist if (ch == '/') { break; } - if (ch == '.' && restConfig.getSuffixPatternMatch()) { + if (ch == '.' && restConfig.getSuffixPatternMatchOrDefault()) { if (contentNegotiator.supportExtension(path.substring(i + 1, end))) { tryMatch(request, new KeyString(path, i, cs), candidates); if (!candidates.isEmpty()) { @@ -323,13 +319,13 @@ public final class DefaultRequestMappingRegistry implements RequestMappingRegist @Override public boolean exists(String path, String method) { - boolean cs = restConfig.getCaseSensitiveMatch(); + boolean cs = restConfig.getCaseSensitiveMatchOrDefault(); if (tryExists(new KeyString(path, cs), method)) { return true; } int end = path.length(); - if (restConfig.getTrailingSlashMatch()) { + if (restConfig.getTrailingSlashMatchOrDefault()) { if (path.charAt(end - 1) == '/') { end--; if (tryExists(new KeyString(path, end, cs), method)) { @@ -343,7 +339,7 @@ public final class DefaultRequestMappingRegistry implements RequestMappingRegist if (ch == '/') { break; } - if (ch == '.' && restConfig.getSuffixPatternMatch()) { + if (ch == '.' && restConfig.getSuffixPatternMatchOrDefault()) { if (contentNegotiator.supportExtension(path.substring(i + 1, end))) { if (tryExists(new KeyString(path, i, cs), method)) { return true;