Skip to content

Refactor: Add null check, optimize string joining, and add JavaDocs #3663

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

Conversation

KoreaNirsa
Copy link
Contributor

Summary

This PR improves the getTextContent method in OpenAiApi with better performance, input validation, and complete documentation.

Changes

  • Assert.notNull(content, "content cannot be null") to prevent potential NullPointerException
  • .reduce("", (a, b) -> a + b) with .collect(Collectors.joining()) for O(n) string concatenation
  • JavaDocs with parameter/return/exception descriptions for better maintainability

@KoreaNirsa KoreaNirsa force-pushed the refactor/getTextContent-joining-and-null-check branch from 4f0489b to 399e419 Compare June 25, 2025 09:47
Copy link
Contributor

@sunyuhan1998 sunyuhan1998 left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Contributor

@yuluo-yx yuluo-yx left a comment

Choose a reason for hiding this comment

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

Good job

@ilayaperumalg
Copy link
Member

@KoreaNirsa Thanks for the cleanup and documentation!

@ilayaperumalg ilayaperumalg merged commit 8d45caf into spring-projects:main Jul 2, 2025
2 checks passed
spring-builds pushed a commit that referenced this pull request Jul 2, 2025
…3663)

* Refactor: Add null check, optimize string joining, and add JavaDocs

Fixes #3663

Signed-off-by: nirsa <[email protected]>
(cherry picked from commit 8d45caf)
TheEterna added a commit to TheEterna/spring-ai that referenced this pull request Jul 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants