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 2022/10/07 10:22:44 UTC

[GitHub] [solr] acsbendi opened a new pull request, #1054: Fix IndexOutOfBounds in RecursiveNumericEvaluator

acsbendi opened a new pull request, #1054:
URL: https://github.com/apache/solr/pull/1054

   # Description
   
   This change fixes the following exception:
   ```
   2022-10-04 12:21:26.033 ERROR (qtp503938393-25) [...] o.a.s.c.s.i.s.ExceptionStream java.lang.IndexOutOfBoundsException: Index 0 out of bounds for length 0 => java.lang.IndexOutOfBoundsException: Index 0 out of bounds for length 0
           at java.base/jdk.internal.util.Preconditions.outOfBounds(Unknown Source)
   java.lang.IndexOutOfBoundsException: Index 0 out of bounds for length 0
           at jdk.internal.util.Preconditions.outOfBounds(Unknown Source) ~[?:?]
           at jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Unknown Source) ~[?:?]
           at jdk.internal.util.Preconditions.checkIndex(Unknown Source) ~[?:?]
           at java.util.Objects.checkIndex(Unknown Source) ~[?:?]
           at java.util.ArrayList.get(Unknown Source) ~[?:?]
           at [org.apache.solr.client.solrj.io](http://org.apache.solr.client.solrj.io/).eval.RecursiveNumericEvaluator.normalizeInputType(RecursiveNumericEvaluator.java:55) ~[?:?]
           at [org.apache.solr.client.solrj.io](http://org.apache.solr.client.solrj.io/).eval.RecursiveEvaluator.recursivelyEvaluate(RecursiveEvaluator.java:214) ~[?:?]
           at [org.apache.solr.client.solrj.io](http://org.apache.solr.client.solrj.io/).eval.RecursiveEvaluator.evaluate(RecursiveEvaluator.java:202) ~[?:?]
           at [org.apache.solr.client.solrj.io](http://org.apache.solr.client.solrj.io/).stream.LetStream.open(LetStream.java:195) ~[?:?]
           at [org.apache.solr.client.solrj.io](http://org.apache.solr.client.solrj.io/).stream.ExceptionStream.open(ExceptionStream.java:49) ~[?:?]
           at org.apache.solr.handler.StreamHandler$TimerStream.open(StreamHandler.java:486) ~[?:?]
           at [org.apache.solr.client.solrj.io](http://org.apache.solr.client.solrj.io/).stream.TupleStream.writeMap(TupleStream.java:77) ~[?:?]
           at org.apache.solr.common.util.JsonTextWriter.writeMap(JsonTextWriter.java:168) ~[?:?]
           at org.apache.solr.common.util.TextWriter.writeMap(TextWriter.java:241) ~[?:?]
           at org.apache.solr.common.util.TextWriter.writeVal(TextWriter.java:85) ~[?:?]
           at org.apache.solr.response.TextResponseWriter.writeVal(TextResponseWriter.java:205) ~[?:?]
           at org.apache.solr.common.util.TextWriter.writeVal(TextWriter.java:45) ~[?:?]
           at org.apache.solr.common.util.JsonTextWriter.writeNamedListAsMapWithDups(JsonTextWriter.java:387) ~[?:?]
           at org.apache.solr.common.util.JsonTextWriter.writeNamedList(JsonTextWriter.java:295) ~[?:?]
           at org.apache.solr.response.JSONWriter.writeResponse(JSONWriter.java:77) ~[?:?]
           at org.apache.solr.response.JSONResponseWriter.write(JSONResponseWriter.java:63) ~[?:?]
           at org.apache.solr.response.QueryResponseWriterUtil.writeQueryResponse(QueryResponseWriterUtil.java:71) ~[?:?]
           at org.apache.solr.servlet.HttpSolrCall.writeResponse(HttpSolrCall.java:999) ~[?:?]
           at org.apache.solr.servlet.HttpSolrCall.call(HttpSolrCall.java:631) ~[?:?]
           at org.apache.solr.servlet.SolrDispatchFilter.dispatch(SolrDispatchFilter.java:239) ~[?:?]
           at org.apache.solr.servlet.SolrDispatchFilter.lambda$doFilter$0(SolrDispatchFilter.java:207) ~[?:?]
           at org.apache.solr.servlet.ServletUtils.traceHttpRequestExecution2(ServletUtils.java:257) ~[?:?]
           at org.apache.solr.servlet.ServletUtils.rateLimitRequest(ServletUtils.java:227) ~[?:?]
           at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:202) ~[?:?]
   ```
   # Solution
   
   I check if the list if empty before accessing its first item.
   
   # Tests
   
   # Checklist
   
   Please review the following and check all that apply:
   
   - [ ] 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.
   - [ ] 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)
   - [ ] I have developed this patch against the `main` branch.
   - [ ] 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] risdenk commented on pull request #1054: Fix IndexOutOfBounds in RecursiveNumericEvaluator

Posted by GitBox <gi...@apache.org>.
risdenk commented on PR #1054:
URL: https://github.com/apache/solr/pull/1054#issuecomment-1282461290

   `./gradlew tidy` should fix up any formatting stuff that was found.


-- 
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] risdenk commented on pull request #1054: Fix IndexOutOfBounds in RecursiveNumericEvaluator

Posted by GitBox <gi...@apache.org>.
risdenk commented on PR #1054:
URL: https://github.com/apache/solr/pull/1054#issuecomment-1281087268

   @acsbendi https://github.com/apache/solr/blob/main/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/StreamExpressionTest.java potentially or one of the other existing classes under https://github.com/apache/solr/tree/main/solr/solrj/src/test/org/apache/solr/client/solrj/io


-- 
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] acsbendi commented on pull request #1054: Fix IndexOutOfBounds in RecursiveNumericEvaluator

Posted by GitBox <gi...@apache.org>.
acsbendi commented on PR #1054:
URL: https://github.com/apache/solr/pull/1054#issuecomment-1280466389

   @risdenk Sure, where should I add one? Yes, this happened in a streaming expression, should I add a test for that streaming expression?


-- 
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] risdenk commented on pull request #1054: Fix IndexOutOfBounds in RecursiveNumericEvaluator

Posted by GitBox <gi...@apache.org>.
risdenk commented on PR #1054:
URL: https://github.com/apache/solr/pull/1054#issuecomment-1282429954

   Thanks @acsbendi - running `./gradlew check -x test` would surface a few errors.
   * `Assert....` shouldn't be needed. just use `assertEquals`
   * Add license header that matches other tests


-- 
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] risdenk commented on pull request #1054: Fix IndexOutOfBounds in RecursiveNumericEvaluator

Posted by GitBox <gi...@apache.org>.
risdenk commented on PR #1054:
URL: https://github.com/apache/solr/pull/1054#issuecomment-1281089307

   I do see a https://github.com/apache/solr/blob/main/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/RecursiveEvaluatorTest.java, but no `RecursiveNumericEvaluatorTest` so take a look and see where your test case might go.


-- 
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] risdenk commented on pull request #1054: SOLR-16483: Fix IndexOutOfBounds in RecursiveNumericEvaluator

Posted by GitBox <gi...@apache.org>.
risdenk commented on PR #1054:
URL: https://github.com/apache/solr/pull/1054#issuecomment-1285859948

   Thanks @acsbendi 


-- 
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] sonatype-lift[bot] commented on pull request #1054: Fix IndexOutOfBounds in RecursiveNumericEvaluator

Posted by GitBox <gi...@apache.org>.
sonatype-lift[bot] commented on PR #1054:
URL: https://github.com/apache/solr/pull/1054#issuecomment-1271455654

   :warning: **314 God Classes** were detected by Lift in this project. [Visit the Lift web console](https://lift.sonatype.com/results/github.com/apache/solr/01GERZG0A62WX54PQNXGA9SNMP?tab=technical-debt&utm_source=github.com&utm_campaign=lift-comment&utm_content=apache\%20solr) for more details.


-- 
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] acsbendi commented on a diff in pull request #1054: Fix IndexOutOfBounds in RecursiveNumericEvaluator

Posted by GitBox <gi...@apache.org>.
acsbendi commented on code in PR #1054:
URL: https://github.com/apache/solr/pull/1054#discussion_r998272943


##########
solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/MovingAverageEvaluatorTest.java:
##########
@@ -0,0 +1,40 @@
+package org.apache.solr.client.solrj.io.stream.eval;

Review Comment:
   Fixed



##########
solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/MovingAverageEvaluatorTest.java:
##########
@@ -0,0 +1,40 @@
+package org.apache.solr.client.solrj.io.stream.eval;
+
+import junit.framework.Assert;
+import org.apache.solr.SolrTestCase;
+import org.apache.solr.client.solrj.io.Tuple;
+import org.apache.solr.client.solrj.io.eval.MovingAverageEvaluator;
+import org.apache.solr.client.solrj.io.eval.StreamEvaluator;
+import org.apache.solr.client.solrj.io.stream.expr.StreamFactory;
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+public class MovingAverageEvaluatorTest extends SolrTestCase {
+
+    StreamFactory factory;
+    Map<String, Object> values;
+
+    public MovingAverageEvaluatorTest() {
+        super();
+
+        factory =
+                new StreamFactory()
+                        .withFunctionName("movingAvg", MovingAverageEvaluator.class);
+        values = new HashMap<>();
+    }
+
+    @Test
+    public void doesNotFailWithEmptyList() throws Exception {
+        StreamEvaluator evaluator = factory.constructEvaluator("movingAvg(a,30)");
+        Object result;
+
+        values.clear();
+        values.put("a", new ArrayList<Double>());
+        result = evaluator.evaluate(new Tuple(values));
+        Assert.assertEquals(Collections.emptyList(), result);

Review Comment:
   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] acsbendi commented on pull request #1054: SOLR-16483: Fix IndexOutOfBounds in RecursiveNumericEvaluator

Posted by GitBox <gi...@apache.org>.
acsbendi commented on PR #1054:
URL: https://github.com/apache/solr/pull/1054#issuecomment-1286591967

   @risdenk You're welcome, glad to be able to contribute!


-- 
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] risdenk commented on a diff in pull request #1054: Fix IndexOutOfBounds in RecursiveNumericEvaluator

Posted by GitBox <gi...@apache.org>.
risdenk commented on code in PR #1054:
URL: https://github.com/apache/solr/pull/1054#discussion_r998267288


##########
solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/MovingAverageEvaluatorTest.java:
##########
@@ -0,0 +1,40 @@
+package org.apache.solr.client.solrj.io.stream.eval;

Review Comment:
   Missing license header



##########
solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/MovingAverageEvaluatorTest.java:
##########
@@ -0,0 +1,40 @@
+package org.apache.solr.client.solrj.io.stream.eval;
+
+import junit.framework.Assert;
+import org.apache.solr.SolrTestCase;
+import org.apache.solr.client.solrj.io.Tuple;
+import org.apache.solr.client.solrj.io.eval.MovingAverageEvaluator;
+import org.apache.solr.client.solrj.io.eval.StreamEvaluator;
+import org.apache.solr.client.solrj.io.stream.expr.StreamFactory;
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+public class MovingAverageEvaluatorTest extends SolrTestCase {
+
+    StreamFactory factory;
+    Map<String, Object> values;
+
+    public MovingAverageEvaluatorTest() {
+        super();
+
+        factory =
+                new StreamFactory()
+                        .withFunctionName("movingAvg", MovingAverageEvaluator.class);
+        values = new HashMap<>();
+    }
+
+    @Test
+    public void doesNotFailWithEmptyList() throws Exception {
+        StreamEvaluator evaluator = factory.constructEvaluator("movingAvg(a,30)");
+        Object result;
+
+        values.clear();
+        values.put("a", new ArrayList<Double>());
+        result = evaluator.evaluate(new Tuple(values));
+        Assert.assertEquals(Collections.emptyList(), result);

Review Comment:
   Just use `assertEquals` without `Assert.`



-- 
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] acsbendi commented on pull request #1054: Fix IndexOutOfBounds in RecursiveNumericEvaluator

Posted by GitBox <gi...@apache.org>.
acsbendi commented on PR #1054:
URL: https://github.com/apache/solr/pull/1054#issuecomment-1282443824

   My pleasure:) The problems are fixed now


-- 
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] risdenk merged pull request #1054: SOLR-16483: Fix IndexOutOfBounds in RecursiveNumericEvaluator

Posted by GitBox <gi...@apache.org>.
risdenk merged PR #1054:
URL: https://github.com/apache/solr/pull/1054


-- 
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] risdenk commented on pull request #1054: Fix IndexOutOfBounds in RecursiveNumericEvaluator

Posted by GitBox <gi...@apache.org>.
risdenk commented on PR #1054:
URL: https://github.com/apache/solr/pull/1054#issuecomment-1279413345

   @acsbendi can you add a test case for this? looks like its a streaming expression potentially? 


-- 
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] acsbendi commented on pull request #1054: Fix IndexOutOfBounds in RecursiveNumericEvaluator

Posted by GitBox <gi...@apache.org>.
acsbendi commented on PR #1054:
URL: https://github.com/apache/solr/pull/1054#issuecomment-1282002833

   @risdenk I've added a test for it, and checked that it fails without my fix:)


-- 
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