[Play 2.2.x] [Java] Increase Spring DataBinder autoGrowCollectionLimit?

307 views
Skip to first unread message

Brannon Smith

unread,
Dec 17, 2014, 6:55:20 PM12/17/14
to play-fr...@googlegroups.com
Is there a convenient ( :-) ) way to increase the autoGrowCollectionLimit in the Spring DataBinder underlying Form above the default 256? Something in a config maybe? Or something to call in Global.java? We have clients sending JSON transactions to us that include over 256 array items and this is causing a problem.

-GBS

James Roper

unread,
Dec 18, 2014, 10:54:56 PM12/18/14
to play-framework
It's not configurable, but I think adding the ability to configure it is worthwhile.  There was a PR to make it unlimited, but that wasn't a good solution:


I'm not sure if it should be something that's done in configuration, or if it should be a parameter that's supplied to the data binder.  The problem with putting it in Play's configuration is that the only way to get to the configuration is by using Play.current, which right now we're trying to remove dependence on to eliminate global state in Play.  I'm not sure what the best way to solve this is.

On Thu, Dec 18, 2014 at 10:55 AM, Brannon Smith <gbs...@gmail.com> wrote:
Is there a convenient ( :-) ) way to increase the autoGrowCollectionLimit in the Spring DataBinder underlying Form above the default 256? Something in a config maybe? Or something to call in Global.java? We have clients sending JSON transactions to us that include over 256 array items and this is causing a problem.

-GBS

--
You received this message because you are subscribed to the Google Groups "play-framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to play-framewor...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
James Roper
Software Engineer

Typesafe – Build reactive apps!
Twitter: @jroper

Brannon Smith

unread,
Dec 19, 2014, 11:48:38 AM12/19/14
to play-fr...@googlegroups.com
Hehe, yeah, unlimited sounds a bit extreme! But a hard limit of 256 is extreme in its own way. I can certainly appreciate the move away from globals, but isn't application configuration by definition "global" to some extent? Isn't that part of the conundrum of dealing with config? How do other projects deal with it? Maybe they just suck it up and accept the globalization? :-) Incidentally, I can see the need for this value to come from config but also be overrideable by param on a case by case basis, perhaps from an annotation somewhere. Certain requests may have different limits on how big their collections need to be.

I actually flirted with the idea of attempting to extend play.data.Form (2.2.x version) and override bind(...) to add the additional param, but that quickly became untenable (if it wasn't already) due to how involved the method appears to be. It makes a lot of private method calls. I even tried copying Form.java in toto and adding the single line change we wanted, which was easy and worked, but that is a whole other kind of fugly.

What if the Form took a collection limit as an optional settable param, which it could pass to the databinder? It would not be a config and is something of a stopgap approach, but at least we would have a degree of control we need but don't have.

-GBS 

amertum

unread,
Dec 19, 2014, 1:38:00 PM12/19/14
to play-fr...@googlegroups.com
I think it is better to make it as a param on Form because it will be likely a per Form configuration. If one need it as a global config, it can be set from Play.configuration, not the contrary.
Now, having a form param with more than 255 elements is not very common. Can you post JSON instead ?

Brannon Smith

unread,
Dec 22, 2014, 11:45:55 AM12/22/14
to play-fr...@googlegroups.com
I did mention in the OP that clients are sending us JSON. Form can bind JSON and we are leveraging that to both bind to our POJO and do automatic validation with annotations.
Reply all
Reply to author
Forward
0 new messages