playframework/playframework — pull request #2266 by CedricGatay (2014-01-14 10:17:22+00:00)
Title: Fix for Java Message Arguments handling

There was a bug in the handling of message arguments when used in Java.

I discovered it when using `@Constraints` annotation on my model objects and returning the validation errors as Json. This simple example illustrate the bug :

//in my model object
@Constraints.MinLength(2)
public String myField;

//in my controller (Json version)
return badRequest(form.errorsAsJson()); //"Minimum length is [2]"
//in my controller (form render)
return badRequest(formView.render(form)); //"Minimum length is 2"

By digging into the code I found out that we were passing directly a List to `Messages.get()`, which in turns rewrap it into another `List` to then call the API. The bug is in fact wider than I first thought and the use case I described must not be the only one where we get this kind of error.

The patch is simple, it checks if there is only one argument and if it is a `List`, in this case it returns the `List` as is, otherwise the previous behavior is kept (wrapping with `Arrays.asList`).
Tests were added in MessagesSpec to validate the behavior in Java, and a MessagesTest class was added to check the behavior of the arguments transformation.

CLA has been signed.