Skip to content

Use ObjectMapper from SolrJacksonMapper in CachingJsonMessageBodyReader#4370

Open
renatoh wants to merge 7 commits intoapache:mainfrom
renatoh:use_own_objectMapper_in_CachingJsonMessageBodyReader
Open

Use ObjectMapper from SolrJacksonMapper in CachingJsonMessageBodyReader#4370
renatoh wants to merge 7 commits intoapache:mainfrom
renatoh:use_own_objectMapper_in_CachingJsonMessageBodyReader

Conversation

@renatoh
Copy link
Copy Markdown
Contributor

@renatoh renatoh commented Apr 27, 2026

Looking into https://issues.apache.org/jira/browse/SOLR-18191 I released our V2API not using SolrJacksonMapper.getObjectMapper(). This feels wrong to me.

@renatoh renatoh changed the title Use own object mapper in caching json message body reader Use ObjectMapper from SolrJacksonMapper in CachingJsonMessageBodyReader Apr 27, 2026
@epugh
Copy link
Copy Markdown
Contributor

epugh commented Apr 27, 2026

While this makes sense to me, I don't know the ramifications of this change.. I'm tagging @gerlowskija as well. I did trigger the tests to run!

@renatoh
Copy link
Copy Markdown
Contributor Author

renatoh commented May 7, 2026

@dsmiley would be great to get your take on that change, thanks!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't changelog worthy, at least not as-written. No user of Solr will care.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't changelog worthy, at least not as-written. No user of Solr will care.

I am a bit confused what does need a changelog and what not. Small changes without a associate Jira do not need a change log?

What you think of the fix itself, is this a fix or improvement in your opinion?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wether there's a JIRA or not doesn't matter, although it tends to be correlated as something not changelog worthy isn't JIRA-worthy either... although we sometimes create JIRAs to remember to do something which is quite alright.

The way I think of a writing a changelog entry is, I think, rather simple. Step back from the nitty gritty details of the PR and imagine telling a a stranger who uses Solr about what you did in a way that hopefully might interest them. The changelog speaks to the user -- it's a summary that many users read each release. How is this change making Solr better? If it's too much of a stretch to write something of interest then don't bother wasting both your time and more importantly all potential readers of it.

The "Other" section can be an exception to this as it's more open up to Solr hackers to record more significant changes that won't interest users. Changes significant enough that us Solr hackers (Solr plugin authors & Solr contributors) may want to remember that a notable thing happened in this Solr version, like a significant (not insignificant) refactoring.

And no-changelog doesn't mean a PR isn't appreciated!

What you think of the fix itself, is this a fix or improvement in your opinion?

All I could discern of interest is the support for comments. I'm unsure if this was possible before? Seems too minor to mention IMO.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume you saw this text in the process of producing the changelog? I seek any feedback you may have to improve it in light of what I said above.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I've not seen this text. I added a change log since I have be told to add one on previous PRs, which were also minor.
But good to know, I think the important point is the one about the audience, I was not aware the audience are not the committers, thanks for pointing it out.

@epugh
Copy link
Copy Markdown
Contributor

epugh commented May 8, 2026

I looked at the unit tests, and yes, if you revert the change, the unit test fails..... I am a bit surprised that this bug hasn't been seen before? Can you share a bit on how you stumbled across this? Is this something that can actually happen in a running Solr, or does it only happen in the way you set it up.

Also, I have seen recently in another project that apparently ObjectMapper's are expensive to create and threadsafe so they SHOULD be reused?

@epugh
Copy link
Copy Markdown
Contributor

epugh commented May 8, 2026

Lastly, I added no-changelog label ;-)

@renatoh
Copy link
Copy Markdown
Contributor Author

renatoh commented May 9, 2026

I looked at the unit tests, and yes, if you revert the change, the unit test fails..... I am a bit surprised that this bug hasn't been seen before? Can you share a bit on how you stumbled across this? Is this something that can actually happen in a running Solr, or does it only happen in the way you set it up.

Also, I have seen recently in another project that apparently ObjectMapper's are expensive to create and threadsafe so they SHOULD be reused?

Yes, they are thread-safe and should be reused, that is also stated in the java-doc:
https://fasterxml.github.io/jackson-databind/javadoc/2.6/com/fasterxml/jackson/databind/ObjectMapper.html

And indeed, the ObjectMapper has not been reused before, I have added a test to ensure it is reused now, and this test is failing with the MessageBodyReaders prior my change.
Are we potentially creating an own ObjectMapper instance for eveyr API-call?

I came across working on this ticket:
https://issues.apache.org/jira/browse/SOLR-18191
I realized changes to org.apache.solr.jersey.SolrJacksonMapper had no effect on how the API-calls where de-serialized, Investigating why, I discovered the SolrJacksonMapper is not used at all for an API-call such as creating a new collection.

@epugh
Copy link
Copy Markdown
Contributor

epugh commented May 9, 2026

Yeah, you may be discovering an issue in us not reusing the ObjectMapper? Do you think you need to dig a bit more and see if there is a larger change that should be made? Or is THIS that fix? Looking at the SolrJacksonMapper.getObjectMapper taht to me says that is where we reuse ObjectMapper instead of creating a new one?

@renatoh
Copy link
Copy Markdown
Contributor Author

renatoh commented May 9, 2026

At the moment I do not understand the scope of the issue since the only endpoint I found invoking org.apache.solr.jersey.MessageBodyReaders.CachingJsonMessageBodyReader#getDelegate is the one to create a collection on /api/collections

All other calls to /api/... do not seem to call it, at least the once I've tried.
I thing the reason why it is not use consistently might be caused by the priorities in:
org.apache.solr.jersey.JerseyApplications

So why wouldn't we want to use CachingJsonMessageBodyReader consistently is the question I do not understand.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants