bosprimigenious commented on PR #1076:
URL: https://github.com/apache/dubbo-go-pixiu/pull/1076#issuecomment-6719573832

   Thanks @AlexStocks for the line-level review — both points are addressed in 
f940760, plus @Alanxtl's hot-path question:
   
   - **Compiled regex is kept**: `FilterFactory` now holds `uriRegex 
*regexp.Regexp`; `Apply()` compiles once and stores it, and 
`PrepareFilterChain` reuses it instead of calling `regexp.MustCompile` per 
request. This also removes the panic path for factories built without `Apply()` 
— the lazy branch compiles locally and returns a wrapped error, and the factory 
stays immutable so concurrent requests cannot race.
   - **Error context**: the failure is now `errors.Wrapf(err, "invalid 
uri_regex %q", ...)`, so the log names the offending pattern instead of just 
the regexp parser message.
   - `UriRegex[1]` remains untouched — it is the replacement string, not a 
pattern.
   
   Tests added in `rewrite_test.go`:
   
   - `TestApplyKeepsCompiledRegex` — Apply stores the compiled regex; 
PrepareFilterChain does not nil it out.
   - `TestApplyErrorNamesThePattern` — error contains `invalid uri_regex "["`.
   - `TestPrepareFilterChainDoesNotPanicWithoutApply` — direct construction + 
invalid regex returns an error instead of panicking.
   - `TestPrepareFilterChainReusesCompiledRegex` — the same `*regexp.Regexp` is 
reused across requests.
   
   ```
   $ go test -count=1 ./pkg/filter/http/proxyrewrite/
   ok  github.com/apache/dubbo-go-pixiu/pkg/filter/http/proxyrewrite  0.713s
   ```
   


-- 
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]

Reply via email to