### CI Link

https://elasticsearch-ci.elastic.co/job/elastic+elasticsearch+pull-request+part-2/7561/

### Repro line

./gradlew ':x-pack:plugin:spatial:test' --tests "org.elasticsearch.xpack.spatial.search.aggregations.bucket.geogrid.GeoTileTilerTests.testGeoGridSetValuesBoundingBoxes_UnboundedGeoShapeCellValues" -Dtests.seed=B78DF2D3C6E9F87B -Dtests.locale=es-PA -Dtests.timezone=Asia/Magadan -Druntime.java=8

### Does it reproduce?

Yes

### Applicable branches

7.17

### Failure history

_No response_

### Failure excerpt

```
  2> REPRODUCE WITH: ./gradlew ':x-pack:plugin:spatial:test' --tests "org.elasticsearch.xpack.spatial.search.aggregations.bucket.geogrid.GeoTileTilerTests.testGeoGridSetValuesBoundingBoxes_UnboundedGeoShapeCellValues" -Dtests.seed=B78DF2D3C6E9F87B -Dtests.locale=es-PA -Dtests.timezone=Asia/Magadan -Druntime.java=8
  2> java.lang.IllegalArgumentException: Unable to Tessellate shape [[0.0, 0.0] [0.0, -3.7434056992857674E-259] [-6.00631214911533E-180, -3.7434056992857674E-259] [-6.00631214911533E-180, 0.0] [0.0, 0.0] ]. Possible malformed shape detected.
        at __randomizedtesting.SeedInfo.seed([B78DF2D3C6E9F87B:C2BBC29EF3DD375D]:0)
        at org.apache.lucene.geo.Tessellator.tessellate(Tessellator.java:116)
        at org.apache.lucene.document.LatLonShape.createIndexableFields(LatLonShape.java:72)
        at org.elasticsearch.index.mapper.GeoShapeIndexer$LuceneGeometryIndexer.visit(GeoShapeIndexer.java:246)
        at org.elasticsearch.index.mapper.GeoShapeIndexer$LuceneGeometryIndexer.visit(GeoShapeIndexer.java:178)
        at org.elasticsearch.geometry.Polygon.visit(Polygon.java:84)
        at org.elasticsearch.index.mapper.GeoShapeIndexer.indexShape(GeoShapeIndexer.java:174)
        at org.elasticsearch.xpack.spatial.util.GeoTestUtils.binaryGeoShapeDocValuesField(GeoTestUtils.java:54)
        at org.elasticsearch.xpack.spatial.util.GeoTestUtils.geoShapeValue(GeoTestUtils.java:60)
        at org.elasticsearch.xpack.spatial.search.aggregations.bucket.geogrid.GeoGridTilerTestCase.testGeoGridSetValuesBoundingBoxes_UnboundedGeoShapeCellValues(GeoGridTilerTestCase.java:161)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at com.carrotsearch.randomizedtesting.RandomizedRunner.invoke(RandomizedRunner.java:1750)
        at com.carrotsearch.randomizedtesting.RandomizedRunner$8.evaluate(RandomizedRunner.java:938)
        at com.carrotsearch.randomizedtesting.RandomizedRunner$9.evaluate(RandomizedRunner.java:974)
        at com.carrotsearch.randomizedtesting.RandomizedRunner$10.evaluate(RandomizedRunner.java:988)
        at com.carrotsearch.randomizedtesting.rules.StatementAdapter.evaluate(StatementAdapter.java:36)
        at org.apache.lucene.util.TestRuleSetupTeardownChained$1.evaluate(TestRuleSetupTeardownChained.java:49)
        at org.apache.lucene.util.AbstractBeforeAfterRule$1.evaluate(AbstractBeforeAfterRule.java:45)
        at org.apache.lucene.util.TestRuleThreadAndTestName$1.evaluate(TestRuleThreadAndTestName.java:48)
        at org.apache.lucene.util.TestRuleIgnoreAfterMaxFailures$1.evaluate(TestRuleIgnoreAfterMaxFailures.java:64)
        at org.apache.lucene.util.TestRuleMarkFailure$1.evaluate(TestRuleMarkFailure.java:47)
        at com.carrotsearch.randomizedtesting.rules.StatementAdapter.evaluate(StatementAdapter.java:36)
        at com.carrotsearch.randomizedtesting.ThreadLeakControl$StatementRunner.run(ThreadLeakControl.java:368)
        at com.carrotsearch.randomizedtesting.ThreadLeakControl.forkTimeoutingTask(ThreadLeakControl.java:817)
        at com.carrotsearch.randomizedtesting.ThreadLeakControl$3.evaluate(ThreadLeakControl.java:468)
        at com.carrotsearch.randomizedtesting.RandomizedRunner.runSingleTest(RandomizedRunner.java:947)
        at com.carrotsearch.randomizedtesting.RandomizedRunner$5.evaluate(RandomizedRunner.java:832)
        at com.carrotsearch.randomizedtesting.RandomizedRunner$6.evaluate(RandomizedRunner.java:883)
        at com.carrotsearch.randomizedtesting.RandomizedRunner$7.evaluate(RandomizedRunner.java:894)
        at org.apache.lucene.util.AbstractBeforeAfterRule$1.evaluate(AbstractBeforeAfterRule.java:45)
        at com.carrotsearch.randomizedtesting.rules.StatementAdapter.evaluate(StatementAdapter.java:36)
        at org.apache.lucene.util.TestRuleStoreClassName$1.evaluate(TestRuleStoreClassName.java:41)
        at com.carrotsearch.randomizedtesting.rules.NoShadowingOrOverridesOnMethodsRule$1.evaluate(NoShadowingOrOverridesOnMethodsRule.java:40)
        at com.carrotsearch.randomizedtesting.rules.NoShadowingOrOverridesOnMethodsRule$1.evaluate(NoShadowingOrOverridesOnMethodsRule.java:40)
        at com.carrotsearch.randomizedtesting.rules.StatementAdapter.evaluate(StatementAdapter.java:36)
        at com.carrotsearch.randomizedtesting.rules.StatementAdapter.evaluate(StatementAdapter.java:36)
        at com.carrotsearch.randomizedtesting.rules.StatementAdapter.evaluate(StatementAdapter.java:36)
        at org.apache.lucene.util.TestRuleAssertionsRequired$1.evaluate(TestRuleAssertionsRequired.java:53)
        at org.apache.lucene.util.TestRuleMarkFailure$1.evaluate(TestRuleMarkFailure.java:47)
        at org.apache.lucene.util.TestRuleIgnoreAfterMaxFailures$1.evaluate(TestRuleIgnoreAfterMaxFailures.java:64)
        at org.apache.lucene.util.TestRuleIgnoreTestSuites$1.evaluate(TestRuleIgnoreTestSuites.java:54)
        at com.carrotsearch.randomizedtesting.rules.StatementAdapter.evaluate(StatementAdapter.java:36)
        at com.carrotsearch.randomizedtesting.ThreadLeakControl$StatementRunner.run(ThreadLeakControl.java:368)
        at java.lang.Thread.run(Thread.java:748)
```
x-pack/plugin/spatial/src/test/java/org/elasticsearch/xpack/spatial/search/aggregations/bucket/geogrid/GeoGridTilerTestCase.java
import org.elasticsearch.xpack.spatial.index.fielddata.GeoShapeValues;
import org.elasticsearch.xpack.spatial.search.aggregations.support.GeoShapeValuesSourceType;
import org.hamcrest.Matchers;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.function.LongConsumer;
import static org.elasticsearch.xpack.spatial.util.GeoTestUtils.geoShapeValue;
import static org.elasticsearch.xpack.spatial.util.GeoTestUtils.randomBBox;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
public abstract class GeoGridTilerTestCase extends ESTestCase {
    protected static final LongConsumer NOOP_BREAKER = (l) -> {};
    protected abstract GeoGridTiler getUnboundedGridTiler(int precision);
    protected abstract GeoGridTiler getBoundedGridTiler(GeoBoundingBox bbox, int precision);
    protected abstract int maxPrecision();
    protected abstract Rectangle getCell(double lon, double lat, int precision);
    protected abstract long getCellsForDiffPrecision(int precisionDiff);
    protected abstract void assertSetValuesBruteAndRecursive(Geometry geometry) throws Exception;
    protected abstract int expectedBuckets(GeoShapeValues.GeoShapeValue value, int precision, GeoBoundingBox bbox) throws Exception;
    public void testMaxCellsBounded() {
        double lon = GeoTestUtil.nextLongitude();
        double lat = GeoTestUtil.nextLatitude();
        for (int i = 0; i < maxPrecision(); i++) {
            Rectangle tile = getCell(lon, lat, i);
            GeoBoundingBox boundingBox = new GeoBoundingBox(
                new GeoPoint(tile.getMaxLat(), tile.getMinLon()),
                new GeoPoint(tile.getMinLat(), tile.getMaxLon())
            );