You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@solr.apache.org by Jason Gerlowski <ge...@gmail.com> on 2026/06/05 15:06:37 UTC
Re: NullPointerException in MirroringUpdateProcessor.ObjectSizeEstimator when SolrInputDocument contains null field values
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
<de...@solr.apache.org> 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: dev-unsubscribe@solr.apache.org
For additional commands, e-mail: dev-help@solr.apache.org
Re: NullPointerException in MirroringUpdateProcessor.ObjectSizeEstimator when SolrInputDocument contains null field values
Posted by Jason Gerlowski <ge...@gmail.com>.
Excellent! Glad to learn I was just "behind" and you got the help you
were looking for. Thanks for the contribution!
Jason
On Wed, Jun 10, 2026 at 12:05 AM Aaron Dockter <aa...@smarsh.com> wrote:
>
> Jason,
>
> Thanks! Yeah, no problem at all. The bug was indeed filed and promptly fixed:
> [SOLR-18239] `ObjectSizeEstimator.primitiveEstimate()` calls `obj.getClass()` without checking if `obj` is null - ASF Jira
>
> Cheers,
>
> Aaron
> ________________________________
> From: Jason Gerlowski <ge...@gmail.com>
> Sent: Friday, June 5, 2026 9:06 AM
> To: dev@solr.apache.org <de...@solr.apache.org>
> Cc: Aaron Dockter <aa...@smarsh.com>
> Subject: Re: NullPointerException in MirroringUpdateProcessor.ObjectSizeEstimator when SolrInputDocument contains null field values
>
> CAUTION: This is an EXTERNAL email. Please do not click any links or open attachments unless you recognize the sender and know the content is safe.
>
>
> 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
> <de...@solr.apache.org> 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: dev-unsubscribe@solr.apache.org
For additional commands, e-mail: dev-help@solr.apache.org
Re: NullPointerException in MirroringUpdateProcessor.ObjectSizeEstimator when SolrInputDocument contains null field values
Posted by Aaron Dockter via dev <de...@solr.apache.org>.
Jason,
Thanks! Yeah, no problem at all. The bug was indeed filed and promptly fixed:
[SOLR-18239] `ObjectSizeEstimator.primitiveEstimate()` calls `obj.getClass()` without checking if `obj` is null - ASF Jira<https://issues.apache.org/jira/browse/SOLR-18239>
Cheers,
Aaron
________________________________
From: Jason Gerlowski <ge...@gmail.com>
Sent: Friday, June 5, 2026 9:06 AM
To: dev@solr.apache.org <de...@solr.apache.org>
Cc: Aaron Dockter <aa...@smarsh.com>
Subject: Re: NullPointerException in MirroringUpdateProcessor.ObjectSizeEstimator when SolrInputDocument contains null field values
CAUTION: This is an EXTERNAL email. Please do not click any links or open attachments unless you recognize the sender and know the content is safe.
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
<de...@solr.apache.org> 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
>