You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lenya.apache.org by Doug Chestnut <dh...@virginia.edu> on 2006/06/20 08:11:28 UTC

[1.4] The document ... is already contained! errors

Hi Devs,
After updating my 1.4 install this week I have noticed "The document ... 
is already contained!" errors when trying to view a page in the 
authoring area of one of my pubs (If I comment out the usecasemenu 
transformer the error goes away).  I get the same error when trying to 
publish as well.

It is really strange as I didn't get the error before the upgrade, and 
it only seems to affect a 3rd level publication (pub has a parent pub 
template and a grandparent template) in tomcat (on my server).  I don't 
get the error from jetty on my laptop.

My error seems to be related to the rather strict add method of the 
DocumentSet class.  Does the add method really need to throw an error if 
a duplicate doc is added, can't it just dedupe silently? (as in the 
patch below)  Or should I look for all occurrences of DocumentSet.add() 
and wrap them in a if(!DocumentSet.contains())?

Thanks,
--Doug

Index: 
C:/src/lenya-1.4.x/src/java/org/apache/lenya/cms/publication/util/DocumentSet.java
===================================================================
--- 
C:/src/lenya-1.4.x/src/java/org/apache/lenya/cms/publication/util/DocumentSet.java 
(revision 415332)
+++ 
C:/src/lenya-1.4.x/src/java/org/apache/lenya/cms/publication/util/DocumentSet.java 
(working copy)
@@ -73,17 +73,15 @@
       * Adds a document to this set.
       *
       * @param document The document to add.
-     * @throws IllegalArgumentException if the document is 
<code>null</code> or already contained.
+     * @throws IllegalArgumentException if the document is 
<code>null</code>.
       */
      public void add(Document document) {
          if (document == null) {
              throw new IllegalArgumentException("The document is null!");
          }
-        if (this.documents.contains(document)) {
-            throw new IllegalArgumentException("The document [" + document
-                    + "] is already contained!");
+        if (!this.documents.contains(document)) {
+            this.documents.add(document);
          }
-        this.documents.add(document);
      }

      /**

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lenya.apache.org
For additional commands, e-mail: dev-help@lenya.apache.org


Re: [1.4] The document ... is already contained! errors

Posted by Andreas Hartmann <an...@apache.org>.
Doug Chestnut wrote:
> Hi Devs,
> After updating my 1.4 install this week I have noticed "The document ... 
> is already contained!" errors when trying to view a page in the 
> authoring area of one of my pubs (If I comment out the usecasemenu 
> transformer the error goes away).  I get the same error when trying to 
> publish as well.

I also got this error in first level publications, but very rarely.
I didn't yet find the cause, but I suspect that it is related to
a lack of thread safety or improper reuse of objects.


> It is really strange as I didn't get the error before the upgrade, and 
> it only seems to affect a 3rd level publication (pub has a parent pub 
> template and a grandparent template) in tomcat (on my server).  I don't 
> get the error from jetty on my laptop.
> 
> My error seems to be related to the rather strict add method of the 
> DocumentSet class.

Actually I don't think so. It might rather be related to concurrent
access, or to a situation where components are not properly released.


> Does the add method really need to throw an error if 
> a duplicate doc is added, can't it just dedupe silently?

I think it should throw an error to point out programming mistakes.
IMO robustness (in the sense of indulgence to errors) at this atomic
level causes more harm than good.

In this case, not throwing an error might actually mask the
underlying cause of the problem, and later on we could be faced
with memory leaks and other serious problems later on ...

Would you mind filing a bug describing your observations?
Thanks a lot!

> (as in the 
> patch below)  Or should I look for all occurrences of DocumentSet.add() 
> and wrap them in a if(!DocumentSet.contains())?

That shouldn't be necessary in most cases.

-- Andreas

-- 
Andreas Hartmann
Wyona Inc.  -   Open Source Content Management   -   Apache Lenya
http://www.wyona.com                      http://lenya.apache.org
andreas.hartmann@wyona.com                     andreas@apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lenya.apache.org
For additional commands, e-mail: dev-help@lenya.apache.org