You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@solr.apache.org by GitBox <gi...@apache.org> on 2021/10/09 17:31:00 UTC
[GitHub] [solr] sayandigital opened a new pull request #338: @sayandigital SOLR-13188 - NullPointerException
sayandigital opened a new pull request #338:
URL: https://github.com/apache/solr/pull/338
https://issues.apache.org/jira/browse/SOLR-13188
<!--
_(If you are a project committer then you may remove some/all of the following template.)_
Before creating a pull request, please file an issue in the ASF Jira system for Solr:
* https://issues.apache.org/jira/projects/SOLR
You will need to create an account in Jira in order to create an issue.
The title of the PR should reference the Jira issue number in the form:
* SOLR-####: <short description of problem or changes>
SOLR must be fully capitalized. A short description helps people scanning pull requests for items they can work on.
Properly referencing the issue in the title ensures that Jira is correctly updated with code review comments and commits. -->
# Description
Please provide a short description of the changes you're making with this pull request.
There is a null pointer exception if the parent query is missing .
# Solution
Please provide a short description of the approach taken to implement your solution.
The parent query adds an additional boolean query .Only if parent is present add boolean query or else match all docs.
# Tests
Please describe the tests you've developed or run to confirm this patch implements the feature or solves the problem.
Test cases run on the entire code.
# Checklist
Please review the following and check all that apply:
- [ check] I have reviewed the guidelines for [How to Contribute](https://wiki.apache.org/solr/HowToContribute) and my code conforms to the standards described there to the best of my ability.
- [ check] I have created a Jira issue and added the issue ID to my pull request title.
- [ ] I have given Solr maintainers [access](https://help.github.com/en/articles/allowing-changes-to-a-pull-request-branch-created-from-a-fork) to contribute to my PR branch. (optional but recommended)
- [ check] I have developed this patch against the `main` branch.
- [ check] I have run `./gradlew check`.
- [ ] I have added tests for my changes.
- [ ] I have added documentation for the [Reference Guide](https://github.com/apache/solr/tree/main/solr/solr-ref-guide)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
[GitHub] [solr] dsmiley commented on pull request #338: @sayandigital SOLR-13182 - NullPointerException
Posted by GitBox <gi...@apache.org>.
dsmiley commented on pull request #338:
URL: https://github.com/apache/solr/pull/338#issuecomment-966370502
Feel free to add another line of test code to test that one.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
[GitHub] [solr] dsmiley commented on a change in pull request #338: @sayandigital SOLR-13182 - NullPointerException
Posted by GitBox <gi...@apache.org>.
dsmiley commented on a change in pull request #338:
URL: https://github.com/apache/solr/pull/338#discussion_r743753769
##########
File path: solr/core/src/java/org/apache/solr/search/join/BlockJoinParentQParser.java
##########
@@ -60,10 +60,15 @@ protected String getFiltersParamName() {
}
protected Query parseParentFilter() throws SyntaxError {
- String filter = localParams.get(getParentFilterLocalParamName());
- QParser parentParser = subQuery(filter, null);
- Query parentQ = parentParser.getQuery();
- return parentQ;
+ try {
Review comment:
Why; what exception gets thrown before your change? If I recall, this whole method would return null and not throw; right? So check that parentQ isn't null and if it is, throw a SyntaxError.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
[GitHub] [solr] sayandigital commented on pull request #338: @sayandigital SOLR-13182 - NullPointerException
Posted by GitBox <gi...@apache.org>.
sayandigital commented on pull request #338:
URL: https://github.com/apache/solr/pull/338#issuecomment-941075860
> @sayandigital I'm going to click the workflow now.
>
> However, two things to ready this for committing:
>
> 1. Can you add a unit test that demonstrates the NPE? That would make it easier for me to verify the fix.
> 2. Can you back out the documentation fix, since I captured that in the other PR!
>
> And, I guess, can you add an entry to the CHANGES.txt crediting how you want it to be fixed.
@epugh I have updated the PR as per the review comments
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
[GitHub] [solr] madrob commented on a change in pull request #338: @sayandigital SOLR-13182 - NullPointerException
Posted by GitBox <gi...@apache.org>.
madrob commented on a change in pull request #338:
URL: https://github.com/apache/solr/pull/338#discussion_r739445201
##########
File path: solr/core/src/java/org/apache/solr/search/join/BlockJoinChildQParser.java
##########
@@ -44,10 +45,8 @@ protected String getParentFilterLocalParamName() {
@Override
protected Query noClausesQuery() throws SyntaxError {
final Query parents = parseParentFilter();
- final BooleanQuery notParents = new BooleanQuery.Builder()
- .add(new MatchAllDocsQuery(), Occur.MUST)
- .add(parents, Occur.MUST_NOT)
- .build();
- return new BitSetProducerQuery(getBitSetProducer(notParents));
+ final BooleanQuery.Builder notParentsBuilder = new BooleanQuery.Builder().add(new MatchAllDocsQuery(), Occur.MUST);
+ final BitSetProducerQuery notParentsQuery=(parents!=null)? new BitSetProducerQuery(getBitSetProducer(notParentsBuilder.add(parents, Occur.MUST_NOT).build())): new BitSetProducerQuery(getBitSetProducer(notParentsBuilder.build()));
+ return notParentsQuery;
Review comment:
This is very hard to read, can you add some whitespace here or possibly switch to using a proper if statement instead of ternary conditional.
##########
File path: solr/core/src/test/org/apache/solr/search/join/BlockJoinChildQueryParserTest.java
##########
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.solr.search.join;
+
+import org.apache.solr.SolrTestCaseJ4;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.io.IOException;
+
+public class BlockJoinChildQueryParserTest extends SolrTestCaseJ4 {
+
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ initCore("solrconfig.xml", "schema.xml");
+ createIndex();
+ }
+
+ public static void createIndex() throws IOException, Exception {
+ assertU(adoc("id", "1", "name", "45", "directed_by_s", "Lennon"));
+ assertU(adoc("id", "2", "name", "42", "directed_by_s", "Block"));
+ assertU(commit());
+ assertQ(req("q", "*:*"), "//*[@numFound='" + 2 + "']");
+ }
+
+ @Test
+ public void testChildrenParserEmpty() {
+ assertQ(
+ req("q", "{!child q={}"), "//*[@numFound='2']");
Review comment:
Could this be in `BJQParserTest` instead of creating a new class for a single assertion?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
[GitHub] [solr] epugh commented on pull request #338: @sayandigital SOLR-13182 - NullPointerException
Posted by GitBox <gi...@apache.org>.
epugh commented on pull request #338:
URL: https://github.com/apache/solr/pull/338#issuecomment-939989951
@sayandigital I'm going to click the workflow now.
However, two things to ready this for committing:
1) Can you add a unit test that demonstrates the NPE? That would make it easier for me to verify the fix.
2) Can you back out the documentation fix, since I captured that in the other PR!
And, I guess, can you add an entry to the CHANGES.txt crediting how you want it to be fixed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
[GitHub] [solr] madrob commented on pull request #338: @sayandigital SOLR-13182 - NullPointerException
Posted by GitBox <gi...@apache.org>.
madrob commented on pull request #338:
URL: https://github.com/apache/solr/pull/338#issuecomment-959367416
I think this looks fine to me, but I'm thinking about whether it makes more sense to return a useful error message in this case rather than silently defaulting to no parent query. @dsmiley you've had a lot of time with block joins, do you have opinion here?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
[GitHub] [solr] dsmiley commented on a change in pull request #338: @sayandigital SOLR-13182 - NullPointerException
Posted by GitBox <gi...@apache.org>.
dsmiley commented on a change in pull request #338:
URL: https://github.com/apache/solr/pull/338#discussion_r743753769
##########
File path: solr/core/src/java/org/apache/solr/search/join/BlockJoinParentQParser.java
##########
@@ -60,10 +60,15 @@ protected String getFiltersParamName() {
}
protected Query parseParentFilter() throws SyntaxError {
- String filter = localParams.get(getParentFilterLocalParamName());
- QParser parentParser = subQuery(filter, null);
- Query parentQ = parentParser.getQuery();
- return parentQ;
+ try {
Review comment:
Why; what exception gets thrown before your change? If I recall, this whole method would return null and not throw; right? So check that parentQ isn't null and if it is, throw a SyntaxError.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
[GitHub] [solr] madrob commented on pull request #338: @sayandigital SOLR-13182 - NullPointerException
Posted by GitBox <gi...@apache.org>.
madrob commented on pull request #338:
URL: https://github.com/apache/solr/pull/338#issuecomment-959367416
I think this looks fine to me, but I'm thinking about whether it makes more sense to return a useful error message in this case rather than silently defaulting to no parent query. @dsmiley you've had a lot of time with block joins, do you have opinion here?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
[GitHub] [solr] sayandigital commented on pull request #338: @sayandigital SOLR-13182 - NullPointerException
Posted by GitBox <gi...@apache.org>.
sayandigital commented on pull request #338:
URL: https://github.com/apache/solr/pull/338#issuecomment-966142399
> I pushed a commit that re-did your tests. The syntax was already wrong/weird (with 'q' instead of "of", and with the extra '{' creating an imbalance. I also wanted to test the parent QParser and to use one of Solr's test utilities to expressly test for a bad request instead of a RuntimeException generally.
>
> You still need to redo the formatting. I think you should also remove the needless newline you put at the beginning and end of the changed method. You might consider starting all-over and force-pushing.
http://localhost:8983/solr/films/select?q={!child%20q={} - This is the query shared in the jira which is invalid
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
[GitHub] [solr] dsmiley commented on a change in pull request #338: @sayandigital SOLR-13182 - NullPointerException
Posted by GitBox <gi...@apache.org>.
dsmiley commented on a change in pull request #338:
URL: https://github.com/apache/solr/pull/338#discussion_r743753769
##########
File path: solr/core/src/java/org/apache/solr/search/join/BlockJoinParentQParser.java
##########
@@ -60,10 +60,15 @@ protected String getFiltersParamName() {
}
protected Query parseParentFilter() throws SyntaxError {
- String filter = localParams.get(getParentFilterLocalParamName());
- QParser parentParser = subQuery(filter, null);
- Query parentQ = parentParser.getQuery();
- return parentQ;
+ try {
Review comment:
Why; what exception gets thrown before your change? If I recall, this whole method would return null and not throw; right? So check that parentQ isn't null and if it is, throw a SyntaxError.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
[GitHub] [solr] madrob commented on pull request #338: @sayandigital SOLR-13182 - NullPointerException
Posted by GitBox <gi...@apache.org>.
madrob commented on pull request #338:
URL: https://github.com/apache/solr/pull/338#issuecomment-959367416
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
[GitHub] [solr] sayandigital commented on pull request #338: @sayandigital SOLR-13182 - NullPointerException
Posted by GitBox <gi...@apache.org>.
sayandigital commented on pull request #338:
URL: https://github.com/apache/solr/pull/338#issuecomment-939780749
@epugh Can you please review this.I am a newbie It shows "First-time contributors need a maintainer to approve running workflows."
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
[GitHub] [solr] dsmiley commented on a change in pull request #338: @sayandigital SOLR-13182 - NullPointerException
Posted by GitBox <gi...@apache.org>.
dsmiley commented on a change in pull request #338:
URL: https://github.com/apache/solr/pull/338#discussion_r745017095
##########
File path: solr/CHANGES.txt
##########
@@ -403,6 +403,8 @@ Bug Fixes
* SOLR-15653: Fix collection creation race that assumes a local clusterstate when the collection has only just been created. (Mark Miller)
+* SOLR-13182: Fix Null Pointer exception for BlockJoinChildQueryParser where parent is null.The fix will apply the parent boolean query only when its not null. (Sayanti Dey)
Review comment:
```suggestion
* SOLR-13182: {!child} and {!parent} shouldn't throw NPE; return syntax error (Sayanti Dey)
```
##########
File path: solr/CHANGES.txt
##########
@@ -403,6 +403,8 @@ Bug Fixes
* SOLR-15653: Fix collection creation race that assumes a local clusterstate when the collection has only just been created. (Mark Miller)
+* SOLR-13182: Fix Null Pointer exception for BlockJoinChildQueryParser where parent is null.The fix will apply the parent boolean query only when its not null. (Sayanti Dey)
Review comment:
Notice how I framed this succinctly in terms users can understand.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org