RuntimeException - Could not convertVariable 'scrollTop' in Zoomed Chrome w

I am using Vaadin 6.8.15, and Chrome Version 39.0.2171.71 m.

Any help that you can provide me on this issue is greatly appreciated.

When viewing a page in chrome, and the zoom is set to something like 110%, the browser sends variable update for an integer variable, but specifies a float value.

The following is an excerpt of what Chrome posts to the server. For simplicity, I’ve replaced the unicode characters with something a little more readable:


- Group Separator ‘/u001D’
- Record Separator ‘/u001E’
- Unit Separator ‘/u001F’


23b29faa-7b17-4285-b1ca-c0399cb1a956

611PID127positionxi

222PID127positionyi



11.8182PID127scrollTopi



0PID127scrollLefti

truePID135stateb

1,1078,372,false,false,false,false,1,14,8PID135mousedetailss

I’ve highlighted / bolded the variable update that is causing the issue.

Here’s the stack trace:


Trace: java.lang.RuntimeException: Could not convert variable “scrollTop” for com.vaadin.ui.Window (PID3394)
at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.decodeVariable(AbstractCommunicationManager.java:1578)
at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.handleVariableBurst(AbstractCommunicationManager.java:1384)
at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.handleVariables(AbstractCommunicationManager.java:1329)
at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.doHandleUidlRequest(AbstractCommunicationManager.java:761)
at com.vaadin.terminal.gwt.server.CommunicationManager.handleUidlRequest(CommunicationManager.java:325)
at com.vaadin.terminal.gwt.server.AbstractApplicationServlet.service(AbstractApplicationServlet.java:501)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

Thank you! Any help or advice is greatly appreciated!

Bump

[code]
public class CorrectInvalidIntegerValues extends HttpServletRequestWrapper
{
public static final String RECORD_SEPARATOR = “\u001e”;
public static final String UNIT_SEPARATOR = “\u001f”;

private final String        body;

public static String truncateFloatingPointValuesInIntegerFields(String string)
{
    return string.replaceAll(//
            "(" + UNIT_SEPARATOR + "i" + RECORD_SEPARATOR + "[0-9]

*)\.[0-9]
*(" + UNIT_SEPARATOR + “)”, //
“$1$2” //
);
}

public CorrectInvalidIntegerValues(HttpServletRequest request) throws IOException
{
    super(request);
    final InputStreamReader inr = new InputStreamReader(request.getInputStream(), request.getCharacterEncoding());
    body = truncateFloatingPointValuesInIntegerFields(CharStreams.toString(inr));
}

@Override
public ServletInputStream getInputStream() throws IOException
{
    final ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(body.getBytes(getCharacterEncoding()));
    ServletInputStream servletInputStream = new ServletInputStream()
    {
        public int read() throws IOException
        {
            return byteArrayInputStream.read();
        }
    };
    return servletInputStream;
}

@Override
public BufferedReader getReader() throws IOException
{
    return new BufferedReader(new InputStreamReader(this.getInputStream()));
}

public String getBody()
{
    return this.body;
}

}
[/code]…is my workaround for this issue.

To use it I extend ApplicationServlet and override service() to patch UIDL requests:

    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
    {
        if (getRequestType(request) == RequestType.UIDL)
        {
            request = new CorrectInvalidIntegerValues(request);
        }
        super.service(request, response);
     }

Cool! I wondered if I would have to do something like that. Thanks! I’m glad I’m not the only one who is facing this issue.

No problems!

If you find out how to make Vaadin send integers from the frontend instead, please add a comment here!

No small feat, that. While I’ve created a Vaadin Widget using GWT before, I don’t quite understand how the UIDL is manufactured. I’m not even sure if that’s a GWT item, or a Vaadin specific thing. Do you happen to know?

Looking at the stack trace it looks like something Vaadin does on top of GWT, e.g. com.vaadin.terminal.gwt.server.AbstractCommunicationManager.doHandleUidlRequest()

I didn’t get it to work so I modified the regex:

public static final String GROUP_SEPARATOR = "\u001d";
public static final String RECORD_SEPARATOR = "\u001e";
public static final String UNIT_SEPARATOR = "\u001f";

public static String truncateFloatingPointValuesInIntegerFields(String string)
{
    String regex = "([" + GROUP_SEPARATOR + RECORD_SEPARATOR + "]
[0-9]
*)\\.[0-9]
*(" + UNIT_SEPARATOR + "\\w+" + UNIT_SEPARATOR + "\\w+" + UNIT_SEPARATOR + "i)";
    return string.replaceAll(
        regex,
        "$1$2"
    );
}

At least that was the case with our Vaadin 6.8.3.

Thanks a lot Dan, that looks more correct! I wrongly assumed that the data type (i) preceeded the value in the record.

Hello
I have the same problem. Where i must put this code?

See
my answer above
, but use Dan’s implementation of truncateFloatingPointValuesInIntegerFields.

Ok, but where i must put this implementation in my code?

This was fixed in vaadin version 6.8.18
https://vaadin.com/download/release/6.8/6.8.18/release-notes.html

Wow! :slight_smile:

The workaround have served us well so far, but now I’ve started getting “null” instead of some integers…

ava.lang.RuntimeException: Could not convert variable “c” for se.softhouse.garden.orchid.vaadin.OrchidInputField (PID125)

at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.decodeVariable(AbstractCommunicationManager.java:1578)
at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.handleVariableBurst(AbstractCommunicationManager.java:1384)
at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.handleVariables(AbstractCommunicationManager.java:1329)
at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.doHandleUidlRequest(AbstractCommunicationManager.java:761)
at com.vaadin.terminal.gwt.server.CommunicationManager.handleUidlRequest(CommunicationManager.java:325)
at com.vaadin.terminal.gwt.server.AbstractApplicationServlet.service(AbstractApplicationServlet.java:501)
...

Caused by: java.lang.NumberFormatException: For input string: “null”

at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:580)
at java.lang.Integer.valueOf(Integer.java:766)
at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.convertVariableValue(AbstractCommunicationManager.java:1601)
at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.decodeVariable(AbstractCommunicationManager.java:1571)
... 40 more

The culprit UIDL looks something like this, with Java escaping:

UIDL:5d9f215c-dd89-497a-9096-cac665dd8cc3\u001Dnull\u001FPID97\u001Fc\u001Fi\u001EXXX@gmail.com\u001FPID97\u001FcurText\u001Fs