Skip to content

SOLR-17864: Provide backwards support for "<str name="hideStackTrace">${solr.hideStackTrace:false}</str>" - #4893

Open
epugh wants to merge 4 commits into
apache:mainfrom
epugh:SOLR-17864_part_diecinueve
Open

SOLR-17864: Provide backwards support for "<str name="hideStackTrace">${solr.hideStackTrace:false}</str>"#4893
epugh wants to merge 4 commits into
apache:mainfrom
epugh:SOLR-17864_part_diecinueve

Conversation

@epugh

@epugh epugh commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

https://issues.apache.org/jira/browse/SOLR-17864

Description

I thought migrating solr.hideStackTrace to solr.responses.stacktrace.enabled would be easy... it had been partly done. Then I discovered that in solrconfig.xml and solr.xml, the property substitution didn't leverage the deprecation mechanism.

So ${solr.hideStackTrace:false} wouldn't actually pick up a solr.responses.stacktrace.enabled value set on the command line — if you'd upgraded and only set the new property name, this token silently kept using its own inline default instead.

This was potentially a big problem for anyone migrating from an older version to a newer one who uses this feature.

The fix is in EnvUtils, not in the token. I initially assumed the fix meant rewriting the token to reference the new name — ${solr.responses.stacktrace.enabled:true} — but that's actually wrong and introduces a worse bug: plain ${...} substitution can't invert a value, and solr.responses.stacktrace.enabled is inverted relative to hideStackTrace (true=show vs. true=hide). Written that way, the token hides stack traces by default, and setting -Dsolr.responses.stacktrace.enabled=true (wanting them shown) actually hides them — the opposite of what's asked.

The correct fix: leave the token exactly as it was — ${solr.hideStackTrace:false} — and teach EnvUtils to resolve a legacy property name by falling back to its replacement's value (inverting it when the mapping is inverted) whenever the legacy name itself isn't set. That way solr.xml/solrconfig.xml never need to change at all; setting -Dsolr.responses.stacktrace.enabled= on the command line is enough, and it's correctly inverted under the hood.

Solution

Rethink a bit how EnvUtils work... Add a Record for tracking properties and their inverted status. Now wires in so older solr.xml etc can participate in reading the deprecated values.

Tests

add tests, and then did this script:

…StackTrace:false}</str>"

These xml subtitutions don't work like the normal deprecations do.   Need to rethink a bit the logic for making it work in places like solr.xml and solrconfig.xml.
@epugh
epugh requested review from dsmiley and janhoy September 9, 2026 13:18
@github-actions github-actions Bot added documentation Improvements or additions to documentation configs jetty-server client:solrj tests labels Sep 9, 2026
@epugh epugh added this to the 10.x milestone Sep 9, 2026
@github-actions github-actions Bot removed the configs label Sep 9, 2026

@dsmiley dsmiley left a comment

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.

Definitely need this for 10.1.

Comment thread solr/core/src/java/org/apache/solr/servlet/ResponseUtils.java Outdated
* Maps a legacy/deprecated sys prop key (dot-separated form) to the current property it was
* replaced by, and whether the replacement is boolean-inverted relative to the legacy property.
*/
private record DeprecatedMapping(String currentName, boolean inverted) {}

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.

okay/fine but merely for a boolean you could simply have a parallel set of inverted names. That's what I'd do.

Comment thread solr/solrj/src/java/org/apache/solr/common/util/EnvUtils.java
@epugh

epugh commented Sep 9, 2026

Copy link
Copy Markdown
Contributor Author

Okay, having second thoughts on deprecation.... On a fresh bin/solr start -e techproducts, there are 2 deprecation warnings, both from the new fallback mechanism we just added:

o.a.s.D.z.c.timeout  A config file still references the deprecated system property zkClientTimeout; it was replaced by solr.zookeeper.client.timeout. ...
o.a.s.D.host         A config file still references the deprecated system property host; it was replaced by solr.host.advertise. ...

Worth flagging though: these two aren't a user leaving a stale config behind. They fire because the shipped solr.xml/code intentionally keeps historical token names permanently (host, zkClientTimeout — same category as hideStackTrace, which we deliberately decided not to rename in config), and bin/solr itself always sets -Dsolr.host.advertise=... at startup. So EnvUtils's fallback resolves these on every single default Solr startup, for every user, forever — not just for someone with an outdated custom config. That means this warning will show up in every fresh install's log from day one, which might read as alarming/noisy for something that's actually working exactly as designed.

Unless we actually change the defaults that we ship to the new values....?

Comment on lines +56 to +58
if (alreadyLogged.containsKey(featureId)) {
return false;
}

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 first part is needless; surely putIfAbsent will handle this, right?
Is this an optimization? If it is, a comment should clearly say so. But I'm suspicious it's any faster than putIfAbsent; surely that one can bail fast. I looked at the code for it in ConcurrentHashMap and I think it's good.

@dsmiley

dsmiley commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

host, zkClientTimeout — same category as hideStackTrace, which we deliberately decided not to rename in config

Why did we not thoroughly change then; are we not sure we wanted to actually change?

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants