-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Description
Recent changes to the bucket aggregation context are backwards incompatible for specific return cases in Painless (#32068). The expected return within this context changed from def (Object) to Double. This causes an issue with casting as it is illegal to cast from one boxed type to another. This means that scripts previously were allowed to do the following where value is a def representing double:
value > 0 ? value : 0
This previous script allowed the auto-return mechanism to cast 0 to Integer and return that since def was the expected return type. Now this will cause a ClassCastException because casting from Integer to Double is not allowed in Painless or Java (included as we follow a casting model very similar to Java's).
My recommended fix is to have this context return Object for now until we can come up with a better solution for deprecation. Note that if this context didn't require null, it would be okay to use double since it's legal to cast from int to double as unboxed types.
This started in version 6.5 and was caught by a Kibana script using a similar example to the one given.