You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wicket.apache.org by Daniel Fernandes Martins <da...@gmail.com> on 2007/10/16 04:13:32 UTC

Little code snippet caused a strange behavior

Hello there!

First of all, I must say that I am trying Wicket for a couple of weeks
and I found it very pleasant to use. It's a great framework indeed!

However, I came here for another reason... I will try to explain what's
going on.

Today, I was working on a custom "menu" component. This custom menu
component extends Panel and it contains some PageLinks. But, after
performing some copy and paste stuff (shame on me :-), I accidentally
caused the application to freeze, by using 95%-100% of CPU time (and no
log messages to tell what's going on).

My "menu" Panel:

public class MyMenuPanel extends Panel {
    public MyMenuPanel(String id) {
        super(id);

        WebMarkupContainer loginItem = new WebMarkupContainer("loginItem");
        loginItem.setVisible(!session.isSignedIn());
        loginItem.add(add(new PageLink("loginPageLink", LoginPage.class)));
        add(loginItem);
    }
}

Let me explain. Before I create this component, all PageLinks of my app
were placed in a custom BasePage component (that extends WebPage, which
is, in turn, extended by all other pages in the app).

After a couple of copy and pastes, I didn't realize that I was adding a
PageLink in two Containers: the WebMarkupContainer and the MyMenuPanel
itself. Here is the bad bad line:

loginItem.add(add(new PageLink("loginPageLink", LoginPage.class)));

Well... after generate the EAR file of my application, I've tried to
deploy and run it in my AppServer. But, when I did the first request
(and that request reached that bad bad line displayed above), the
AppServer started to take out 95%-100% of my CPU time. I thought that it
triggered some sort of recursive calls, but nothing changed after a
minute or two. No log message appeared as well.

Again: in this specific case, it was my fault because I made a mistake
(thanks to the god-damned copy and pastes!). But, at the same time, I
think that the framework could avoid all this ... maybe displaying an
error page or a log message. Not for the mistake itself, but the sudden
high CPU usage can make the system unstable.

My setup:

Wicket (wicket, wicket-spring and wicket-auth-roles) 1.2.6;
Glassfish v2 b58g;
JDK/JRE 1.6.0-b105;
Ubuntu 7.06.

PS: sorry for my English... :-P

Cheers,

-- 
Daniel F. Martins