OAK-12125: Use sentinel when propertyNames is null#2784
Conversation
| 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"); |
There was a problem hiding this comment.
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.
| // get property names | ||
| PropertyState names = definition.getProperty(PROPERTY_NAMES); | ||
| if (names.count() == 1) { | ||
| if (names == null && Boolean.parseBoolean(System.getProperty(FT_GRANITE_63829))) { |
There was a problem hiding this comment.
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
dd22638 to
0edf00b
Compare
| Field f = PropertyIndexEditorProvider.class.getDeclaredField("feature"); | ||
| f.setAccessible(true); | ||
| f.set(provider, feature); |
There was a problem hiding this comment.
I think we should not use setAccessible
a42a018 to
12aa9a6
Compare
…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>
Links