You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by danisevsky <da...@gmail.com> on 2021/11/29 20:12:33 UTC

AjaxTimerBehavior - findParent method returned null in onTimer method

Hi,

we found NPE in our production log and I am not able to explain how this
could happen. Simplified code looks like this:

    private class UserNameStep extends WizardStep {

        @Override
        protected void onInitialize() {
            super.onInitialize();
            add(new AbstractAjaxTimerBehavior(Duration.seconds(3)) {

                @Override
                protected void onTimer(AjaxRequestTarget target) {
                    NewUserWizard wizard = findParent(NewUserWizard.class);
                    wizard.getWizardModel().next();
                    target.add(wizard);
                }
            });
        }

NPE was caused by "findParent(NewUserWizard.class);" returned null. The
only explanation which I can imagine is some race condition - some another
thread would replace this step to another but as I know access to page is
synchronized. Furthermore if this step wouldn't part of current page the
"onTimer" method would not invoked. Could you please imagine any scenario
for not finding parent component in "onTimer" method?

Thanks a lot!
D.