[ELASTIC-19] Index creation fails with a NullPointerException when no linkGeneratorClass is given Created: 18/Jan/22 Updated: 18/Jan/22 |
|
| Status: | Open |
| Project: | Elasticsearch |
| Component/s: | None |
| Affects Version/s: | 1.0.0 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Neutral |
| Reporter: | wolf bubenik | Assignee: | Unassigned |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Java 11, Magnolia 6.2.15 |
||
| Template: |
|
| Patch included: |
Yes
|
| Acceptance criteria: |
[ ]*
The field for the linkGeneraorField should be mandatory or the index creation should work without it.
|
| Task DoD: |
[ ]*
Doc/release notes changes? Comment present?
[ ]*
Downstream builds green?
[ ]*
Solution information and context easily available?
[ ]*
Tests
[ ]*
FixVersion filled and not yet released
[ ] 
Architecture Decision Record (ADR)
|
| Bug DoR: |
[ ]*
Steps to reproduce, expected, and actual results filled
[ ]*
Affected version filled
|
| Description |
|
The Index Editor app does not require to add a linkGeneratorClass. However, if it is missing the index creation fails with a NullPointerException in IndexJcrDataFactory.
Workaround: Patch IndexJcrDataFactory.addLinkFields(...) and add null check protected static void addLinkFields(GeneratedIndexPackage indexPackage, Node node, IndexItemConfiguration index, MappingItemConfiguration mappingField) throws ElasticConfigurationException { if (index.getLinkGeneratorClass() != null) { IndexFieldsLinkGenerator<?> linkGenerator = Components.getComponent(index.getLinkGeneratorClass()); if (linkGenerator instanceof JcrIndexFieldsLinkGenerator) { JcrIndexFieldsLinkGenerator<Node> jcrLinkGenerator = (JcrIndexFieldsLinkGenerator<Node>) linkGenerator; Map<String, String> linkMap = jcrLinkGenerator.getLinks(node); for (String linkFieldName : linkMap.keySet()) { String link = linkMap.get(linkFieldName); ElasticItem elasticItemManually; try { elasticItemManually = new ElasticItem(TypeSpecification.TEXT, linkFieldName, node.getPath(), node.getIdentifier()); elasticItemManually.setValue(link); indexPackage.getIndexPackage().put(elasticItemManually.getName(), elasticItemManually); indexPackage.setItemsAdded(true); } catch (RepositoryException e) { throw new ElasticConfigurationException("query-manager.elastic-index-app.error.unable_read_node", e, log); } } } } } |