Hey Aaron, Agreed that it sounds like a bug! We should probably be more defensive in that code. If you haven't ready, are you willing to file a JIRA ticket for this please?
Thanks for surfacing this and sorry for the delayed reply. Best, Jason On Fri, May 8, 2026 at 11:19 PM Aaron Dockter via dev <[email protected]> wrote: > > Hi all, > I'm new to the community, but I have found, what I believe to be, a bug in > the cross-dc module's MirroringUpdateProcessor.ObjectSizeEstimator that > causes a NullPointerException during cross-DC replication when indexing > documents containing fields with null values. Before I log a Jira ticket, > just wanted to throw this out there... > > Problem Description > When using Solr's cross-DC replication feature, indexing operations fail with > a NullPointerException in > MirroringUpdateProcessor.ObjectSizeEstimator.primitiveEstimate(). The error > occurs when a SolrInputDocument contains a field explicitly set to null. > Error Stack Trace > > java.lang.NullPointerException > at > org.apache.solr.crossdc.update.processor.MirroringUpdateProcessor$ObjectSizeEstimator.primitiveEstimate(MirroringUpdateProcessor.java:XXX) > at > org.apache.solr.crossdc.update.processor.MirroringUpdateProcessor$ObjectSizeEstimator.estimate(MirroringUpdateProcessor.java:XXX) > > Root Cause > The primitiveEstimate(Object obj, long def) method calls obj.getClass() > without first checking if obj is null. When a field value is null, this > causes the NPE. > Proposed Fix > Add a null guard at the start of the primitiveEstimate method: > > java > > private static long primitiveEstimate(Object obj, long def) { > if (obj == null) return def; > Class<?> clazz = obj.getClass(); > // ... rest of method > } > > This ensures that when a field value is null, the method returns the default > size estimate instead of attempting to introspect the class type. > Test Case > I've added a regression test in MirroringUpdateProcessorTest.java: > > java > > @Test > public void testObjectSizeEstimatorWithNullFieldValue() { > SolrInputDocument doc = new SolrInputDocument(); > doc.addField("id", "test"); > doc.addField("nullField", null); > long size = MirroringUpdateProcessor.ObjectSizeEstimator.estimate(doc); > assertTrue("size should be non-negative", size >= 0); > } > > Files Changed > > * > solr/modules/cross-dc/src/java/org/apache/solr/crossdc/update/processor/MirroringUpdateProcessor.java > * > solr/modules/cross-dc/src/test/org/apache/solr/crossdc/update/processor/MirroringUpdateProcessorTest.java > > Solr Version > This issue affects the cross-dc module in the Solr codebase (version 9.x > branch). > Would someone from the Solr team be able to review this fix? I'm happy to > submit a pull request if this approach is acceptable. > Thank you for your time and consideration. > Best regards, > Aaron Dockter > --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
