Fix silently swallowed Solr core initialization failures - #848
Open
gallardo wants to merge 1 commit into
Open
Conversation
When the embedded Solr core cannot be created in registerSolrIndex() - e.g. CoreContainer.create() throws a SolrException wrapping an IndexFormatTooOldException after a Lucene major version upgrade - the exception is not converted into a CmsConfigurationException, because only NullPointerException is caught. It then propagates past the handling in CmsSolrIndex#initialize() that would disable the index, so the index stays enabled without a Solr client, initSearchIndexes() reports it as successfully configured, and every later query fails with an unexplained NullPointerException on the missing client. Two changes: - registerSolrIndex(): catch RuntimeException instead of only NullPointerException around core creation and wrap it into the existing CmsConfigurationException, so the index is disabled with a clear error. - initSearchIndexes(): also disable the index in the catch block, so any initialization failure not handled inside initialize() itself is reported truthfully by the status log instead of as a success. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
gallardo
marked this pull request as ready for review
July 28, 2026 15:36
Contributor
Author
Verification of PR #848 on OpenCms 21.0.1 (official Docker image)Environment: Without the fix (stock 21.0.1 jar) — the bugStartup log ( Every subsequent Solr query fails ( With the fix (same corruption, patched jar =
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When the embedded Solr core of a
CmsSolrIndexcannot be created, the failure is effectively swallowed and the index is left in a broken-but-enabled state:CmsSearchManager#registerSolrIndex(), onlyNullPointerExceptionis caught aroundCoreContainer.create(...). Any otherRuntimeException— e.g. aSolrExceptionwrapping anorg.apache.lucene.index.IndexFormatTooOldException— propagates raw.CmsConfigurationExceptionhandling inCmsSolrIndex#initialize()that would disable the index, and lands in the broadcatch (Exception)ofCmsSearchManager#initSearchIndexes(), which only logs a WARN.setEnabled(false)never ran, the status report right below logs the index as successfully configured (directly after the WARN about its failed initialization), and every later query against the index fails with an unexplainedNullPointerExceptionon the missing Solr client (m_solris null).This is not a theoretical path: after upgrading an installation to Solr/Lucene 10, a "Solr Online" index whose data directory was originally created with Lucene 8.x fails core creation with
IndexFormatTooOldException(Lucene only reads indexes created by the current and previous major version). The only diagnostics are one WARN at startup plus misleading "successfully configured" INFO, followed by NPEs at query time. A follow-on symptom of the half-failed creation isSolrException: Could not create a new core in .../solr/<name> as another core is already defined thereon re-initialization.Changes
registerSolrIndex(): catchRuntimeExceptioninstead of onlyNullPointerExceptionaround core creation and wrap it into the existingCmsConfigurationException, so the index is disabled through the normal path with a clear error message.initSearchIndexes(): additionally callindex.setEnabled(false)in thecatchblock, so any initialization failure not handled insideinitialize()itself is reported truthfully by the status log instead of as a success.Status
Draft until tested against a real installation (reproduction environment: OpenCms with embedded Solr 10 and a Lucene-8-created index directory).
🤖 Generated with Claude Code