logo       

Re: NullPointerException in EventLog in Flux when replace='instance'; propo: msg#00027

Subject: Re: NullPointerException in EventLog in Flux when replace='instance'; proposed fix
Leigh,

many thanks for the report and the detailed analysis. Uli + me will review the problem and apply a patch soon. But before we use yours we'll still have to check if that event is dispatched correctly in that situation and if yes whether is makes much sense to pass it to the client.

Thanks,

Joern

Klotz, Leigh wrote:
This is with chiba-core 1.2.0 and chiba-web CVS T-2-3-2006.

Symptom:
An <xf:submission replace="instance" /> which results in nodes being
deleted from an existing instance causes a NullPointerException.

Analysis:
When submission/@replace='instance' happens and nodes disappear, during
the following refresh a chiba-state-changed Chiba event gets dispatched
and when FluxAdapter handles the event, it decides do nothing but log
it.  Unfortunately, the context data includes a pair whose value is a
Java null, causing a NullPointerException in toString() in
org.chiba.adapter.flux.EventLog.add.  The result is a
"java.lang.NullPointerException" Javascript alert in the browser window,
and the stack backtrace below.

Proposed fix:
If the chiba-state-changed event's is supposed to include the pair
{"value", NULL} in its context, then EventLog.add(event) needs to avoid
calling .toString on null values, and EventLog.addProperty(element,
name, value) needs to understand that value=null means not to add a text
child, or addProperty needs to be made generic over (element, name) with
no value arg.


Diff of a proposed fix (null test in both EventLog.add and
EventLog.addProperty):
I also moved the String name and Object value inside the while() in
EventLog.add(event)
--- EventLog.java       2006-02-10 11:02:20.000000000 -0800
+++ EventLog.java.orig  2006-02-10 11:02:06.000000000 -0800
@@ -166,10 +166,10 @@
// add event params
         Iterator iterator = event.getPropertyNames().iterator();
-        String name;
         while (iterator.hasNext()) {
-            name = (String) iterator.next();
-            addProperty(element, name,
event.getContextInfo(name).toString());
+            String name = (String) iterator.next();
+            Object value = event.getContextInfo(name);
+            addProperty(element, name, value == null ? null :
value.toString());
         }
     }
@@ -180,7 +180,9 @@
     public Element addProperty(Element element, String name, String
value) {
         Element property = this.doc.createElement("property");
         property.setAttribute("name", name);
-        property.appendChild(this.doc.createTextNode(value));
+        if (value != null) {
+            property.appendChild(this.doc.createTextNode(value));
+        }
         element.appendChild(property);
return element;

Stack Backtrace:
10 Feb 2006 09:21:35 - [Thread[Thread-19,5,main]] - Caused by:
org.chiba.xml.xforms.exception.XFormsException:
java.lang.NullPointerException
10 Feb 2006 09:21:35 - [Thread[Thread-19,5,main]] -     at
org.chiba.xml.xforms.Container.dispatch(Unknown Source)
10 Feb 2006 09:21:35 - [Thread[Thread-19,5,main]] -     at
org.chiba.xml.xforms.Container.dispatch(Unknown Source)
10 Feb 2006 09:21:35 - [Thread[Thread-19,5,main]] -     at
org.chiba.xml.xforms.ui.state.UIElementStateUtil.dispatchChibaEvents(Unk
nown Source)
10 Feb 2006 09:21:35 - [Thread[Thread-19,5,main]] -     at
org.chiba.xml.xforms.ui.state.BoundElementState.update(Unknown Source)
10 Feb 2006 09:21:35 - [Thread[Thread-19,5,main]] -     at
org.chiba.xml.xforms.ui.BoundElement.updateElementState(Unknown Source)
10 Feb 2006 09:21:35 - [Thread[Thread-19,5,main]] -     at
org.chiba.xml.xforms.ui.BoundElement.update(Unknown Source)
10 Feb 2006 09:21:35 - [Thread[Thread-19,5,main]] -     at
org.chiba.xml.xforms.Initializer.updateUIElements(Unknown Source)
10 Feb 2006 09:21:35 - [Thread[Thread-19,5,main]] -     at
org.chiba.xml.xforms.ui.AbstractUIElement.updateChildren(Unknown Source)
10 Feb 2006 09:21:35 - [Thread[Thread-19,5,main]] -     at
org.chiba.xml.xforms.ui.BoundElement.update(Unknown Source)
10 Feb 2006 09:21:35 - [Thread[Thread-19,5,main]] -     at
org.chiba.xml.xforms.Initializer.updateUIElements(Unknown Source)
10 Feb 2006 09:21:35 - [Thread[Thread-19,5,main]] -     at
org.chiba.xml.xforms.Initializer.updateUIElements(Unknown Source)
10 Feb 2006 09:21:35 - [Thread[Thread-19,5,main]] -     at
org.chiba.xml.xforms.Model.refresh(Unknown Source)
10 Feb 2006 09:21:35 - [Thread[Thread-19,5,main]] -     at
org.chiba.xml.xforms.Submission.submitReplaceInstance(Unknown Source)
10 Feb 2006 09:21:35 - [Thread[Thread-19,5,main]] -     at
org.chiba.xml.xforms.Submission.submit(Unknown Source)
10 Feb 2006 09:21:35 - [Thread[Thread-19,5,main]] -     at
org.chiba.xml.xforms.Submission.performDefault(Unknown Source)
10 Feb 2006 09:21:35 - [Thread[Thread-19,5,main]] -     at
org.chiba.xml.xforms.XFormsDocument.performDefault(Unknown Source)
10 Feb 2006 09:21:35 - [Thread[Thread-19,5,main]] -     at
org.chiba.xml.xforms.XFormsDocument.dispatchEvent(Unknown Source)
10 Feb 2006 09:21:35 - [Thread[Thread-19,5,main]] -     at
org.apache.xerces.dom.NodeImpl.dispatchEvent(Unknown Source)
10 Feb 2006 09:21:35 - [Thread[Thread-19,5,main]] -     at
org.chiba.xml.xforms.Container.dispatch(Unknown Source)
10 Feb 2006 09:21:35 - [Thread[Thread-19,5,main]] -     at
org.chiba.xml.xforms.Container.dispatch(Unknown Source)
10 Feb 2006 09:21:35 - [Thread[Thread-19,5,main]] -     at
org.chiba.xml.xforms.Container.dispatch(Unknown Source)
10 Feb 2006 09:21:35 - [Thread[Thread-19,5,main]] -     at
org.chiba.xml.xforms.ui.Submit.handleEvent(Unknown Source)
10 Feb 2006 09:21:35 - [Thread[Thread-19,5,main]] -     at
org.apache.xerces.dom.DocumentImpl.dispatchEvent(Unknown Source)
10 Feb 2006 09:21:35 - [Thread[Thread-19,5,main]] -     at
org.chiba.xml.xforms.XFormsDocument.dispatchEvent(Unknown Source)
10 Feb 2006 09:21:35 - [Thread[Thread-19,5,main]] -     at
org.apache.xerces.dom.NodeImpl.dispatchEvent(Unknown Source)
10 Feb 2006 09:21:35 - [Thread[Thread-19,5,main]] -     at
org.chiba.xml.xforms.Container.dispatch(Unknown Source)
10 Feb 2006 09:21:35 - [Thread[Thread-19,5,main]] -     at
org.chiba.xml.xforms.Container.dispatch(Unknown Source)
10 Feb 2006 09:21:35 - [Thread[Thread-19,5,main]] -     at
org.chiba.xml.xforms.Container.dispatch(Unknown Source)
10 Feb 2006 09:21:35 - [Thread[Thread-19,5,main]] -     at
org.chiba.xml.xforms.Container.dispatch(Unknown Source)
10 Feb 2006 09:21:35 - [Thread[Thread-19,5,main]] -     at
org.chiba.xml.xforms.ChibaBean.dispatch(Unknown Source)
10 Feb 2006 09:21:35 - [Thread[Thread-19,5,main]] -     at
org.chiba.adapter.flux.FluxAdapter.dispatch(FluxAdapter.java:212)
10 Feb 2006 09:21:35 - [Thread[Thread-19,5,main]] -     at
org.chiba.adapter.flux.FluxFacade.dispatch(FluxFacade.java:222)
10 Feb 2006 09:21:35 - [Thread[Thread-19,5,main]] -     ... 37 more
10 Feb 2006 09:21:35 - [Thread[Thread-19,5,main]] - Caused by:
java.lang.NullPointerException
10 Feb 2006 09:21:35 - [Thread[Thread-19,5,main]] -     at
org.chiba.adapter.flux.EventLog.add(EventLog.java:172)
10 Feb 2006 09:21:35 - [Thread[Thread-19,5,main]] -     at
org.chiba.adapter.flux.FluxAdapter.handleEvent(FluxAdapter.java:265)
10 Feb 2006 09:21:35 - [Thread[Thread-19,5,main]] -     at
org.apache.xerces.dom.DocumentImpl.dispatchEvent(Unknown Source)
10 Feb 2006 09:21:35 - [Thread[Thread-19,5,main]] -     at
org.chiba.xml.xforms.XFormsDocument.dispatchEvent(Unknown Source)
10 Feb 2006 09:21:35 - [Thread[Thread-19,5,main]] -     at
org.apache.xerces.dom.NodeImpl.dispatchEvent(Unknown Source)
10 Feb 2006 09:21:35 - [Thread[Thread-19,5,main]] -     ... 69 more


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=k&kid3432&bid#0486&dat1642
_______________________________________________
Chiba-developer mailing list
Chiba-developer-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@xxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/chiba-developer




-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
audio.irate.dev...    yellowdog.gener...    ietf.ips/2002-0...    xfree86.fonts/2...    busybox/2003-07...    emacs.jdee/2004...    linux.mandrake....    hardware.microc...    user-groups.lin...    science.analysi...    version-control...    db.filemaker.de...    cluster.openmos...    mail.eyebrowse....    text.xml.xerces...    kde.devel.kwrit...    finance.moneyda...    gcc.regression/...    network.routing...    os.freebsd.deve...    recreation.radi...    qnx.openqnx.dev...    python.xml/2002...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe