Environment
Jmix version: 2.x (main branch)
Description
This is a code quality improvement proposal addressing three minor issues found in the codebase:
1. Inefficient AntPathMatcher instantiation
AntPathMatcher is instantiated on every method call in RestAuthorizedUrlsRequestMatcher, ReportAsResourceServerBeforeInvocationEventListener, and ReportOidcResourceServerBeforeInvocationEventListener. Since AntPathMatcher is stateless and thread-safe, it should be a static final field.
2. Code duplication in reports-rest module
ReportAsResourceServerBeforeInvocationEventListener and ReportOidcResourceServerBeforeInvocationEventListener contain nearly identical code. There is even a TODO comment in the code: "TODO get rid of code duplication".
3. Inefficient logging with string concatenation
Several classes use string concatenation in log statements (e.g., log.error("Message " + variable)) instead of SLF4J placeholders (log.error("Message {}", variable)). This causes unnecessary string concatenation even when the log level is disabled.
Current Behavior
- New
AntPathMatcher object created on each request
- Duplicated code in two event listeners
- String concatenation performed regardless of log level
Expected Behavior
- Single shared
AntPathMatcher instance per class
- Common logic extracted to abstract base class
- SLF4J parameterized logging for better performance
Proposed Solution
I have prepared a PR with the following changes:
- Extract
AntPathMatcher to static final fields
- Create
AbstractReportBeforeInvocationEventListener base class
- Replace string concatenation with
{} placeholders in 8 files
All existing tests pass.
Environment
Jmix version: 2.x (main branch)
Description
This is a code quality improvement proposal addressing three minor issues found in the codebase:
1. Inefficient AntPathMatcher instantiation
AntPathMatcheris instantiated on every method call inRestAuthorizedUrlsRequestMatcher,ReportAsResourceServerBeforeInvocationEventListener, andReportOidcResourceServerBeforeInvocationEventListener. SinceAntPathMatcheris stateless and thread-safe, it should be a static final field.2. Code duplication in reports-rest module
ReportAsResourceServerBeforeInvocationEventListenerandReportOidcResourceServerBeforeInvocationEventListenercontain nearly identical code. There is even a TODO comment in the code: "TODO get rid of code duplication".3. Inefficient logging with string concatenation
Several classes use string concatenation in log statements (e.g.,
log.error("Message " + variable)) instead of SLF4J placeholders (log.error("Message {}", variable)). This causes unnecessary string concatenation even when the log level is disabled.Current Behavior
AntPathMatcherobject created on each requestExpected Behavior
AntPathMatcherinstance per classProposed Solution
I have prepared a PR with the following changes:
AntPathMatchertostatic finalfieldsAbstractReportBeforeInvocationEventListenerbase class{}placeholders in 8 filesAll existing tests pass.