Fix unknown command issue in sentinel-transport-netty-http module #817
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Describe what this PR does / why we need it
If a command whose mapping path and command name has more than one "/",
the CommandHandler can't be found in
sentinel-transport-netty-http
,such as:
/cluster/server/flowRules
FetchClusterFlowRulesCommandHandler
will case:
Unknown command "cluster"
Does this pull request fix one issue?
Fixes #810
Describe how you did it
Modify the
String parseTarget(String uri)
method inHttpServerHandler
class.Don't use
uri.split("/")
to parse, but useindexOf("/")
instead, to remove the/ in uri, just like the
parseRequest
method ofHttpEventTask
class insentinel-transport-simple-http
module.Describe how to verify it
Add 2 test cases in
HttpServerHandlerTest
class:testFetchClusterFlowRulesCommandEmptyRule
testFetchClusterFlowRulesCommandSomeFlowRules
In order to test,
sentinel-cluster-server-default
dependency is added withtest
scope.Run demo in
sentinel-demo-cluster-server-alone
module,change the
sentinel-transport-simple-http
tosentinel-transport-netty-http
,start the
ClusterServerDemo
and visit http://localhost:8719/cluster/server/flowRulesSpecial notes for reviews
The previous test case which marked FIXME in
HttpServerHandlerTest
class has been fixed, I found a way that we can callembeddedChannel.readOutbound()
looply to get the whole result.Some comments in test class have been improved, such as upper case the first letter.
In pom.xml of parent module,
sentinel-transport-netty-http
is added in<dependencyManagement>
, so that we needn't add version number when use it.