Skip to content

PropertyDefinitionUsageBuilder.visitString() throws NullPointerException for pattern without synopsis #709

Description

@vharseko

Problem

PropertyDefinitionUsageBuilder.visitString() throws a NullPointerException for string properties which define a pattern but no pattern synopsis:

if (isDetailed) {
    LocalizableMessageBuilder builder = new LocalizableMessageBuilder();
    builder.append(d.getPatternUsage());
    builder.append(" - ");
    builder.append(d.getPatternSynopsis());   // <-- NPE: synopsis is optional and may be null
    return builder.toMessage();
}
java.lang.NullPointerException: message was null
	at org.forgerock.i18n.LocalizableMessageBuilder.append(LocalizableMessageBuilder.java:180)
	at org.forgerock.opendj.config.PropertyDefinitionUsageBuilder$MyPropertyDefinitionVisitor.visitString(PropertyDefinitionUsageBuilder.java:231)
	at org.forgerock.opendj.config.StringPropertyDefinition.accept(StringPropertyDefinition.java:135)
	at org.forgerock.opendj.config.PropertyDefinitionUsageBuilder.getUsage(PropertyDefinitionUsageBuilder.java:270)
	at org.forgerock.opendj.config.PropertyException.createMessage(PropertyException.java:130)
	at org.forgerock.opendj.config.PropertyException.illegalPropertyValueException(PropertyException.java:62)
	at org.forgerock.opendj.config.StringPropertyDefinition.validateValue(StringPropertyDefinition.java:243)

Impact

Every pattern validation failure for such a property crashes with an NPE while building the error message, instead of reporting the intended PropertyException with a usage description. PropertyException.createMessage() runs this code on the real error reporting path (e.g. dsconfig value validation), so this is not test-only.

This is also the long-standing "I18N problem" that kept the two pattern-mismatch methods of StringPropertyDefinitionTest disabled since the ForgeRock era.

Fix

Append the synopsis only when present. Fix and the re-enabled regression tests (2×42/42 green in opendj-config) are included in #707 — this issue can be closed once #707 is merged.

Found during the test audit (#684-#707).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions