Skip to content

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
scionaltera pushed a commit to scionaltera/spring-ai that referenced this pull request Sep 3, 2025
…pring-projects#3663)

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

Auto-cherry-pick to 1.0.x
Fixes spring-projects#3663

Signed-off-by: nirsa <[email protected]>
chedim pushed a commit to couchbaselabs/spring-ai that referenced this pull request Sep 19, 2025
…pring-projects#3663)

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

Auto-cherry-pick to 1.0.x
Fixes spring-projects#3663

Signed-off-by: nirsa <[email protected]>
Willam2004 pushed a commit to Willam2004/spring-ai that referenced this pull request Oct 11, 2025
…pring-projects#3663)

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

Auto-cherry-pick to 1.0.x
Fixes spring-projects#3663

Signed-off-by: nirsa <[email protected]>
Signed-off-by: 家娃 <[email protected]>
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