Refactor: guard all logger calls with isXxxEnabled() checks#101
Merged
mercyblitz merged 14 commits intomainfrom Mar 27, 2026
Merged
Refactor: guard all logger calls with isXxxEnabled() checks#101mercyblitz merged 14 commits intomainfrom
mercyblitz merged 14 commits intomainfrom
Conversation
Co-authored-by: mercyblitz <533114+mercyblitz@users.noreply.github.com> Agent-Logs-Url: https://github.com/microsphere-projects/microsphere-spring-cloud/sessions/e48e837d-515a-41bc-82ca-62cba0ba78a9
Copilot created this pull request from a session on behalf of
mercyblitz
March 25, 2026 04:29
View session
Bump parent POM and dependency versions; update CI workflow
Codecov Report✅ All modified and coverable lines are covered by tests.
🚀 New features to boost your workflow:
|
Annotate multiple test classes with @SpringLoggingTest to enable consistent test logging and add a new FeignClientSpecificationPostProcessorTest. Adjust Feign auto-refresh code: simplify ConditionalOnBean to use Marker, statically import NoOpRequestInterceptor.INSTANCE, and make AUTO_REFRESH_CAPABILITY_CLASS, FEIGN_CLIENT_SPECIFICATION_CLASS and injectAutoRefreshCapability package-private to allow testing. Update parent POM to add junit-jupiter.version and import the JUnit BOM for consistent test dependency management.
Change testStart() to testStart(int index) and wrap its assertions in an if (index == 0) block so the assertions only run for index 0. This adapts the test for parameterized or repeated invocations while preserving the original assertion behavior.
Change excludeMappings from private(Set) to package-private(Collection) so it can be accessed within the package and accept any Collection<WebEndpointMapping>. Iteration logic remains unchanged.
Remove the final newline character from microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/client/service/registry/autoconfigure/WebMvcServiceRegistryAutoConfigurationTest.java. This is a non-functional whitespace/formatting change.
Replace @SpringLoggingTest with @LoggingLevelsTest and update imports. Add a new test (testExcludeMappings) that constructs a WebEndpointMapping, injects WebServiceRegistryAutoConfiguration, and verifies excludeMappings removes the mapping. Also add static imports for newLinkedList, ofList and GET, and adjust references to use this.registration for clarity.
Delete the unused import and the @SpringLoggingTest annotation from BaseServiceRegistrationEndpointTest, cleaning up the test class by removing the SpringLoggingTest extension usage.
Replace the previous conditional/parameterized testStart with a simpler test annotated with @LoggingLevelsTest(levels = "ERROR"). The test now asserts that start() returns the same value as isRunning(), called twice, removing redundant true/false assertions and unused static imports. Added the LoggingLevelsTest import and cleaned up imports accordingly.
Replace class-level @SpringLoggingTest with the more granular @LoggingLevelsTest. Updated import to io.microsphere.logging.test.jupiter.LoggingLevelsTest, removed the @SpringLoggingTest annotation on the class, and added @LoggingLevelsTest(levels = "ERROR") to the testAttachMetadata method to scope logging level for that test.
Replace assertFalse/assertTrue with assertEquals assertions that compare endpoint.isRunning() to stop()/start() results for clearer intent. Add import and annotate testStop with @LoggingLevelsTest(levels = "ERROR"). Remove unused static imports of assertFalse/assertTrue.
Clean up import ordering and duplicates in test classes. Move the static getLogger import to a consistent location, add or relocate the Logger import as needed, and tidy blank lines in BaseTest.java and ObservableFeignInvocationHandler.java. No functional changes.
Move the static import of LoggerFactory.getLogger to be grouped with other imports and add a blank line for improved import formatting in the test AQueryMapEncoder. No functional changes; only import ordering/formatting.
Adjust import ordering in BQueryMapEncoder test: move the static import of LoggerFactory.getLogger below other imports and add spacing. No functional changes; only formatting/organizing imports.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.



Unguarded logger calls evaluate their arguments eagerly regardless of log level, causing unnecessary string construction, method calls, and lambda execution at runtime.
Changes
logger.trace(...),logger.info(...), andlogger.warn(...)calls across 7 files in the appropriateisXxxEnabled()guardforEachlambda inServiceInstanceUtils) under a single guard block to avoid redundant level checksBefore:
After:
Files affected
DecoratedFeignComponenttraceFeignClientSpecificationPostProcessortraceTomcatDynamicConfigurationListenertraceServiceInstanceUtilstraceforEachlambda)ServiceRegistrationEndpointinfo,warnServiceDeregistrationEndpointinfo,warnWebServiceRegistryAutoConfigurationtrace