You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by jo...@apache.org on 2007/01/03 21:57:27 UTC

svn commit: r492298 - in /cocoon/trunk/blocks/cocoon-poi/cocoon-poi-impl: src/main/java/org/apache/cocoon/components/elementprocessor/NoOpElementProcessor.java src/main/java/org/apache/cocoon/serialization/ElementProcessorSerializer.java status.xml

Author: joerg
Date: Wed Jan  3 12:57:27 2007
New Revision: 492298

URL: http://svn.apache.org/viewvc?view=rev&rev=492298
Log:
COCOON-1976: Prevent NPE in ElementProcessorSerializer on characters before first startElement.

Added:
    cocoon/trunk/blocks/cocoon-poi/cocoon-poi-impl/src/main/java/org/apache/cocoon/components/elementprocessor/NoOpElementProcessor.java   (with props)
Modified:
    cocoon/trunk/blocks/cocoon-poi/cocoon-poi-impl/src/main/java/org/apache/cocoon/serialization/ElementProcessorSerializer.java
    cocoon/trunk/blocks/cocoon-poi/cocoon-poi-impl/status.xml

Added: cocoon/trunk/blocks/cocoon-poi/cocoon-poi-impl/src/main/java/org/apache/cocoon/components/elementprocessor/NoOpElementProcessor.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-poi/cocoon-poi-impl/src/main/java/org/apache/cocoon/components/elementprocessor/NoOpElementProcessor.java?view=auto&rev=492298
==============================================================================
--- cocoon/trunk/blocks/cocoon-poi/cocoon-poi-impl/src/main/java/org/apache/cocoon/components/elementprocessor/NoOpElementProcessor.java (added)
+++ cocoon/trunk/blocks/cocoon-poi/cocoon-poi-impl/src/main/java/org/apache/cocoon/components/elementprocessor/NoOpElementProcessor.java Wed Jan  3 12:57:27 2007
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.components.elementprocessor;
+
+import java.io.IOException;
+
+import org.apache.cocoon.components.elementprocessor.types.Attribute;
+
+/**
+ * @version $ID$
+ */
+public class NoOpElementProcessor implements ElementProcessor {
+
+    public void initialize(Attribute[] attributes, ElementProcessor parent) throws IOException { }
+
+    public void acceptCharacters(char[] data) { }
+
+    public void acceptWhitespaceCharacters(char[] data) { }
+
+    public void endProcessing() throws IOException { }
+
+}

Propchange: cocoon/trunk/blocks/cocoon-poi/cocoon-poi-impl/src/main/java/org/apache/cocoon/components/elementprocessor/NoOpElementProcessor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: cocoon/trunk/blocks/cocoon-poi/cocoon-poi-impl/src/main/java/org/apache/cocoon/serialization/ElementProcessorSerializer.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-poi/cocoon-poi-impl/src/main/java/org/apache/cocoon/serialization/ElementProcessorSerializer.java?view=diff&rev=492298&r1=492297&r2=492298
==============================================================================
--- cocoon/trunk/blocks/cocoon-poi/cocoon-poi-impl/src/main/java/org/apache/cocoon/serialization/ElementProcessorSerializer.java (original)
+++ cocoon/trunk/blocks/cocoon-poi/cocoon-poi-impl/src/main/java/org/apache/cocoon/serialization/ElementProcessorSerializer.java Wed Jan  3 12:57:27 2007
@@ -27,6 +27,7 @@
 import org.apache.cocoon.components.elementprocessor.CannotCreateElementProcessorException;
 import org.apache.cocoon.components.elementprocessor.ElementProcessor;
 import org.apache.cocoon.components.elementprocessor.ElementProcessorFactory;
+import org.apache.cocoon.components.elementprocessor.NoOpElementProcessor;
 import org.apache.cocoon.components.elementprocessor.types.Attribute;
 
 import org.xml.sax.Attributes;
@@ -51,16 +52,20 @@
 public abstract class ElementProcessorSerializer
     extends AbstractLogEnabled implements Serializer, Serviceable {
 
-    private OutputStream outputStream;
-    private Stack openElements;
-    private Locator locator;
+    private final Stack openElements;
+    private final ElementProcessor noOpElementProcessor;
+    
     protected ServiceManager manager;
 
+    private OutputStream outputStream;
+    private Locator locator;
+    
     /**
      * Constructor
      */
     public ElementProcessorSerializer() {
         this.openElements = new Stack();
+        this.noOpElementProcessor = new NoOpElementProcessor();
     }
 
     public void service(ServiceManager manager) {
@@ -135,7 +140,7 @@
     }
 
     private ElementProcessor getCurrentElementProcessor() {
-        return this.openElements.empty() ? null
+        return this.openElements.empty() ? this.noOpElementProcessor
                                          : (ElementProcessor)this.openElements.peek();
     }
 

Modified: cocoon/trunk/blocks/cocoon-poi/cocoon-poi-impl/status.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-poi/cocoon-poi-impl/status.xml?view=diff&rev=492298&r1=492297&r2=492298
==============================================================================
--- cocoon/trunk/blocks/cocoon-poi/cocoon-poi-impl/status.xml (original)
+++ cocoon/trunk/blocks/cocoon-poi/cocoon-poi-impl/status.xml Wed Jan  3 12:57:27 2007
@@ -16,7 +16,7 @@
   limitations under the License.
 -->
 <!DOCTYPE status [
-<!ELEMENT status (developers, todo, changes)>
+<!ELEMENT status (developers?, todo?, changes)>
 <!ELEMENT developers (person+)>
 <!ELEMENT person EMPTY>
 <!ATTLIST person
@@ -66,6 +66,9 @@
  <!-- The following list contains the changes since the latest 2.1.x version. -->
  <changes>
   <release version="@version@" date="@date@">
+    <action dev="JH" type="fix" fixes-bug="COCOON-1976" due-to="Rob Berens">
+      Prevent NPE in ElementProcessorSerializer on characters before first startElement.
+    </action>
   </release>
  </changes>