Skip to content

Conversation

6mmLIU
Copy link
Contributor

@6mmLIU 6mmLIU commented Sep 11, 2025

Describe what this PR does / why we need it

Replaces calls to printStackTrace with an SLF4J logger in DateUtils.parseDateString so that failures are logged appropriately without throwing uncaught exceptions. On parse failure, the method now logs a warning and returns null. Adds unit test coverage for both successful parsing and failure scenarios to prevent regressions and ensure robustness.

Does this pull request fix one issue?

NONE

Describe how you did it

Introduced a private static SLF4J Logger in DateUtils.

Wrapped the sdf.parse(time) call in a try/catch block; on ParseException, call logger.warn("Failed to parse date string: {}", time, e) and return null.

Wrote JUnit tests verifying that:

A valid date string (e.g. "Wed Sep 10 14:23:45 GMT 2025") returns a non-null Date.

An invalid string (e.g. "not-a-date") yields null and emits a warning.

Describe how to verify it

Run the core module’s tests:

mvn -q -pl spring-ai-alibaba-studio/spring-ai-alibaba-studio-server/spring-ai-alibaba-studio-server-core -am test

Verify all tests pass. Additionally, trigger a failure case in a debugger or by running a small main method to confirm that a warning is logged (rather than a stack trace printed) when parsing an invalid string.

@github-actions github-actions bot added the area/studio SAA Studio module label Sep 11, 2025
@VLSMB VLSMB changed the title refactor(core): improve date parsing error handling refactor(studio): improve date parsing error handling Sep 12, 2025
@VLSMB
Copy link
Collaborator

VLSMB commented Sep 13, 2025

Please format your code and have a LICENSE before each new file is added

@github-actions github-actions bot added the area/infra SAA Infra module label Sep 13, 2025
@6mmLIU 6mmLIU requested a review from VLSMB September 15, 2025 03:54
@github-actions github-actions bot removed the area/infra SAA Infra module label Sep 15, 2025
Copy link
Collaborator

@VLSMB VLSMB left a comment

Choose a reason for hiding this comment

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

LGTM

@VLSMB VLSMB merged commit d553960 into alibaba:main Sep 15, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/studio SAA Studio module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants