Open
Conversation
Adds a new unit test in ThrowableConsumerTest that calls execute(String, ThrowableConsumer, BiConsumer) with a no-op exception handler to verify the exception-handling path does not propagate an error. Improves coverage for the execute-with-handler scenario.
Introduce an abstract test utility LoggingTest that manages Logback logger levels for tests. The class (microsphere-java-core/src/test/java/io/microsphere/LoggingTest.java) uses JUnit 5 annotations to run parameterized (INFO, TRACE) scenarios, with @BeforeEach/@AfterEach methods to set and restore the logger level via a shared LoggerContext. The test is currently @disabled and provides getTargetLogger() to target the package logger.
Import LoggingTest and have ShutdownHookCallbacksThreadTest extend it so the test can leverage shared logging utilities/capture. Also remove an extra trailing blank line.
Update ClassPathResourceConfigurationPropertyLoaderTest to extend LoggingTest and add the corresponding import. This enables logging support/capture for the test class (facilitating inspection of logs during test execution).
Make ArtifactDetectorTest extend LoggingTest to enable logging support in the test. Added import for io.microsphere.LoggingTest and updated the class declaration so tests can leverage the shared logging test utilities.
Wrap the logger.trace call in JarUtils with a logger.isTraceEnabled() check to avoid unnecessary message formatting and exception handling overhead when trace logging is disabled. This change improves performance on the error path when opening a JarFile fails.
Import LoggingTest and have JarUtilsTest extend it so test logging utilities are available. This enables shared logging setup/behavior for the JarUtils tests to improve diagnostics during test runs.
Wrap two logger.trace calls in ClassUtils.java with logger.isTraceEnabled() checks (in class path scanning and in the SimpleJarEntryScanner exception handler). This avoids unnecessary logging overhead/formatting when TRACE is disabled and preserves existing behavior when enabled.
Add import for io.microsphere.LoggingTest and change ClassUtilsTest to extend LoggingTest so the test can leverage shared logging/test utilities. No other test logic was modified.
Wrap trace-level logging calls in FieldUtils with logger.isTraceEnabled() checks to avoid unnecessary string construction when trace logging is disabled. Changes apply to findField and the exception handlers handleIllegalAccessException and handleIllegalArgumentException. No functional change to exception behavior; this is an optimization to reduce logging overhead.
Add io.microsphere.LoggingTest import and update FieldUtilsTest to extend LoggingTest so the test class inherits logging/diagnostic behavior. No other logic changes were made.
Add a logger.isTraceEnabled() check before invoking logger.trace in ManifestArtifactResourceResolver. This avoids unnecessary string formatting and potential expensive artifact representation creation when trace logging is disabled, reducing runtime overhead without changing behavior.
Wrap existing logger.trace(...) calls with logger.isTraceEnabled() checks to avoid unnecessary string formatting when trace logging is disabled. Applied to three locations in StreamArtifactResourceResolver where missing archive, missing JarEntry, or missing artifact metadata file are logged. No behavioral changes beyond logging performance improvement.
Import LoggingTest and make AbstractArtifactResourceResolverTest extend it so the artifact resolver tests can use shared logging utilities and capture test logs consistently.
Replace Loggable abstract class with a Loggable interface that provides default logging methods (logger is now obtained per-call). Update test classes to implement Loggable instead of extending it, adjust class/interface declaration orders where necessary, and add a LoggingTest base class to ExecutorUtilsTest (with import). Also update ModifierTest to avoid referencing the removed protected logger field by checking Proxy.h instead.
Wrap the trace log call in ExecutorUtils.shutdown(...) with a logger.isTraceEnabled() check to avoid unnecessary logging overhead when trace level is disabled. This prevents potential cost from message formatting or parameter evaluation in high-frequency shutdown paths.
Wrap the trace log call in IOUtils with logger.isTraceEnabled() to avoid unnecessary message formatting and argument evaluation when trace level is disabled. This reduces overhead in the stream copy path while preserving the original logging behavior.
Import io.microsphere.LoggingTest and update IOUtilsTest to extend LoggingTest so the test class can reuse shared logging/test utilities (captures logging or common setup/teardown).
Wrap trace logging calls with logger.isTraceEnabled() checks to avoid unnecessary message formatting and potential expensive operations when trace level is disabled. Applied to the file-dispatch log in the event dispatch path and the directory registration log in registerDirectoriesToWatchService.
Import io.microsphere.LoggingTest and update StandardFileWatchServiceTest to extend LoggingTest (while retaining Loggable). This enables reuse of logging test utilities in the test class.
Wrap the logger.trace call in StandardURLStreamHandlerFactory#createURLStreamHandlerFromDefaultFactory with a logger.isTraceEnabled() check to avoid unnecessary logging overhead and follow conditional logging best practices.
Import LoggingTest and have StandardURLStreamHandlerFactoryTest extend it so the test inherits shared logging setup/fixtures. This enables consistent logging behavior for the test class.
Wrap the logger.trace call in URLUtils.java with an if (logger.isTraceEnabled()) check to avoid unnecessary logging message formatting when trace is disabled. Preserves existing behavior (returns null for whitespace in protocol) while reducing runtime overhead during protocol validation.
Add io.microsphere.LoggingTest import and have URLUtilsTest extend LoggingTest so the test can use shared logging/test utilities (enabling log capture/configuration during test execution).
Wrap the trace log call in ClassicProcessIdResolver#current() with logger.isTraceEnabled() to avoid unnecessary message construction when trace logging is disabled. Preserves existing behavior when trace is enabled while reducing potential performance overhead.
Update the test class to extend io.microsphere.LoggingTest and add the required import so the test can use shared logging utilities/capture. No behavior changes to test logic.
Wrap the logger.trace call in ModernProcessIdResolver.current() with logger.isTraceEnabled() to avoid unnecessary logging overhead (message formatting) when TRACE is disabled. This reduces runtime cost for the PID resolution path.
Import io.microsphere.LoggingTest and make ModernProcessIdResolverTest extend LoggingTest. This enables shared logging setup/utility for the test class so test logging can be captured or configured consistently.
Wrap the logger.trace(...) call in ProcessExecutor with a logger.isTraceEnabled() check to avoid unnecessary message formatting when trace logging is disabled. The change sits in the finally block after removing unfinished processes and is a small performance optimization.
Refactor and expand ReflectionUtilsTest to exercise new caller-resolution strategies (StackTrace/StackWalker and sun.reflect reflection). Introduces CALLER_CLASS/CALLER_CLASS_NAME constants, replaces older GeneralJVM/SunJVM assertions with StackTrace/StackWalker variants, and adds tests for frame bounds, StackWalker behavior across Java versions (using VersionUtils), and expected exceptions on unsupported JVMs. Also adjusts imports and uses assertThrows where appropriate.
Update ReflectionUtilsBenchmark: add static imports for new helpers, rename benchmark methods to reflect StackWalker/StackTrace strategies, and add a benchmark that invokes the sun.reflect.Reflection-based lookup (commented out). These changes clarify which caller lookup approach is being measured and prepare the test for additional comparisons.
Call getCallerClassName with a fixed index (1) instead of using invocationFrame + 1 to avoid out-of-range/throwing behavior for large frame values. Update the test to expect no exception when passing an excessively large frame (use assertDoesNotThrow) and add the necessary import.
Raise the StackWalker limit from 5 to 9 in getCallerClassNamesInStackWalker to collect more frames. Replace the previous hardcoded caller offset (1) with a computed offset (invocationFrame + 2) when resolving the caller class, ensuring correct caller resolution for deeper or nested invocation stacks.
Remove StackWalker-based caller lookup and related reflection/version utilities from StackTraceUtils. This change deletes imports, constants, static initializers, logger, and methods such as getCallerClassName, getCallerClassNames, getCallerClassNameInGeneralJVM and other StackWalker/StackFrame helpers, leaving only getStackTrace() and the private constructor. The class is simplified to no longer perform stack-walking or reflectively invoke StackWalker APIs.
Replace multiple caller-name and Java-version-dependent tests with a single simple test that asserts StackTraceUtils.getStackTrace() is not null. Clean up imports accordingly and remove tests for getCallerClassName, getCallerClassNames and VersionUtils checks.
Delete the JMH benchmark class StackTraceElementUtilsBenchmark from microsphere-java-core tests. Removes io/microsphere/util/StackTraceElementUtilsBenchmark.java which contained benchmarks for StackTraceUtils (getCallerClassName and getCallerClassNameInGeneralJVM).
Introduce utilities to determine caller classes/names using Thread#getStackTrace. A static invocationFrameOffset is computed at class init by scanning StackTraceElement frames for this utility class, and helper methods were added: getCallerClassInStatckTrace(), getCallerClassNameInStackTrace(), getCallerClassInStatckTrace(int) and getCallerClassNameInStackTrace(int). The implementation resolves class names to Class<?> via resolveClass and returns null when a target frame is unavailable.
Add unit tests to StackTraceUtilsTest covering caller-related utilities. Introduces CALLER_CLASS and CALLER_CLASS_NAME constants and tests for getCallerClassInStatckTrace(), getCallerClassNameInStackTrace(), and an out-of-range frame case (assertNull). Also adds necessary static imports for the new assertions and methods.
Rename and consolidate stack-frame offset fields and simplify caller-class detection logic. Fields like sunReflectReflectionInvocationFrame and stackWalkerInvocationFrame were renamed to sunReflectReflectionInvocationFrameOffset and stackWalkerInvocationFrameOffset, and offset calculations were adjusted to account for invocation-level increments. Removed several stack-trace-based helper methods and fallbacks, simplified getCallerClassInSunReflectReflection to always try the MethodHandle call, and updated StackWalker-related logic to use the new offsets. Tests were updated to import StackTraceUtils helpers and to reflect the new offset behavior and assertions. This change reduces reliance on fragile stack-trace indexing and unifies offset handling across JVM detection paths.
Replace the fully-qualified ReflectionUtils.getCallerClassNameInStackTrace() call with a static import of getCallerClassNameInStackTrace from StackTraceUtils in ReflectionUtilsBenchmark. This clarifies the method origin and keeps the test import style consistent with other helper methods.
Replace reflection-based getCallerClass(...) with StackTraceUtils.getCallerClassInStatckTrace(...) and update import accordingly. Adjust the default caller frame in getCallerClassLoader() from 4 to 5 to account for the different stack depth used by the new stack-trace-based lookup.
Change the stack depth used to resolve the caller ClassLoader from 4 to 5 when loadedClass is null. This adjusts the caller lookup to account for an additional stack frame in the call chain so the correct ClassLoader is returned, preventing incorrect loader resolution in certain call contexts.
Introduce SecurityUtils utility to manage the java.security.policy system property (constant, getter, and setters accepting String and File). Adds annotations and a private constructor. Include JUnit 5 tests (SecurityUtilsTest) that verify the constant and set/get behavior, prepare a module base path for resources, and clear system properties after each test.
Add class-load-test.policy under microsphere-java-core/src/test/resources/META-INF that grants java.security.AllPermission for test runs. This enables unrestricted class loading and security permissions during class-load related tests.
Replace Thread.currentThread().getContextClassLoader() with ClassLoaderUtils.getDefaultClassLoader() in getBundle to standardize how the ClassLoader is obtained. Added static import for getDefaultClassLoader and removed the unused static import of Thread.currentThread(). This ensures a consistent/default class loader is used when loading resource bundles.
Refactor ClassLoaderUtils to simplify null handling and returns. Added static import of Objects.nonNull and replaced explicit null checks/ternary logic in getDefaultClassLoader and getClassLoader with more concise calls and returns. Use nonNull in isLoadedClass and delegate null-to-empty handling to ofSet for resource and class list returns, removing several redundant null checks and try/catch blocks for cleaner code while preserving fallback semantics (bootstrap -> system ClassLoader).
Switch the test to extend LoggingTest and implement Loggable, add a classLoader field and an @AfterEach reset to restore verbose state. Introduce new unit tests (caller-classloader out-of-bounds, getClassResourceWithClass, and ResourceType DEFAULT/CLASS/PACKAGE behavior). Add/import several test constants and ResourceType static imports and adjust imports accordingly.
Add a unit test asserting jsonStringer.toString() returns null, and import assertNull. Remove an empty placeholder testBeforeValue() method. Minor EOF newline adjustment.
Update testReadEscapeCharacter to include an extra 'c' in the input string and add an assertion that readEscapeCharacter() returns 'c'. Ensures the tokener correctly returns a non-escape character following escape sequences.
Add two assertions to strengthen MapUtilsTest: verify nestedMap correctly returns the top-level value for a map with dotted keys (A, A.B, A.B.C) and verify extraProperties returns an empty map for a single-entry map (A=1). These checks cover edge cases for nested key resolution and extraProperties handling.
Extend ConfigurerTest with a case that calls configure((Object) null). The new test ensures the Configurer API can accept a null target and still perform compare/apply calls without throwing, increasing test coverage for null handling.
Introduce io.microsphere.collection.Iterators utility class with a static equals(Iterator, Iterator) method that compares two iterators element-by-element using Objects.equals and correctly handles nulls and differing lengths. Class includes a private constructor to prevent instantiation and implements the Utils marker interface. File is added with ASF license header and author metadata.
Add a new JUnit 5 test class IteratorsTest that verifies Iterators.equals behavior. Tests cover same iterator, equal iterators, different iterators, null handling, and same-size but different-order iterators. Uses CollectionUtils.emptyIterator and Lists.ofList; file includes ASF license header and author tag.
Add a Javadoc comment for the Iterators.equals(Iterator, Iterator) method, documenting the two iterator parameters and the boolean return value. This improves API documentation without changing runtime behavior.
Replace manual while-loop element comparisons with a call to Iterators.equals(iterator, otherIterator). This simplifies the code, reduces boilerplate, and ensures correct handling of element and length comparisons between the two iterators.
Replace unqualified 'instance' references with 'this.instance' throughout MutableCollectionTest to improve clarity and avoid potential shadowing; updates assertions, iterator usage, toArray/toArray(T[]), add/remove operations, collection bulk ops, forEach, hashCode and toString checks accordingly.
Adds a new test that calls instance.remove(null) before invoking super.testRemove(), ensuring the reversed deque handles removal of null without throwing and preserves expected behavior.
Make BeanUtilsTest extend LoggingTest (add import) to enable test logging, and add an extra assertion in testGetBeanMetadata to verify that findWriteMethod returns null for a non-existent property name ("not-found").
|
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.



This pull request adds an additional test case to improve coverage of exception handling in the
ThrowableConsumerTestclass.Testing improvements:
testExecute3OnHandleExceptiontest method toThrowableConsumerTest.javato verify the behavior of theexecutemethod when handling exceptions.