Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Synchronized sequential calls to ParameterHandler and URIHandler?
Well, I am having some troubles getting ParameterHandler and URIHandler work synchronized when they are used to produce dynamic material during a "stress" test.
The attached code below is more or less copied from the "book of vaadin" section 11.5.2 Parameter handlers.
The code is a URIHandler to produce dynamic rendered images according to URI parameters sent in the request string.
I had to synchronize the methods "handleParameters" and "handleURI" that are implementing the methods specified by the ParameterHandler and URIHandler interfaces. Otherwise the images produced were very scattered and noisy.
As it is now the images are "clean" but it seem like the calls to the parameter handler and uri handler are not synchronized and that under stress (many calls to the uri) will produce unexpected results. Apparently the calls to parameter handler and uri handler are not made synchronized in a sequential manner.
This means that several calls to the uri can be handled in any order by the parameter handler before the calls reach the uri handler that try to produce the content on the output stream but only uses the parameters from the last call.
Anyone who has any idea on how to make the calls work synchronized in sequence?
Replace Handlers line
private String text;
private Map<Long,String> texts = new HashMap<Long,String>();
this.text = textParameterValue;
And replace get
final String imageText = this.text;
final String imageText = this.texts.get(Thread.currentThread().getId());
After that each thread accessing hadleURI method get right text variable.
There might be also other way to handle problem...