| I was able to capture the arguments causing the StackOverflowError in the StringHelper#replace method. The call is originating from QueryParameterBindingsImpl#expandListValuedParameters (line 640). It seems to be related to the "in" clause of the query containing many values (in the 1000s). I've noticed that the issue does not occur all of the time. After some debugging, I think it may be related to the iteration order of the entry set of QueryParameterBindingsImpl#parameterListBindingMap in the QueryParameterBindingsImpl#expandListValuedParameters method. For example, suppose there are two entries in the map, representing values of the two "in" clauses of the query. One of those "in" clauses has many values (1000s), while the other only has a few values. It seems that we only get the error when the entry with the many values is iterated first, which causes StringHelper#replace to be called with a very large expansion list. The placeholder in the "in" clause is replaced with these expanded values, which turn out to be more placeholders. Then on the second iteration of the loop, StringHelper#replace is called for the other "in" clause. But now, the afterPlaceholder argument is huge, which seems to cause the overflow. I've decided to modify the underlying query so we don't create an "in" clause with a ton of values. We can get by with doing some filtering on the client side in order to avoid the potential overflow error. So I think we are good, and there's no need to address this just for us. Just for completion, and in case you are curious, here are the values passed to StringHelper#replace, which is called in QueryParameterBindingsImpl#expandListValuedParameters. I'm attaching the afterPlaceholder value as a file since it is such a large string. String beforePlaceholder = "select auditLogEntity\n" + "from AuditLogEntity auditLogEntity\n" + "where auditLogEntity.masterEntityClassName in (" String placeholder = "?1" String replacement = "?1, ?12202" boolean wholeWords = true boolean encloseInParensIfNecessary = true Thank you. |