Last minute bugs

3 Messages Forum Options Options
Permalink
sabob
Last minute bugs
Reply Threaded More
Print post
Permalink
Hi all,

While testing the examples I found a bug with PageImports and stateful
pages.

Since PageImports is mutable we have to nullify between requests for
stateful pages.

However the PageImports is created in the createPage method which is
not in a synchronized block. So I ended up with situations where the
PageImports was sometimes null and threw NPE.

To rectify this, PageImports is now created inside processPage which
is within a synchronized block.

To be on the safe side I've changed the setPageImports to package
private and getPageImports is now final.

kind regards

bob


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Click-development mailing list
Click-development@...
https://lists.sourceforge.net/lists/listinfo/click-development
Malcolm Edgar-2
Re: Last minute bugs
Reply Threaded More
Print post
Permalink
Interesting, I haven't seen this bug in any of the stateful pages we
are using prior to 1.5M2

On Mon, Jul 21, 2008 at 12:18 AM, bob <sabob1@...> wrote:

> Hi all,
>
> While testing the examples I found a bug with PageImports and stateful
> pages.
>
> Since PageImports is mutable we have to nullify between requests for
> stateful pages.
>
> However the PageImports is created in the createPage method which is
> not in a synchronized block. So I ended up with situations where the
> PageImports was sometimes null and threw NPE.
>
> To rectify this, PageImports is now created inside processPage which
> is within a synchronized block.

Sounds good.

> To be on the safe side I've changed the setPageImports to package
> private and getPageImports is now final.

On the Page class however, getPageImports() should not be final so
that pages can override this method, which is called just prior to
rendering, to modify the PageImports. For example in the HomePage
scenario where the page uses a condensed CSS style sheet, and or JS
imports.

Also on the setPageImports, I think this method should be public. I
dont see any benefit to making it package private.

> kind regards
>
> bob
>
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> Click-development mailing list
> Click-development@...
> https://lists.sourceforge.net/lists/listinfo/click-development
>

regards Malcolm Edgar

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Click-development mailing list
Click-development@...
https://lists.sourceforge.net/lists/listinfo/click-development
sabob
Re: Last minute bugs
Reply Threaded More
Print post
Permalink
Malcolm Edgar wrote:
> Interesting, I haven't seen this bug in any of the stateful pages we
> are using prior to 1.5M2

If you refreshed a stateful page really really fast so that some
requests were busy creating (or retrieving) the Page and other
requests were inside the sync block, the NPE can occur. :)

What happened was that request1 nullified the PageImports inside the
sync block, while request2 was waiting for the lock to be released.
Before request1 leaves the sync block it sets the PageImports to null.
Next request2 grabs the lock, but the PageImports is set to null and
NPE ensues.

>
>> To be on the safe side I've changed the setPageImports to package
>> private and getPageImports is now final.
>
> On the Page class however, getPageImports() should not be final so
> that pages can override this method, which is called just prior to
> rendering, to modify the PageImports. For example in the HomePage
> scenario where the page uses a condensed CSS style sheet, and or JS
> imports.

Not sure I follow. getPageImports is called before the resources are
added by the Page and Controls. So overriding it won't enable one to
change the imports as the PageImports is still empty at this stage.

I was thinking of adding a method Page#skipControlImports(boolean),
which when true, will only import from the Page, not Controls. That
way the Page can provide an optimized CSS+JS for the HomePage.

> Also on the setPageImports, I think this method should be public. I
> dont see any benefit to making it package private.

If it is public it means the user can set the PageImports. I am a
little unsure what the use case for that would be. As PageImports is
quite involved, I doubt folk will set PageImports very often if ever.

But its easy to change either way :)

kind regards

bob

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Click-development mailing list
Click-development@...
https://lists.sourceforge.net/lists/listinfo/click-development