Skip to content

Conversation

@xterao
Copy link
Collaborator

@xterao xterao commented May 16, 2025

When locating the associated SQL and DAO files, if the original file path doesn’t contain the expected substring, String.indexOf() returns -1, causing the subsequent String.substring() call to throw an exception.

Add a guard to check the result of indexOf() and only perform the substring operation when it yields a valid index.

@xterao xterao requested a review from Copilot May 16, 2025 02:39
@xterao xterao self-assigned this May 16, 2025
@xterao xterao added bug Something isn't working fix Bug fixes labels May 16, 2025
@xterao xterao linked an issue May 16, 2025 that may be closed by this pull request
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 addresses a StringIndexOutOfBoundsException by adding a guard for substring extraction when the expected path substring is missing. The key changes include:

  • Removal of the unused function isJavaOrKotlinFileType(VirtualFile)
  • Addition of guard logic in searchDaoFile() to validate the substring index before extraction
  • Inclusion of debug print statements and a TODO note for future improvements

@xterao xterao force-pushed the fix/string-indexout-of-bounds-exception branch from 776c2cf to 4b66649 Compare May 16, 2025 02:43
@xterao xterao merged commit 3d3f1d6 into main May 16, 2025
3 checks passed
@xterao xterao deleted the fix/string-indexout-of-bounds-exception branch May 16, 2025 07:00
@xterao xterao added this to the 0.8.0 Release milestone May 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working fix Bug fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

StringIndexOutOfBoundsException

2 participants