Java Client 2.1.1 -> 2.2.0 unexpected compilation errors (not backward compatible)


(Joel Stewart) #1

I am surprised to find incompatible changes in my code.

Is compatibility of minor version increments not to be expected?

I have client code that will make rolling release to 2.2.0 very difficult to coordinate.

Looking forward to the REST API, for sure.

grief.


(David Pilato) #2

What are the changes?


(Joel Stewart) #3

Code that compiles in 2.1.1, that fails to compile in 2.2.0. It used to be that ClusterHealthResponse was Iterable, and ClusterIndexHealth no longer exists.

		ClusterHealthResponse clusterHealthResponse = client.admin().cluster().prepareHealth().get();
		
		for (ClusterIndexHealth indexHealth : clusterHealthResponse) {
			//
		}

Is client.admin() api not covered by the backward compatibility expectation for the java api in minor releases?

Maybe I misunderstood what backward compatible java client was to mean - e.g., the expectation is limited to allowing server and client to be different, but not to code assembled that has been compiled against different versions.

In any case, this change is not documented in the https://www.elastic.co/guide/en/elasticsearch/reference/current/breaking-changes-2.2.html.

The rolling release is actually not going to be a problem. The problem is that maven dependency mediation fails. If a library A is built to use these APIs 2.1.1, then trying to run them in an app that its own or other dependencies for 2.2.0, then running the app will see java.lang.NoSuchMethodError .


(David Pilato) #4

Interesting. This was caused by this change: https://github.com/elastic/elasticsearch/pull/14557

I added a comment to the issue.

Thanks for reporting this!


(Daniel Mitterdorfer) #5

Hi Joel,

I am sorry that this change has caused trouble. I have an open PR that documents the change now.

While ClusterHealthResponse does not implement Iterable anymore, it is still possible to get ClusterIndexHealth (this will also be described in the breaking changes as soon as the PR is merged):

ClusterHealthResponse clusterHealthResponse = client.admin().cluster().prepareHealth().get();
for (Map.Entry<String, ClusterIndexHealth> index : clusterHealthResponse.getIndices().entrySet()) {
    String indexName = index.getKey();
    ClusterIndexHealth health = index.getValue();
}

If you really need the old behavior, it shouldn't be a big deal though. Just open a ticket on Github and we can get it in.

Daniel


(Joel Stewart) #6

Thank you.

It will help the community build neat things and share with each other when the public APIs don't change. I may want to push to github some tooling around elasticsearch 2.1.1, and wouldn't it be great if another in the community could use that, but also not have to wait on me to update my codes if he wishes to continue on to 2.2.0....


(system) #7