Viritin BrowserCookie NullPointerException when reading a cookie

I have an application that needs @Push and cookies, so I’m using Viritin to handle the cookies.

I am getting a NullPointerException when the cookies are read using BrowserCookie.

I am able to reproduce the problem in the attached test program (86 lines).

It does not matter if @Push is enabled or not – reading a cookie that has been set always causes an NPE.

To reproduce the problem:

  1. Click on the “Read Cookies with Viritin”. The console will show:

readViritin::buttonClick() callback for alpha, value = null callback for bravo, value = null This is correct because the cookies for alpha and bravo have not been set yet.

  1. Enter data into the Alpha and Bravo fields, such as “test1” and “test2”.

  2. Click on the “Save Cookies with Viritin”. The console will show:

saveViritin::buttonClick() 4) Click on the “Read Cookies with Viritin”. The console will show:

[code]
readViritin::buttonClick()
callback for alpha, value = test1
[Two NPE stack traces inserted here]

callback for bravo, value = test2
[/code]The code I’m using the save a cookie is:

BrowserCookie.setCookie(COOKIE_NAME1, alpha_field.getValue());

The code I’m using to read the cookie is:

BrowserCookie.detectCookieValue(COOKIE_NAME1,
    new BrowserCookie.Callback() {
        @Override
        public void onValueDetected(String value) {
            System.out.println("  callback for " + COOKIE_NAME1 + ", value = " + value);
        }
    }
);

What is wrong and what do I do to fix it?

Thanks

Curtis

Edit: using Viritin 1.25, Vaadin 7.3.10.
17949.java (2.64 KB)

Hi,

The issue is fixed in the github. Will be released in 1.26. Thanks for the heads up!

cheers,
matti