Skip to content

Conversation

@mercyblitz
Copy link
Contributor

@mercyblitz mercyblitz commented Sep 29, 2025

This pull request introduces several improvements and refactorings across the codebase, focusing on enhancing the StringUtils utility methods, updating dependencies, and improving test coverage and maintainability. The most notable changes include a complete rewrite of the split methods in StringUtils, the addition of a contributor code of conduct, and updates to dependency management for Spring compatibility.

String utilities enhancements

  • Refactored StringUtils.split methods to handle more edge cases (null/empty strings, empty delimiters, single-character delimiters), added annotations for null-safety, and replaced the use of StringTokenizer with custom logic for splitting. This improves correctness and consistency across usages. [1] [2]
  • Added new utility method toStringArray(Collection<String>) to safely convert collections to string arrays, returning an empty array for null or empty collections.

Test improvements

  • Expanded StringUtilsTest to cover new edge cases in split, replace, substringBeforeLast, substringAfterLast, and to test the new toStringArray method. Refactored tests for clarity and correctness. [1] [2] [3] [4] [5] [6]
  • Improved concurrency handling in FileUtilsTest by refactoring the test for directory deletion to run in a separate thread and properly handle executor shutdown. [1] [2]
  • Minor cleanup in ClassDataRepositoryTest to remove an unnecessary assertion.

Dependency and configuration updates

  • Updated Spring version to 6.2.11 in the parent POM, and added a Maven profile for Spring 5 compatibility for Java 8-16 environments, improving build flexibility. [1] [2]
  • Updated the parent build version in the root pom.xml from 0.2.0 to 0.2.1.

Project governance

  • Added a CODE_OF_CONDUCT.md file based on the Contributor Covenant, establishing clear guidelines for community behavior and reporting mechanisms.

Minor fixes

  • Fixed an off-by-one bug in URLUtils.findSubProtocolsString to correctly extract subprotocols from URLs.

…rojects#193

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.
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.
@mercyblitz mercyblitz requested a review from Copilot September 29, 2025 02:44
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR upgrades the Spring framework version from 5.3.31 to 6.2.11 and adds Java version-based profile support to maintain backward compatibility. It also refactors a test method to run in a separate executor thread.

  • Upgrades Spring framework to version 6.2.11 with fallback profile for Spring 5.3.31 on Java 8-16
  • Adds Maven profile for conditional Spring version selection based on JDK version
  • Refactors FileUtilsTest to execute deletion test in separate thread executor

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
microsphere-java-parent/pom.xml Updates Spring version and adds JDK-based profile for Spring 5 compatibility
microsphere-java-core/src/test/java/io/microsphere/io/FileUtilsTest.java Refactors test method to run in executor thread with proper shutdown handling

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines 119 to 121
while (!executor.isTerminated()) {
sleep(10L);
}
Copy link

Copilot AI Sep 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This busy-wait loop with sleep could run indefinitely if the executor never terminates. Consider using executor.awaitTermination(timeout, timeUnit) with a reasonable timeout to prevent potential test hangs.

Suggested change
while (!executor.isTerminated()) {
sleep(10L);
}
// Wait for executor to terminate, with a timeout to prevent hangs
boolean terminated = executor.awaitTermination(5000L, MILLISECONDS);
assertTrue(terminated, "Executor did not terminate within timeout");

Copilot uses AI. Check for mistakes.
@codecov
Copy link

codecov bot commented Sep 29, 2025

Codecov Report

❌ Patch coverage is 95.00000% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...src/main/java/io/microsphere/util/StringUtils.java 94.73% 0 Missing and 1 partial ⚠️
Files with missing lines Coverage Δ Complexity Δ
...ore/src/main/java/io/microsphere/net/URLUtils.java 90.05% <100.00%> (ø) 119.00 <0.00> (ø)
...src/main/java/io/microsphere/util/StringUtils.java 99.26% <94.73%> (-0.74%) 89.00 <8.00> (+5.00) ⬇️

... and 3 files with indirect coverage changes

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

…ects#191

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.
@sonarqubecloud
Copy link

sonarqubecloud bot commented Oct 4, 2025

@mercyblitz mercyblitz merged commit 70770cf into microsphere-projects:dev Oct 4, 2025
7 checks passed
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