IcoreE opened a new pull request, #1530:
URL: https://github.com/apache/commons-lang/pull/1530

   ```
   // source code
   public static CharSet getInstance(final String... setStrs) {
       if (setStrs == null) {
           return null; // error
       }
       if (setStrs.length == 1) {
           final CharSet common = COMMON.get(setStrs[0]);
           if (common != null) {
               return common;
           }
       }
       return new CharSet(setStrs);
   } 
   ```
   The getInstance method of CharSet currently returns null when the input 
parameter setStrs is null. This behavior contradicts the documentation, which 
states that a null input should return the EMPTY constant (an empty character 
set). Returning null can lead to NullPointerException in calling code that 
expects a valid CharSet instance even for empty inputs.
   
   The Javadoc and source code are as follows:
   <img width="896" height="491" alt="image" 
src="https://github.com/user-attachments/assets/1ab28a8e-e76a-4f1f-ac50-15f005001ea5";
 />
   
   ```
   // Test NullPointerException
       @Test
       void testGetInstance_Null_Fixed_ReturnsEmpty_NoNPE() {
           CharSet charSet = CharSet.getInstance(null);
           assertThrows(NullPointerException.class,()->charSet.contains('['));
       } 
   ```
   


-- 
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]

Reply via email to