Ivan Saric created SOLR-18603:
---------------------------------

             Summary: Seal the NamedList class hierarchy (SIP-22 step 4)
                 Key: SOLR-18603
                 URL: https://issues.apache.org/jira/browse/SOLR-18603
             Project: Solr
          Issue Type: Improvement
          Components: SolrJ
            Reporter: Ivan Saric


This is step 4 of [SIP-22: NamedList 
Reduction|https://cwiki.apache.org/confluence/spaces/SOLR/pages/340036504/SIP-22+NamedList+Reduction]:

{quote}Minor: Use Java 17 "sealed classes" to insist the NamedList type 
hierarchy is exactly what we want; no surprises.{quote}

Steps 1-3 of the SIP are done (SOLR-17623, SOLR-17635, SOLR-17625). This step 
was agreed as the next one on the dev list: [Follow-up work after 
SOLR-17600|https://lists.apache.org/thread/2o09q8yjmsx4l9b58mqqk5mgdbv7qf36]. 
Per that thread, the SIP's "Solr 10" now means Solr 11 ({{main}}), since 10.0 
has shipped.

h3. Proposal

Declare {{org.apache.solr.common.util.NamedList}} as {{sealed}} with an 
explicit {{permits}} list, so that the set of NamedList subtypes is fixed and 
visible in one place. The expected outcome is that {{NamedList}} permits 
exactly {{SimpleOrderedMap}}; whether {{SimpleOrderedMap}} itself becomes 
{{final}} or stays open is to be decided from the audit below.

Before writing any {{permits}} clause, audit every subclass of {{NamedList}} 
across all Gradle modules, including test sources, {{solr/modules/*}} and 
anonymous subclasses. Any subclass beyond {{SimpleOrderedMap}} is either 
removed or rewritten (if it is internal), or reported here as a finding before 
deciding whether to permit it.

No behaviour changes and no public method signature changes. Those are later 
SIP-22 steps.

h3. Compatibility

{{NamedList}} is public SolrJ API, so sealing it is a plugin-compatibility 
change: a third-party subclass of {{NamedList}} will no longer compile. This is 
a {{main}} / 11.0-only change and will be called out in the changelog as an 
upgrade note. The SIP already anticipates plugin-compatibility impact.

h3. Out of scope

* Migrating {{new NamedList(...)}} instantiations to {{SimpleOrderedMap}} 
(SIP-22 step 5). That will be a separate Jira, per the SIP's "don't combine 
with anything else".
* Changing public API signatures away from {{NamedList}} (SIP-22 step 7).

One PR against {{main}}.




--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to