romseygeek commented on a change in pull request #1444: URL: https://github.com/apache/lucene-solr/pull/1444#discussion_r413670977
########## File path: lucene/expressions/src/java/org/apache/lucene/expressions/ExpressionValueSource.java ########## @@ -42,13 +42,17 @@ this.expression = Objects.requireNonNull(expression); variables = new DoubleValuesSource[expression.variables.length]; boolean needsScores = false; - for (int i = 0; i < variables.length; i++) { - DoubleValuesSource source = bindings.getDoubleValuesSource(expression.variables[i]); - if (source == null) { - throw new RuntimeException("Internal error. Variable (" + expression.variables[i] + ") does not exist."); + try { + for (int i = 0; i < variables.length; i++) { + DoubleValuesSource source = bindings.getDoubleValuesSource(expression.variables[i]); + if (source == null) { + throw new RuntimeException("Internal error. Variable (" + expression.variables[i] + ") does not exist."); + } + needsScores |= source.needsScores(); + variables[i] = source; } - needsScores |= source.needsScores(); - variables[i] = source; + } catch (StackOverflowError e) { Review comment: I've reworked this so that instead of a `Supplier<DoubleValuesSource>` we store a `Function<Bindings, DoubleValuesSource>`, and supply a special `Bindings` implementation in `validate()` that checks for cycles. Definitely much nicer, thanks for nudging me in the right direction! ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org