Skip to content

OAK-12125: Use sentinel when propertyNames is null#2784

Closed
tmvlad wants to merge 2 commits into
apache:trunkfrom
tmvlad:OAK-12125
Closed

OAK-12125: Use sentinel when propertyNames is null#2784
tmvlad wants to merge 2 commits into
apache:trunkfrom
tmvlad:OAK-12125

Conversation

@tmvlad

@tmvlad tmvlad commented Mar 6, 2026

Copy link
Copy Markdown
Contributor
  • A property index definition with `type=property` but missing the required `propertyNames` property caused a `NullPointerException` in `PropertyIndexEditor` that was not caught by `IndexUpdate`, breaking the entire async indexing cycle for all indexes
  • Fix: use a default when encountering a 'null' value for propertyNames, log a WARN and continue processing without throwing.

Links

PropertyState names = definition.getProperty(PROPERTY_NAMES);
if (names.count() == 1) {
if (names == null) {
throw new IllegalStateException("Missing required property '" + PROPERTY_NAMES + "' in property index definition");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So instead of a NPE we now get an IllegalStateException... It might currently resolve the problem, but I think it is not a good solution, because still an exception is thrown. There is a performance overhead in throwing an exception, but more importantly exception handing is not part of the API, and so changes in the future might break this logic. Also, there is no logging.

An alternative solution would be:

  • Use a default value if no propertyNames are set, eg. use the value "propertyNamesIsMissing". A property name that is so unlikely to occur in practice that there are no repositories with this property. (And if there are, then actually it wouldn't be a problem.)
  • Log a warning, but only once. Only once such that the log file is not filled.

@tmvlad tmvlad changed the title OAK-12125: throw IllegalStateException for property index missing propertyNames OAK-12125: Use sentinel when propertyNames is null Jun 1, 2026
@thomasmueller thomasmueller self-requested a review June 1, 2026 07:59
// get property names
PropertyState names = definition.getProperty(PROPERTY_NAMES);
if (names.count() == 1) {
if (names == null && Boolean.parseBoolean(System.getProperty(FT_GRANITE_63829))) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So far we throw a NullPointerException. We could argue a feature toggle is not needed in this case. But let's add one anyway (possibly NPE is better than not throwing a NPE, for some weird reason).

Please use a feature toggle like other we use, see oak-core-spi/src/main/java/org/apache/jackrabbit/oak/spi/toggle/FeatureToggle.java

@tmvlad tmvlad force-pushed the OAK-12125 branch 2 times, most recently from dd22638 to 0edf00b Compare June 1, 2026 11:57
@thomasmueller thomasmueller self-requested a review June 1, 2026 12:29
Comment on lines +1338 to +1340
Field f = PropertyIndexEditorProvider.class.getDeclaredField("feature");
f.setAccessible(true);
f.set(provider, feature);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should not use setAccessible

@tmvlad tmvlad force-pushed the OAK-12125 branch 2 times, most recently from a42a018 to 12aa9a6 Compare June 1, 2026 12:56
tmvlad and others added 2 commits June 2, 2026 14:20
…ache#2924)

A missing 'propertyNames' caused an NPE that escaped IndexUpdate's
IllegalStateException catch and broke the async indexing cycle. Add an
opt-in fallback gated by FT_GRANITE-63829 (registered in @activate, driven
by LaunchDarkly in production): when on, the editor logs one WARN per
misconfigured index path and uses a sentinel property name so the cycle
continues. Default off preserves the pre-PR behavior.

Co-authored-by: Theia Vlad <tvlad@Theias-MacBook-Pro.local>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants