atheendre130505 opened a new pull request, #21355: URL: https://github.com/apache/kafka/pull/21355
Description This PR implements character range support (e.g., `[a-z]`, `[0-9]`, `[abc]`) for glob pattern matching within the Kafka shell module. It addresses a long-standing `TODO` comment in `GlobComponent.java`. The implementation includes: - Support for basic character ranges and sets. - Support for negation using both `!` and `^` (e.g., `[!a-z]`). - Proper handling of escaped characters within brackets (e.g., `[a\-z]`). - Handling of literal `]` as the first character in a set (e.g., `[]abc]`). - Error handling for unterminated character classes. Additionally, the `toRegularExpression` method was refactored to extract bracket and escape handling into separate private methods. This was done to reduce the NPath complexity from **1020** to within the project's Checkstyle limit (500). Testing Strategy The changes were verified using unit tests in `GlobComponentTest.java`. A new set of comprehensive test cases was added to cover: - Basic character ranges and sets matching. - Negation patterns. - Escaped characters inside and outside brackets. - Combined patterns (e.g., character ranges with wildcards `*` and `?`). - Edge cases like literal bracket placements and unterminated ranges. - Verified that existing shell glob tests still pass. All tests were executed and passed on a local environment using OpenJDK 21. License I state that the contribution is my original work and that I license the work to the project under the project's open source license. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
