SOLR-18038: Remove deprecated LocalSolrQueryRequest and use SolrQueryRequestBase#4101
SOLR-18038: Remove deprecated LocalSolrQueryRequest and use SolrQueryRequestBase#4101epugh wants to merge 18 commits intoapache:mainfrom
Conversation
| } else { | ||
| stream = new ContentStreamBase.ByteArrayStream(streamBytes, source, "text/csv"); | ||
| } | ||
| return (new SampleCSVLoader(new CSVRequest(params), maxDocsToLoad)).loadDocs(stream); |
There was a problem hiding this comment.
Here we deleted a trivial class!
| * longer in use. | ||
| */ | ||
| public abstract class SolrQueryRequestBase implements SolrQueryRequest, Closeable { | ||
| public class SolrQueryRequestBase implements SolrQueryRequest, Closeable { |
There was a problem hiding this comment.
Do we eliminate SolrQueryRequest interface?
| protected Map<Object, Object> context; | ||
| protected Iterable<ContentStream> streams; | ||
| protected Map<String, Object> json; | ||
| protected String userPrincipalName = null; |
There was a problem hiding this comment.
I investigated why we had to preserve this here when only one class uses it and:
DocExpirationUpdateProcessorFactory is the ONLY built-in component that:
- Creates background/scheduled requests (not triggered by HTTP)
- Needs authentication (because it makes distributed deletes)
- Must identify itself as a node-initiated operation
Other internal requests either:
- Don't need authentication (single-node operations)
- Are triggered by user requests (already have principal from HTTP)
- Use different mechanisms (like HTTP client with PKI headers for inter-node communication)
This is why setUserPrincipalName() exists but is rarely used - it's a special-purpose API for a rare use case!
I wondered about another home for this, or how do we handle secure internode elsewhere...? Any ideas?
|
|
||
| /** | ||
| * Utility method to build SolrParams from individual query components. This is a convenience | ||
| * method for legacy code that needs to construct params from separate query, qtype, start, limit, |
There was a problem hiding this comment.
how strongly do we want to eliminate this pattern? Actually, on more investigation, it's only used by five classes, though 27 times!
| @Override | ||
| public IndexSchema getSchema() { | ||
| // a request for a core admin will no have a core | ||
| // a request for a core admin will not have a core |
There was a problem hiding this comment.
I am not sure what this comment is telling us..
| * | ||
| * @see PKIAuthenticationPlugin#NODE_IS_USER | ||
| * @see #getUserPrincipal | ||
| * @lucene.internal |
There was a problem hiding this comment.
these tags are copied over from oroginal implementation. Not sure what they mean or why we have them at this point. If there was a better more "supported" way to do this, I'd love to hear about it!
|
|
||
| assertU("<optimize/>"); | ||
|
|
||
| // test query |
There was a problem hiding this comment.
These tests are covered by other unit tests that do the same thing. So removed to pare this massive file back.
There was a problem hiding this comment.
Pull request overview
This PR removes the deprecated LocalSolrQueryRequest by making SolrQueryRequestBase instantiable and migrating production code + tests to use it, including some cleanup of legacy parameter-building patterns.
Changes:
- Make
SolrQueryRequestBaseconcrete and move functionality previously unique toLocalSolrQueryRequestinto it; deleteLocalSolrQueryRequest. - Update many modules/tests to construct requests using
SolrQueryRequestBase, frequently switching fromNamedListtoModifiableSolrParams. - Minor test refactors/cleanups (imports, signatures, small comment tweaks).
Reviewed changes
Copilot reviewed 80 out of 80 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| solr/test-framework/src/java/org/apache/solr/util/TestHarness.java | Adds a helper to build SolrParams for legacy “six-parameter” request construction; updates factory to use SolrQueryRequestBase. |
| solr/test-framework/src/java/org/apache/solr/update/processor/UpdateProcessorTestBase.java | Migrates request creation from LocalSolrQueryRequest to SolrQueryRequestBase. |
| solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java | Uses SolrQueryRequestBase in helpers that previously returned LocalSolrQueryRequest. |
| solr/solrj/src/test/org/apache/solr/client/solrj/routing/ReplicaListTransformerTest.java | Updates test request instantiation; minor method signature cleanup. |
| solr/solrj/src/test/org/apache/solr/client/solrj/request/TestCoreAdmin.java | Removes unnecessary checked exceptions/imports in tests. |
| solr/modules/scripting/src/test/org/apache/solr/scripting/xslt/XSLTUpdateRequestHandlerTest.java | Migrates request creation to SolrQueryRequestBase. |
| solr/modules/scripting/src/java/org/apache/solr/scripting/update/ScriptUpdateProcessorFactory.java | Uses SolrQueryRequestBase for local init validation request. |
| solr/modules/ltr/src/test/org/apache/solr/ltr/TestLTRReRankingPipeline.java | Migrates test request creation to SolrQueryRequestBase. |
| solr/modules/ltr/src/java/org/apache/solr/ltr/feature/SolrFeature.java | Switches request param construction from NamedList to ModifiableSolrParams and SolrQueryRequestBase. |
| solr/modules/extraction/src/test/org/apache/solr/handler/extraction/ExtractingRequestHandlerTestAbstract.java | Adjusts casts/types to SolrQueryRequestBase for request handling in tests. |
| solr/modules/cross-dc/src/test/org/apache/solr/crossdc/handler/MirroringConfigSetsHandlerTest.java | Uses SolrQueryRequestBase for test request creation. |
| solr/modules/cross-dc/src/test/org/apache/solr/crossdc/handler/MirroringCollectionsHandlerTest.java | Uses SolrQueryRequestBase for test request creation. |
| solr/modules/cross-dc/src/java/org/apache/solr/crossdc/handler/MirroringConfigSetsHandler.java | Wraps requests using SolrQueryRequestBase instead of LocalSolrQueryRequest. |
| solr/modules/clustering/src/test/org/apache/solr/handler/clustering/ClusteringComponentTest.java | Migrates requests in tests to SolrQueryRequestBase. |
| solr/modules/clustering/src/java/org/apache/solr/handler/clustering/ClusteringComponent.java | Replaces legacy arg-map request construction with ModifiableSolrParams + SolrQueryRequestBase. |
| solr/core/src/test/org/apache/solr/update/processor/UUIDUpdateProcessorFallbackTest.java | Uses SolrQueryRequestBase in tests. |
| solr/core/src/test/org/apache/solr/update/processor/TolerantUpdateProcessorTest.java | Uses SolrQueryRequestBase in tests. |
| solr/core/src/test/org/apache/solr/update/processor/TemplateUpdateProcessorTest.java | Uses SolrQueryRequestBase in tests. |
| solr/core/src/test/org/apache/solr/update/processor/SkipExistingDocumentsProcessorFactoryTest.java | Moves request params from NamedList to ModifiableSolrParams and uses SolrQueryRequestBase. |
| solr/core/src/test/org/apache/solr/update/processor/SignatureUpdateProcessorFactoryTest.java | Uses SolrQueryRequestBase in tests. |
| solr/core/src/test/org/apache/solr/update/processor/IgnoreCommitOptimizeUpdateProcessorFactoryTest.java | Uses SolrQueryRequestBase in tests. |
| solr/core/src/test/org/apache/solr/update/processor/DistributedUpdateProcessorTest.java | Uses SolrQueryRequestBase in tests. |
| solr/core/src/test/org/apache/solr/update/processor/DefaultValueUpdateProcessorTest.java | Uses SolrQueryRequestBase in tests. |
| solr/core/src/test/org/apache/solr/update/processor/AtomicUpdateProcessorFactoryTest.java | Uses SolrQueryRequestBase in tests. |
| solr/core/src/test/org/apache/solr/update/SolrIndexSplitterTest.java | Updates test request types/creation to SolrQueryRequestBase. |
| solr/core/src/test/org/apache/solr/update/DirectUpdateHandlerTest.java | Uses SolrQueryRequestBase in tests. |
| solr/core/src/test/org/apache/solr/update/AddBlockUpdateTest.java | Uses SolrQueryRequestBase in tests. |
| solr/core/src/test/org/apache/solr/spelling/SpellCheckCollatorTest.java | Uses SolrQueryRequestBase in tests. |
| solr/core/src/test/org/apache/solr/security/TestPKIAuthenticationPlugin.java | Updates test request type; introduces a poorly named variable that shadows the class. |
| solr/core/src/test/org/apache/solr/search/SpatialFilterTest.java | Updates commented-out legacy snippet to SolrQueryRequestBase. |
| solr/core/src/test/org/apache/solr/search/SignificantTermsQParserPluginTest.java | Uses SolrQueryRequestBase in tests. |
| solr/core/src/test/org/apache/solr/schema/IndexSchemaTest.java | Uses SolrQueryRequestBase in tests. |
| solr/core/src/test/org/apache/solr/schema/IndexSchemaRuntimeFieldTest.java | Uses SolrQueryRequestBase in tests. |
| solr/core/src/test/org/apache/solr/schema/CopyFieldTest.java | Uses SolrQueryRequestBase in tests. |
| solr/core/src/test/org/apache/solr/schema/ChangedSchemaMergeTest.java | Uses SolrQueryRequestBase in tests; replaces NamedList request params. |
| solr/core/src/test/org/apache/solr/response/TestPushWriter.java | Uses SolrQueryRequestBase in writer tests. |
| solr/core/src/test/org/apache/solr/response/TestJavaBinResponseWriter.java | Uses SolrQueryRequestBase in tests. |
| solr/core/src/test/org/apache/solr/response/SmileWriterTest.java | Uses SolrQueryRequestBase in tests. |
| solr/core/src/test/org/apache/solr/request/TestSolrRequestInfo.java | Uses SolrQueryRequestBase in tests. |
| solr/core/src/test/org/apache/solr/handler/component/StatsComponentTest.java | Uses SolrQueryRequestBase in tests. |
| solr/core/src/test/org/apache/solr/handler/component/SpellCheckComponentTest.java | Uses SolrQueryRequestBase in tests. |
| solr/core/src/test/org/apache/solr/handler/component/MoreLikeThisComponentTest.java | Uses SolrQueryRequestBase in tests. |
| solr/core/src/test/org/apache/solr/handler/admin/api/V2NodeAPIMappingTest.java | Reworks param capture to use ModifiableSolrParams + SolrQueryRequestBase. |
| solr/core/src/test/org/apache/solr/handler/admin/V2ApiMappingTest.java | Updates request instantiation for mapping tests to SolrQueryRequestBase. |
| solr/core/src/test/org/apache/solr/handler/admin/TestCollectionAPIs.java | Updates request instantiation but drops getHttpMethod() behavior needed by BaseHandlerApiSupport. |
| solr/core/src/test/org/apache/solr/handler/admin/TestApiFramework.java | Uses SolrQueryRequestBase for API-framework tests. |
| solr/core/src/test/org/apache/solr/handler/admin/ShowFileRequestHandlerTest.java | Uses SolrQueryRequestBase in tests. |
| solr/core/src/test/org/apache/solr/handler/admin/SecurityConfHandlerTest.java | Uses SolrQueryRequestBase in tests. |
| solr/core/src/test/org/apache/solr/handler/V2UpdateAPIMappingTest.java | Uses SolrQueryRequestBase for update API mapping tests. |
| solr/core/src/test/org/apache/solr/handler/V2ClusterAPIMappingTest.java | Uses SolrQueryRequestBase for cluster API mapping tests. |
| solr/core/src/test/org/apache/solr/handler/TestCSVLoader.java | Uses SolrQueryRequestBase in tests; minor formatting. |
| solr/core/src/test/org/apache/solr/handler/RequestHandlerBaseTest.java | Uses SolrQueryRequestBase in tests. |
| solr/core/src/test/org/apache/solr/handler/MoreLikeThisHandlerTest.java | Uses SolrQueryRequestBase in tests. |
| solr/core/src/test/org/apache/solr/handler/FieldAnalysisRequestHandlerTest.java | Uses SolrQueryRequestBase in tests. |
| solr/core/src/test/org/apache/solr/core/TestLazyCores.java | Returns SolrQueryRequestBase from helper methods in tests. |
| solr/core/src/test/org/apache/solr/TestCrossCoreJoin.java | Replaces 6-arg request ctor usage with explicit ModifiableSolrParams + SolrQueryRequestBase. |
| solr/core/src/test/org/apache/solr/ConvertedLegacyTest.java | Migrates legacy request construction to TestHarness.makeParams(...) + SolrQueryRequestBase. |
| solr/core/src/test/org/apache/solr/BasicFunctionalityTest.java | Updates request creation to SolrQueryRequestBase; minor comment tweak. |
| solr/core/src/java/org/apache/solr/update/processor/DocExpirationUpdateProcessorFactory.java | Uses SolrQueryRequestBase for internal periodic work; minor comment fixes. |
| solr/core/src/java/org/apache/solr/update/UpdateLog.java | Uses SolrQueryRequestBase for internal update-log operations. |
| solr/core/src/java/org/apache/solr/update/PeerSync.java | Uses SolrQueryRequestBase for internal requests during peer sync. |
| solr/core/src/java/org/apache/solr/update/DirectUpdateHandler2.java | Uses SolrQueryRequestBase for internal request context. |
| solr/core/src/java/org/apache/solr/update/CommitTracker.java | Uses SolrQueryRequestBase for internal commit execution. |
| solr/core/src/java/org/apache/solr/search/join/ScoreJoinQParserPlugin.java | Uses SolrQueryRequestBase for cross-core parsing request. |
| solr/core/src/java/org/apache/solr/search/JoinQParserPlugin.java | Uses SolrQueryRequestBase for cross-core parsing request. |
| solr/core/src/java/org/apache/solr/schema/IndexSchema.java | Uses SolrQueryRequestBase for schema XML writing request context. |
| solr/core/src/java/org/apache/solr/request/SolrQueryRequestBase.java | Made concrete; adds principal-name plumbing; removes deprecated LocalSolrQueryRequest dependency. |
| solr/core/src/java/org/apache/solr/request/SolrQueryRequest.java | Small signature/style cleanup in interface (remove redundant public). |
| solr/core/src/java/org/apache/solr/request/LocalSolrQueryRequest.java | Deleted (deprecated class removal). |
| solr/core/src/java/org/apache/solr/handler/designer/DefaultSampleDocumentsLoader.java | Removes trivial CSVRequest subclass; uses SolrQueryRequestBase directly. |
| solr/core/src/java/org/apache/solr/handler/component/RealTimeGetComponent.java | Uses SolrQueryRequestBase for transformer factory request. |
| solr/core/src/java/org/apache/solr/handler/admin/api/UpgradeCoreIndex.java | Uses SolrQueryRequestBase for internal commit/reindex operations. |
| solr/core/src/java/org/apache/solr/handler/admin/api/MergeIndexes.java | Wraps request with SolrQueryRequestBase when invoking update chain. |
| solr/core/src/java/org/apache/solr/handler/admin/SplitOp.java | Uses SolrQueryRequestBase for split requests. |
| solr/core/src/java/org/apache/solr/handler/IndexFetcher.java | Uses SolrQueryRequestBase for internal commit requests. |
| solr/core/src/java/org/apache/solr/core/CoreContainer.java | Uses SolrQueryRequestBase for internal commit during reload/read-only transitions. |
| solr/core/src/java/org/apache/solr/cloud/ReplicateFromLeader.java | Uses SolrQueryRequestBase for internal commit-and-switch operations. |
| solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java | Uses SolrQueryRequestBase for internal commits during recovery. |
| solr/core/src/java/org/apache/solr/api/Api.java | Minor doc grammar cleanup. |
Comments suppressed due to low confidence (1)
solr/core/src/test/org/apache/solr/security/TestPKIAuthenticationPlugin.java:97
- The variable name
SolrQueryRequestBaseshadows theSolrQueryRequestBasetype and violates usual lowerCamelCase conventions. This is easy to misread and can confuse IDE navigation; rename it to something likelocalReq/testReq/solrRequest.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| import org.apache.solr.schema.IndexSchema; | ||
| import org.apache.solr.search.SolrIndexSearcher; | ||
| import org.apache.solr.security.PKIAuthenticationPlugin; | ||
| import org.apache.solr.util.RTimerTree; |
There was a problem hiding this comment.
PKIAuthenticationPlugin is imported but only referenced in Javadoc. If the build enforces no-unused-imports (common with Checkstyle/Spotless), this will fail. Either remove the import and fully-qualify it in the @see, or reference the class in code.
solr/core/src/java/org/apache/solr/request/SolrQueryRequestBase.java
Outdated
Show resolved
Hide resolved
| @@ -163,16 +163,32 @@ public List<CommandOperation> getCommands(boolean validateInput) { | |||
| public Map<String, String> getPathTemplateValues() { | |||
| return parts; | |||
| } | |||
|
|
|||
| @Override | |||
| public String getHttpMethod() { | |||
| return method.toString(); | |||
| } | |||
| }; | |||
| api.call(req, rsp); | |||
There was a problem hiding this comment.
This test request no longer overrides getHttpMethod() and also doesn't populate req.getContext().put("httpMethod", ...). Since SolrQueryRequest#getHttpMethod()'s default implementation reads and casts the httpMethod context entry, BaseHandlerApiSupport will hit an NPE when it calls req.getHttpMethod(). Set req.getContext().put("httpMethod", method) (where method is the SolrRequest.METHOD enum) or add back a getHttpMethod() override.
| private SolrQueryRequestBase createTestRequest( | ||
| SolrParams params, | ||
| Map<String, String> pathTemplateValues, | ||
| String httpMethod, | ||
| String requestBody, | ||
| Api api) { | ||
| return new SolrQueryRequestBase(null, params) { | ||
| @Override | ||
| public List<CommandOperation> getCommands(boolean validateInput) { | ||
| if (requestBody == null) return Collections.emptyList(); | ||
| return ApiBag.getCommandOperations( | ||
| new ContentStreamBase.StringStream(requestBody), api.getCommandSchema(), true); | ||
| } | ||
|
|
||
| @Override | ||
| public Map<String, String> getPathTemplateValues() { | ||
| return pathTemplateValues; | ||
| } | ||
| }; | ||
| } |
There was a problem hiding this comment.
createTestRequest(...) is unused, and it has an unused parameter (httpMethod). Either remove this helper entirely or refactor makeCall(...) to use it (and ensure it sets the request context/overrides needed for getHttpMethod() as well).
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
https://issues.apache.org/jira/browse/SOLR-18038
Description
Migrate from LocalSolrQueryRequest to SolrQueryRequestBase by making
SolrQueryRequestBaseno longer abstract and including all functionality previously unique toLocalSolrQueryRequestSolution
Beyond the direct conversion, I've also looked for places we used a
NamedListand replaced them withModifiableSolrParams.There is this "six parameter" pattern that remains, primarily in tests, but it's done via
ModifiableSolrParamsmethod.Some anonymous subclasses of
SolrQueryRequestBaseare now explicit.CSVRequestwas trivial and could be removed now thatSolrQueryRequestBaseisn't abstract._BIG QUESTION: SHould we rename
SolrQueryRequestBaseto justSolrQueryRequestand eliminate the interfaceSolrQueryRequest?Tests
I've re-run the tests.