On Wed, 16 Sep 2026 10:02:31 GMT, Jaikiran Pai <[email protected]> wrote:

>> Timofei Fedotov has updated the pull request incrementally with one 
>> additional commit since the last revision:
>> 
>>   Add regression test
>
> src/java.naming/share/classes/javax/naming/ldap/Rfc2253Parser.java line 134:
> 
>> 132:             // IndexOutOfBoundsException instead of the documented
>> 133:             // InvalidNameException.
>> 134:             if (rdn.size() == 0) {
> 
> `javax.naming.ldap.Rdn` is a public exported class which means that it can be 
> overridden by (external/application) sub-classes. The `size()` method is 
> public too (and thus can be overridden). I think it would be better to avoid 
> calling this method here and instead we should probably call a 
> package-private method which returns the same detail. 
> 
> So I think introducing something like the following new package-private 
> method in `Rdn` class and then calling `rdn.numAttributes()` here might be 
> better:
> 
> 
> diff --git a/src/java.naming/share/classes/javax/naming/ldap/Rdn.java 
> b/src/java.naming/share/classes/javax/naming/ldap/Rdn.java
> --- a/src/java.naming/share/classes/javax/naming/ldap/Rdn.java
> +++ b/src/java.naming/share/classes/javax/naming/ldap/Rdn.java
> @@ -248,6 +248,15 @@ void sort() {
>          }
>      }
>  
> +    /**
> +     * {@return the number of type/value mappings contained in this Rdn}
> +     * This method is same as {@link #size()}, except that it cannot be
> +     * overridden by sub-classes.
> +     */
> +    final int numAttributes() {
> +        return this.entries.size();
> +    }
> +

Good point. Since Rdn can be subclassed and size() can be overridden, relying 
on it from the parser could make the validation depend on subclass behavior.

So, I'll add a package-private final numAttributes() method.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/32648#discussion_r4024825802

Reply via email to