So I don't have time to provide a good test case, as the shapefile where I'm getting this error is 170 megs. But I have a fix for it, I'm just assigning this to you Andrea as I think you wrote the original code and I want some one to look over it to make sure it's right.
The problem is on the bbox optimization in org.geotools.filter.GeometryFilterImpl. I'm working with multilinestrings, a huge set of them. The bbox checks the dimension to see if there are coordinates to examine, using left.getDimension(). It then looks at the Coordinate arrays of the envelopes of the Geometries. And this is where I get an array out of bounds exception, as it checks cl. I dug into the jts code a bit, and it looks like it's possible that a multilinestring could be constructed with just one point, (or maybe even zero points?). The javadocs for getEnvelope() (which is how the coordinates to compare) say:
'Returns this Geometrys bounding box. If this Geometry is the empty geometry, returns an empty Point. If the Geometry is a point, returns a non-empty Point. Otherwise, returns a Polygon whose points are (minx, miny), (maxx, miny), (maxx, maxy), (minx, maxy), (minx, miny).'
So I believe what happens is that getDimension returns 1, since the geometry type is a multiLineString. But the actual array is only one point, as getEnvelope would just return a point, and the getCoordinates of that would only be of length one.
So I replaced left.getDimension() with cl.length > 1 && cr.length > 1
I'm committing the code, just go ahead and close this if you agree with the changes, or let me know and I can change it or you can change it to a better way, and then close this.