GeoHashUtils Library not working as expected

60 views Asked by At
public static void main(String[] args) {
        List<String> geoList = Arrays.asList("t9yu8v", "vtejpg", "t9yu8Y", "vtejpg", "t9yu8Y");
        for(String s : geoList) {
            try {
                GeoHashUtils.bbox(s);
                System.out.println("Success in " + s);
            } catch (Exception ex) {
                System.out.println("Exception in " + s);
            }
        }
    }

org.elasticsearch.common.geo.GeoHashUtils.java is the class present in maven dependency of elastic search version 6.5.0/6.8.23 This code sometimes giving success, sometimes throwing exception for the same geohash

Output - 
Success in t9yu8v
Success in vtejpg
Exception in t9yu8Y
Success in vtejpg
Exception in t9yu8Y

In the first run, vtejpg giving success, but giving exception in subsequent run.

1

There are 1 answers

0
imotov On

Based on your example it works with t9yu8v and vtejpg but fails on t9yu8Y, which makes sense since the last one is not correct geohash from Elasticsearch's perspective.The last character in it is invalid.

That is expected behavior, but the intermittent error with vtejpg that you are describing in your question is not really possible since there is no state in this utility class that would behave differently in sequential runs.