-
Notifications
You must be signed in to change notification settings - Fork 54
Release 0.1.6 #198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Release 0.1.6 #198
Conversation
Sync dev code
Removed the 'spring-core' test dependency from microsphere-java-core/pom.xml and added multiple Spring Framework source files under src/test/java for testing purposes. This change allows tests to run without relying on the external spring-core dependency.
This reverts commit 66405ee.
Bumped the default Spring version to 6.2.11. Added a Maven profile 'spring5' to use Spring 5.3.31 for JDK versions 1.8 to 16, ensuring compatibility with older Java versions.
Reimplemented StringUtils.split to avoid StringTokenizer, handle null and empty delimiters, and added toStringArray utility. Updated StringUtilsTest to cover new edge cases and ensure compatibility with Spring's delimitedListToStringArray.
Corrects the substring indices when extracting the protocol from a URL string, ensuring the returned value does not include a leading character.
Eliminated redundant sleep call in FileUtilsTest to improve test efficiency and clarity.
Release 0.1.6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Release update introducing enhanced String utilities, expanded tests, new collection-to-array helper, Spring version/profile adjustments, build matrix update, and added community guidelines.
- Refactored StringUtils.split to support null and empty delimiters plus character-wise splitting when delimiter is empty.
- Added toStringArray(Collection) and broadened related unit tests.
- Introduced Spring 5 fallback profile for older JDKs and added Java 25 to CI matrix.
Reviewed Changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| pom.xml | Bumped project revision and parent build version. |
| microsphere-java-parent/pom.xml | Upgraded Spring to 6.2.11 with JDK-conditional Spring 5 profile. |
| microsphere-java-core/src/main/java/io/microsphere/util/StringUtils.java | Refactored split logic; added toStringArray and annotations; updated examples. |
| microsphere-java-core/src/main/java/io/microsphere/net/URLUtils.java | Corrected substring extraction for subprotocols. |
| microsphere-java-core/src/main/java/io/microsphere/util/ClassPathUtils.java | Minor documentation formatting tweak. |
| microsphere-java-core/src/test/java/io/microsphere/util/StringUtilsTest.java | Expanded split/replace/substring tests and added toStringArray coverage. |
| microsphere-java-core/src/test/java/io/microsphere/io/FileUtilsTest.java | Refactored an asynchronous test pattern for delete directory IOException scenario. |
| microsphere-java-core/src/test/java/io/microsphere/lang/ClassDataRepositoryTest.java | Removed immutability assertion on returned Set. |
| microsphere-annotation-processor/src/test/java/io/microsphere/annotation/processor/TestAnnotation.java | Switched to static imports for retention/target constants. |
| CODE_OF_CONDUCT.md | Added contributor code of conduct. |
| .github/workflows/maven-build.yml | Added Java 25 to CI build matrix. |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| assertEquals(TEST_EMPTY_STRING, replace(TEST_EMPTY_STRING, "null", null)); | ||
| assertEquals(TEST_CSV_STRING, replace(TEST_CSV_STRING, "null", "null")); | ||
|
|
||
| assertEquals(TEST_EMPTY_STRING, replace(TEST_EMPTY_STRING, null, null)); |
Copilot
AI
Oct 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicate assertion on lines 180 and 184 adds noise without increasing coverage; remove one of them.
| assertEquals(TEST_EMPTY_STRING, replace(TEST_EMPTY_STRING, null, null)); |
microsphere-java-core/src/test/java/io/microsphere/util/StringUtilsTest.java
Outdated
Show resolved
Hide resolved
| ExecutorService executor = newSingleThreadExecutor(); | ||
| executor.submit(this::testDeleteDirectoryOnIOException0); | ||
| shutdown(executor); | ||
| while (!executor.isTerminated()) { | ||
| } |
Copilot
AI
Oct 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exceptions thrown in the submitted task are never observed (no Future captured), so the test can pass despite failures; capture the Future and call get() (e.g., Future<?> f = executor.submit(...); f.get();), eliminating the silent failure.
| while (!executor.isTerminated()) { | ||
| } |
Copilot
AI
Oct 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Busy-wait loop wastes CPU cycles; replace with executor.awaitTermination(timeout, unit) or Future.get() to block efficiently.
| while (!executor.isTerminated()) { | |
| } | |
| executor.awaitTermination(1000, MILLISECONDS); |
microsphere-java-core/src/test/java/io/microsphere/io/FileUtilsTest.java
Outdated
Show resolved
Hide resolved
| * <h3>Example Usage</h3> | ||
| * <pre>{@code | ||
| * StringUtils.split(null, ",") = [] | ||
| * StringUtils.split("", null) = [] | ||
| * StringUtils.split("", ";") = [] | ||
| * StringUtils.split("abc", "") = ["a", "b", "c"] | ||
| * StringUtils.split("a,b,c", ",") = ["a", "b", "c"] |
Copilot
AI
Oct 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Document the behavior for a non-empty String with a null delimiter (returns the whole String as a single element) to clarify the difference from empty and blank inputs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| executor.submit(this::testDeleteDirectoryOnIOException0); | ||
| shutdown(executor); | ||
| while (!executor.isTerminated()) { |
Copilot
AI
Oct 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assertions and exceptions inside testDeleteDirectoryOnIOException0 will not fail the test because the Future returned by submit(...) is ignored; any AssertionError thrown in the worker thread is swallowed. Capture the Future and call future.get() (or use executor.submit(...).get()) so failures propagate, or invoke the helper method directly on the test thread.
| executor.submit(this::testDeleteDirectoryOnIOException0); | |
| shutdown(executor); | |
| while (!executor.isTerminated()) { | |
| try { | |
| // Capture the Future and call get() to propagate exceptions | |
| executor.submit(this::testDeleteDirectoryOnIOException0).get(); | |
| } finally { | |
| shutdown(executor); | |
| while (!executor.isTerminated()) { | |
| } |
| if (startIndex <= length) { | ||
| // Add rest of String, but not in case of empty input. | ||
| result.add(value.substring(startIndex)); | ||
| } |
Copilot
AI
Oct 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Condition 'if (startIndex <= length)' is always true here (startIndex cannot exceed length) given earlier flow and the empty-input guard at line 162, making the check redundant. Remove the conditional and add the tail element unconditionally to simplify.
| if (startIndex <= length) { | |
| // Add rest of String, but not in case of empty input. | |
| result.add(value.substring(startIndex)); | |
| } | |
| // Add rest of String, but not in case of empty input. | |
| result.add(value.substring(startIndex)); |
| @Test | ||
| void testReplace() { | ||
| assertNull(replace(null, null, null)); | ||
| assertEquals(TEST_EMPTY_STRING, replace(TEST_EMPTY_STRING, null, null)); |
Copilot
AI
Oct 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicate assertion (line 184 repeats line 180) adds no additional coverage; remove the duplicate to reduce noise.
| * <h3>Example Usage</h3> | ||
| * <pre>{@code | ||
| * StringUtils.split(null, ",") = [] | ||
| * StringUtils.split("", null) = [] | ||
| * StringUtils.split("", ";") = [] | ||
| * StringUtils.split("abc", "") = ["a", "b", "c"] | ||
| * StringUtils.split("a,b,c", ",") = ["a", "b", "c"] | ||
| * StringUtils.split("a;b;c", ",") = ["a;b;c"] | ||
| * StringUtils.split("a,,b,c", ",") = ["a", "", "b", "c"] |
Copilot
AI
Oct 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Javadoc omits the behavior for a non-empty input with a null delimiter (returns the entire String as a single-element array). Add an example (e.g., StringUtils.split("abc", null) = ["abc"]) to fully document the null-delimiter case.
Updated the assertSplit method to correctly handle delimiter length checks and assertions. Now, assertions for single-character and multi-character delimiters are separated, ensuring accurate test validation.
Replaces busy-wait loop with assertTrue using awaitTermination for better test reliability and readability in testDeleteDirectoryOnIOException.
Changed the return type of testDeleteDirectoryOnIOException0 from Void to File and updated the return statement to return the test directory. This improves clarity and allows the caller to access the created directory.
Fix the issues from the code-review
|
Codecov Report❌ Patch coverage is
... and 4 files with indirect coverage changes 🚀 New features to boost your workflow:
|



This pull request introduces several improvements and updates across the codebase, focusing mainly on utility enhancements, test coverage, and project configuration. The most significant changes include a refactor of the
StringUtils.splitmethod for better handling of edge cases, the addition of a utility method for converting collections to string arrays, expanded test coverage for string utilities, and updates to project dependencies and build configurations.String Utilities Enhancements:
StringUtils.splitto handlenulland empty delimiters more robustly, and improved its logic for splitting strings, including support for splitting by empty strings and handling edge cases. [1] [2]StringUtils.toStringArray(Collection<String>)utility method to convert collections of strings to string arrays safely.Test Coverage Improvements:
StringUtilsTestto cover more cases forsplit,replace,substringBeforeLast,substringAfterLast, and added tests for the newtoStringArraymethod. [1] [2] [3] [4] [5] [6]Project Configuration and Documentation:
CODE_OF_CONDUCT.mdfile to establish contributor guidelines and foster a welcoming community.Minor Code and Test Updates:
URLUtils.findSubProtocolsStringto correctly handle subprotocols in URLs.