Skip to content

dev 0.1.8#233

Open
mercyblitz wants to merge 303 commits intomicrosphere-projects:devfrom
mercyblitz:dev
Open

dev 0.1.8#233
mercyblitz wants to merge 303 commits intomicrosphere-projects:devfrom
mercyblitz:dev

Conversation

@mercyblitz
Copy link
Contributor

@mercyblitz mercyblitz commented Feb 4, 2026

This pull request introduces several improvements and refactorings to the microsphere-annotation-processor module, focusing on dependency updates, codebase modernization, and internal API changes. The changes streamline the annotation processor's dependencies, update workflow configurations, and refactor utility usages to align with newer shared modules.

Dependency and Build Updates:

  • Updated the Maven wrapper to version 3.9.9 and switched the distribution URL to an Aliyun mirror for potentially faster downloads. Also, changed the wrapper configuration to use only the script distribution. (.mvn/wrapper/maven-wrapper.properties)
  • Updated GitHub Actions workflows to use the latest versions of actions/checkout and actions/setup-java (v5), switched Maven invocations to use the wrapper script (./mvnw), and added JVM options for test execution. (.github/workflows/maven-build.yml, .github/workflows/maven-publish.yml) [1] [2]

Dependency Management and Testing:

  • Removed unused properties for JAX-RS and JAX-WS versions from the annotation processor's pom.xml, and added new dependencies on microsphere-lang-model, microsphere-jdk-tools, and microsphere-java-test to support enhanced annotation processing and testing. (microsphere-annotation-processor/pom.xml) [1] [2] [3]
  • Updated test dependencies to use fixed versions instead of property references, simplifying dependency management. (microsphere-annotation-processor/pom.xml)

Refactoring and Code Modernization:

  • Refactored imports throughout the annotation processor to use utility classes from the new microsphere-lang-model module, replacing previous local utilities. (ConfigurationPropertyAnnotationProcessor.java, FilerProcessor.java, ResourceProcessor.java) [1] [2] [3]
  • Moved and refactored ConfigurationPropertyJSONElementVisitor from the model.util package to the main annotation processor package, updated its API for package-private usage, and improved its handling of annotation attributes. (ConfigurationPropertyJSONElementVisitor.java) [1] [2] [3] [4] [5] [6]

Internal API and Test Updates:

  • Added a toJSON() method to ConfigurationPropertyAnnotationProcessor for easier inspection of generated JSON during testing. (ConfigurationPropertyAnnotationProcessor.java)
  • Updated the test class for the annotation processor to use new testing utilities and assertion methods, and removed unused imports. (ConfigurationPropertyAnnotationProcessorTest.java)

@codecov
Copy link

codecov bot commented Feb 4, 2026

Codecov Report

❌ Patch coverage is 99.14894% with 8 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...java/io/microsphere/convert/AbstractConverter.java 33.33% 2 Missing and 2 partials ⚠️
.../io/microsphere/io/filter/FileExtensionFilter.java 50.00% 0 Missing and 1 partial ⚠️
...src/main/java/io/microsphere/json/JSONTokener.java 95.00% 0 Missing and 1 partial ⚠️
.../main/java/io/microsphere/management/JmxUtils.java 97.29% 1 Missing ⚠️
...n/java/io/microsphere/reflect/ReflectionUtils.java 95.83% 0 Missing and 1 partial ⚠️
Files with missing lines Coverage Δ Complexity Δ
...ssor/ConfigurationPropertyAnnotationProcessor.java 100.00% <100.00%> (+6.97%) 16.00 <5.00> (+4.00)
...essor/ConfigurationPropertyJSONElementVisitor.java 100.00% <100.00%> (ø) 24.00 <4.00> (?)
...crosphere/annotation/processor/FilerProcessor.java 100.00% <ø> (ø) 5.00 <0.00> (ø)
...sphere/annotation/processor/ResourceProcessor.java 100.00% <ø> (+7.40%) 36.00 <0.00> (ø)
...assloading/BannedArtifactClassLoadingExecutor.java 100.00% <100.00%> (+25.53%) 13.00 <1.00> (+4.00)
...classloading/ManifestArtifactResourceResolver.java 100.00% <100.00%> (+13.51%) 13.00 <2.00> (-1.00) ⬆️
...classloading/ServiceLoadingURLClassPathHandle.java 100.00% <100.00%> (+16.66%) 5.00 <1.00> (-1.00) ⬆️
...e/classloading/StreamArtifactResourceResolver.java 100.00% <100.00%> (+8.16%) 17.00 <2.00> (-1.00) ⬆️
...va/io/microsphere/collection/ArrayEnumeration.java 100.00% <100.00%> (ø) 10.00 <0.00> (ø)
.../io/microsphere/collection/DelegatingIterator.java 100.00% <100.00%> (ø) 9.00 <9.00> (?)
... and 107 more

... and 10 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Replace the inline null-check return with an explicit if-block in AnnotationUtils.matchesDefaultAttributeValue to improve readability. The method now returns false immediately if attributeMethod is null, then delegates to matchesAttributeValue for the default value; no behavioral change intended.
Refactor CompilerInvocationInterceptor to build a Class<?>[] from the collected Set and pass that array to Compiler APIs. Added a static import of EMPTY_CLASS_ARRAY and renamed the Set to compiledClassesSet to avoid naming confusion. This ensures typed empty-array usage with toArray(EMPTY_CLASS_ARRAY) and uses the resulting Class[] for sourcePaths(...) and compile(...), removing ad-hoc toArray(new Class[0]) calls.
Move AnnotatedElementJSONElementVisitor to microsphere-lang-model and update packages/usages; make ConfigurationPropertyJSONElementVisitor package-private, change its CONFIGURATION_PROPERTY_ANNOTATION_CLASS_NAME and constructor visibility, and override supportsType to always return true. Update ConfigurationPropertyAnnotationProcessor to import ResourceConstants, adjust static import path, refactor resolveMetadata into an overload that accepts a Set (prepend '[' before resolving, append generated SPI JSON, and ensure proper trailing bracket handling), and add a toJSON() helper. Update and add unit tests to match the refactor: adapt ConfigurationPropertyAnnotationProcessorTest, add ConfigurationPropertyJSONElementVisitorTest, and add AnnotatedElementJSONElementVisitorTest under the lang-model tests. Miscellaneous import and formatting adjustments applied to affected files.
Pass the attribute name into setSources and make the method process only when attributeName equals "source". This avoids treating non-source annotation attributes as sources when the visitor's default branch invokes setSources. The method visibility was relaxed and a unit test (testSetSourcesOnNoSource) was added to ensure calling setSources with a non-'source' attribute and null values does not throw.
Extend ResourceProcessorTest to cover fallback/error-handler behavior when resource callbacks throw. Add assertions that:
- classOutputProcessor.processInResource with a throwing callback returns null when a handler returning null is provided.
- sourcePathProcessor.processInResourceInputStream/Reader/Content with throwing callbacks return Optional.empty() when a handler returning null is provided.
- classOutputProcessor.processInResourceOutputStream and processInResourceWriter invoke the error handler and receive a non-null exception.
These tests ensure resource processors correctly propagate exceptions to provided handlers and return the expected fallback values.
Introduce TestDeque (backed by LinkedList) as a reusable test implementation of AbstractDeque with configurable max capacity. Replace the large anonymous deque instance in AbstractDequeTest#setUp with TestDeque<>(1), remove now-unused imports, and update the testRemoveFirstOccurrence assertion to expect false when removing null. These changes improve test clarity and reuse.
Added explicit overrides for common Deque operations (addFirst, addLast, removeFirst, removeLast, removeFirstOccurrence, push, pop, offer, poll, peek) in TestDeque that simply delegate to the superclass. This clarifies the class API and ensures these methods are available/overridable for testing or further extension without changing behavior.
Introduce DelegatingIterator<E> that forwards all Iterator calls to an underlying delegate and implements DelegatingWrapper to expose the delegate. Refactor EmptyIterator to extend DelegatingIterator and use Collections.emptyIterator() as its delegate. Add DelegatingIteratorTest to verify delegation behavior (hasNext, next, remove, forEachRemaining, getDelegate, hashCode, equals, toString). This enables easier iterator wrapping and reuse of common iterator behavior.
Centralize and simplify character access and position checks in JSONTokener. Replaced repeated this.in.charAt/length checks with helper methods (hasNext, nextChar, currentChar, charAt) and refactored loops to use them. Also added static imports for Double.valueOf, Long.parseLong, Integer.MAX_VALUE and MIN_VALUE and updated numeric parsing to use those imports. Adjusted more() and next() to use the new helpers and cleaned up related parsing methods to improve readability and reduce duplication.
Refactor JSONStringer to use static imports for Scope enum constants and introduce an isEmpty() helper that wraps stack.isEmpty(). Replace direct Scope.* and stack.isEmpty() usages across methods (array/endArray/object/endObject/open/peek/value/beforeKey/beforeValue) to improve readability and consistency without changing behavior.
Replace value.length() with the precomputed 'length' variable when delimiterLength == 0. This ensures the loop boundary is consistent with earlier computations and avoids repeated method calls when splitting the string into single-character substrings.
Replace the manual null and Object.class checks with a call to isObjectType(targetClass) in the loop that collects resolved type arguments. This centralizes the terminal-condition logic for traversing the class hierarchy, improving readability and consistency when resolving type arguments.
Add junit.jupiter.execution.parallel.enabled = true to src/test/resources/junit-platform.properties to enable parallel test execution for JUnit Jupiter. This update allows tests to run concurrently during the test phase.
Reformat long method signatures in TypeUtils.resolveTypeArgumentsMap overloads for improved readability by wrapping parameters across lines. Also simplify the loop in resolveTypeArguments by removing a redundant null check (targetClass is validated earlier), leaving behavior unchanged while making the code clearer.
Prevent instantiation of the Assert utility class by adding a private no-arg constructor. This enforces the class's static-only usage and communicates intent to future maintainers.
Remove the redundant super() call from the private no-arg constructor in StringUtils. This is a clean-up change with no behavioral impact since Object's constructor is invoked implicitly.
Normalize test code by prefixing urlConnection references with this.urlConnection and consolidating static imports (copyToString, attach, TEST_CONSOLE_URL, System.out, assertSame). Replace IOUtils.toString with copyToString, adjust testGetOutputStream to expect IOException, and add a scenario that attaches the ServiceLoaderURLStreamHandlerFactory, opens TEST_CONSOLE_URL and asserts the returned output stream is System.out. Miscellaneous small assertions and cleanup for clarity.
Refactor JSONUtilsTest to use explicit this.jsonBuilder references (replacing bare jsonBuilder) to avoid ambiguity and make the instance usage clear. Add static import for appendName and introduce testAppendName to validate appendName behavior for null, empty, blank and normal names. No production code changed—only test code and imports updated.
Replace the manual loop for resolving current process id with a Stream-based pipeline that filters supported ProcessIdResolvers, maps to their current id, and picks the first non-null value or UNKNOWN_PROCESS_ID. Remove the Logger, the log(...) helper and related imports since trace logging was eliminated. Update tests to reflect the change: remove the logging-centric test and unused imports, and add an assertion that the static currentProcessId equals the value returned by getCurrentProcessId(). Miscellaneous: add Objects import and tidy up unused imports.
Refactor BannedArtifactClassLoadingExecutor to make config-loading helpers static and accept a ClassLoader (loadBannedArtifactConfigs(ClassLoader), loadBannedArtifactConfigs(URL), loadBannedArtifactConfig(String)). execute() now passes this.classLoader and uses a stream forEach for artifact processing. loadBannedArtifactConfig now throws IllegalArgumentException for invalid definitions. Tests added to cover execution and error cases (failed resource lookup and invalid definition). Also removed an unused test field as part of cleanup.
Add -Dsurefire.useSystemClassLoader=false to the Maven test invocation in the GitHub Actions workflow (.github/workflows/maven-build.yml) to avoid Surefire classloader-related issues during test execution and improve test reliability in CI.
Replace artifacts.stream().forEach(...) with artifacts.forEach(...) to avoid unnecessary stream creation and simplify the iteration. This is a small stylistic cleanup with no functional change.
Refactor reflection utilities to use common helpers and improve null/edge-case handling. Replaced direct Thread.currentThread() calls with a static import, unified field access via FieldUtils.getFieldValue, and switched static checks to MemberUtils.isStatic. Simplified toObject() and readFieldsAsMap() to handle nulls, recursive structures and return empty/unmodifiable maps; use newLinkedHashMap for initial sizing. Introduced overloads for isInaccessibleObjectException to accept Class and String types and added Javadoc. Updated unit tests to cover toObject, readFieldsAsMap recursion, and the new isInaccessibleObjectException behavior, plus minor import and assertion adjustments.
Modify ExecutorUtilsTest to explicitly qualify executorService with this and to simulate JVM shutdown by fetching ShutdownHookUtils.shutdownHookCallbacks (via getStaticFieldValue), polling the registered callback and running it, then asserting the executor is shutdown. Added necessary imports (ShutdownHookUtils, PriorityBlockingQueue, FieldUtils). Minor EOF newline change in ExecutorUtils.java.
Add tracing log when an ExecutorService is shut down by introducing a Logger into ExecutorUtils. This helps debugging executor lifecycle events.

Update ExecutorUtilsTest to be more robust: add @AfterEach tearDown to shut down the executor, make testShutdownOnExit handle InterruptedException, iterate over ShutdownHookUtils' callbacks to find and run the lambda-based shutdown callbacks (instead of assuming queue order), remove executed callbacks, and wait briefly for termination before asserting shutdown. Also add necessary imports and assertions.
In AbstractConverterTest, the anonymous converter now calls super.resolvePriority() and overrides getPriority() to return super.getPriority(). Also adds testEquals() to assert the converter equals itself. These changes improve test coverage for priority delegation and equality behavior.
Replace explicit null comparison with java.util.Objects.nonNull for readability in supports(). Remove the manual isTraceEnabled() guard and call logger.trace directly in current(), relying on the logger implementation to check the level. No functional behavior changes; just small cleanup and simplification.
Replace direct AbstractTestCase inheritance in FileUtilsTest with Loggable and remove the class import. Add static imports for TEST_CLASS_LOADER and several helper methods from AbstractTestCase (createRandomDirectory, createRandomFile, createRandomTempDirectory, createRandomTempFile, makeLinkFile, newRandomTempFile, random) so tests continue to use the utilities without extending the base test class. Updates only affect microsphere-java-core/src/test/java/io/microsphere/io/FileUtilsTest.java.
Replace AbstractTestCase with Loggable as the test base to leverage logging utilities, and add a static import for newRandomTempFile for test file creation. No functional changes to the test behavior; this only updates the base class and imports for clarity and utility.
Replace anonymous Filter implementations with lambda expressions and add static imports for FilterUtils.filter and FilterOperator.AND/OR. Remove the unused AbstractTestCase import/extension and simplify test calls to make the test more concise and idiomatic.
Decouple IOUtilsTest from the AbstractTestCase base by removing the extends clause and the direct import. The TEST_NULL_STRING constant is kept via a static import, cleaning up an unused dependency while preserving test behavior.
Simplify IterableAdapterTest by removing its inheritance from AbstractTestCase and instead statically importing TEST_ELEMENT. Cleans up imports and reduces coupling to the base test class; minor file cleanup (EOF newline change).
Stop extending AbstractTestCase in JSONTest and switch to a static import of AbstractTestCase.random. Adjust imports and class declaration so the test class is a plain class while still using the random helper method. No test logic changed.
Decouple JarUtilsTest from the AbstractTestCase base class: remove the direct import of io.microsphere.AbstractTestCase and the 'extends AbstractTestCase' declaration, and add static imports for createRandomTempDirectory and createRandomTempFile. Keeps test helpers available via static imports while making the test class plain.
Delete the unused import of io.microsphere.AbstractTestCase and remove the extends AbstractTestCase clause from JmxUtilsTest. Tests themselves are unchanged aside from a minor whitespace adjustment, decoupling the test class from the shared base test class.
Replace AbstractTestCase with Loggable for test logging, remove unused logging factory import, and tidy imports. Add static imports for TEST_NULL_* and TEST_NULL_LIST constants, and use the static MutableInteger.of import (of(0)) in tests. Minor formatting update (no newline at EOF change).
ListsTest no longer extends AbstractTestCase. Instead it statically imports TEST_NULL_OBJECT_ARRAY from io.microsphere.AbstractTestCase and updates imports accordingly. This decouples the test class from the base test class while preserving access to the shared test constant.
LoggingFileChangedListenerTest no longer extends AbstractTestCase. The test now statically imports createRandomTempFile from AbstractTestCase and the unused class import was removed, decoupling the test from the base test class and using the helper method directly.
Remove the import of io.microsphere.AbstractTestCase and the 'extends AbstractTestCase' clause from ManagementUtilsTest. The test is now a plain JUnit Jupiter test class; test logic and assertions remain unchanged. This removes the unnecessary dependency on the AbstractTestCase base class for this test.
Replace AbstractTestCase with Loggable in ProcessExecutorTest: update the import and change the test class to extend Loggable. This simplifies the test base by using the logging helper instead of the previous abstract test class.
Replace the test base from io.microsphere.AbstractTestCase to io.microsphere.Loggable in ProcessManagerTest. This updates the import and the class declaration (extends AbstractTestCase -> extends Loggable) to use the Loggable test utility.
Drop the unused io.microsphere.AbstractTestCase import and remove extends AbstractTestCase from ReflectionUtilsTest. This makes the test class a plain unit test, simplifying setup and removing an unnecessary dependency.
Remove dependency on AbstractTestCase by deleting its import and the extends clause. Add a static import for TEST_NULL_STRING_ARRAY and tidy imports/formatting in the test file to simplify the unit test and remove the base test class coupling.
Delete the AbstractTestCase import and stop extending it in SetsTest; add a static import for TEST_NULL_OBJECT_ARRAY so the test can reference it directly. This simplifies the test class into a plain JUnit 5 test without changing test behavior.
Drop the unused AbstractTestCase import and stop extending it in SimpleFileScannerTest. The test no longer depends on the base test class, simplifying the test class declaration.
Replace inheritance from AbstractTestCase with Loggable and add static imports for createRandomFile and createRandomTempDirectory. This updates the test to use the logging base class while pulling test helper methods in as static imports to simplify references in the test file.
Replace use of super.classLoader with TEST_CLASS_LOADER in StandardFileWatchServiceTest.testFile and add a static import for TEST_CLASS_LOADER. This ensures the shared test class loader is used for resource lookup instead of referencing the superclass instance field.
Replace AbstractTestCase with Loggable in StopWatchTest and remove explicit Logger and getLogger imports. Clean up unused imports and adjust class inheritance to rely on Loggable for logging support.
StringBuilderWriterTest no longer extends AbstractTestCase. Instead, required utilities (TEST_NULL_STRING and random) are imported statically from AbstractTestCase. Cleans up test class to avoid inheritance-based coupling and use static helpers directly.
Replace AbstractTestCase with io.microsphere.Loggable in ThrowableActionTest. The import and class declaration were updated so the test now extends Loggable, enabling use of the logging helper instead of the previous AbstractTestCase.
Replace AbstractTestCase with Loggable as the superclass in ThrowableBiConsumerTest and update the import. This switches the test to use logging utilities provided by Loggable instead of the previous test base.
Remove trailing newline at end of microsphere-java-core/src/test/java/io/microsphere/lang/function/ThrowableBiConsumerTest.java. No functional changes — only EOF newline removal.
Change several test helper methods in AbstractTestCase to be public static so they can be invoked without an instance. Updated modifiers for assertThrowable, both assertValues overloads, and assertType to increase reusability across tests and static utility contexts.
Remove inheritance from AbstractTestCase and add a static import of assertValues. The test class no longer extends the base test case and instead uses the assertValues utility directly; no other behavioral changes to the tests.
Decouple TypeUtilsTest from the AbstractTestCase base by removing the extends clause and the direct import. Add a static import for assertValues to keep assertions working. Also clean up minor import/EOF formatting and stray commented lines.
Remove AbstractTestCase inheritance and unused import; add static imports for TEST_CLASS_LOADER and TEST_NULL_STRING. Replace usages of the instance classLoader with TEST_CLASS_LOADER in getClassResource/getResource calls and adjust imports accordingly to simplify test setup while preserving behavior.
@sonarqubecloud
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant