bosprimigenious commented on code in PR #1076:
URL: https://github.com/apache/dubbo-go-pixiu/pull/1076#discussion_r4527114638
##########
pkg/filter/http/proxyrewrite/rewrite.go:
##########
@@ -79,7 +79,8 @@ func (factory *FilterFactory) Apply() error {
if len(factory.cfg.UriRegex) != 2 {
return errors.Errorf("UriRegex len must == 2, %v",
factory.cfg.UriRegex)
}
- return nil
+ _, err := regexp.Compile(factory.cfg.UriRegex[0])
+ return err
Review Comment:
In `f940760`, `Apply()` keeps the compiled regexp on the factory and
`PrepareFilterChain` reuses it. The fallback for factories constructed without
`Apply()` compiles locally and returns an error rather than calling
`MustCompile`; it does not mutate the shared factory.
##########
pkg/filter/http/proxyrewrite/rewrite.go:
##########
@@ -79,7 +79,8 @@ func (factory *FilterFactory) Apply() error {
if len(factory.cfg.UriRegex) != 2 {
return errors.Errorf("UriRegex len must == 2, %v",
factory.cfg.UriRegex)
}
- return nil
+ _, err := regexp.Compile(factory.cfg.UriRegex[0])
Review Comment:
已在 f940760 中保留编译结果:`Apply()` 写入 `factory.uriRegex`,正常请求的
`PrepareFilterChain` 直接复用它。只有未经过 `Apply()` 的直接构造路径才局部编译并返回错误,不回写共享 factory。
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]