Re: ConcurrentModificationException - ?

From: Matt Kerr (mat..entralparksoftware.com)
Date: Sun Jun 13 2004 - 20:54:49 EDT

  • Next message: Andrus Adamchik: "Re: ConcurrentModificationException - ?"

    andrus - you are a life saver!

    i had the feeling it was something sneaky like that; i just didn't know
    where to look.

    i would consider this me abusing cayenne. :-/
    i believe this was the offending code snippet:

            public void validateForSave(ValidationResult result) {
                    if (!getIsProcessingOnly()) { // WANNA: find proper home - this a
    nasty side-effect
                            setIsTranscriptionClient(false);
                    }
                    super.validateForSave(result);
            }

    (i sensed this was no-no when i wrote it :-/)
    i commented it out. my world is good once again.

    i suppose the better place to do this ... would be like so?

            public void setIsTranscriptionClient(boolean value) {
                    if (!getIsProcessingOnly()) {
                            value = false;
                    }
                    super.setIsTranscriptionClient(value);
            }

    much praise and thanks!!
    -matt

    On Jun 13, 2004, at 18:03, Andrus Adamchik wrote:

    > Hi Matt,
    >
    > This is a bug. I created a unit test that reproduces it. Condition
    > that triggers the exception is that "validateForSave" in one of your
    > DataObjects indirectly modifies the ObjectStore during the iteration
    > (e.g. by inserting new objects or doing a fetch).
    >
    > I opened a bug report:
    > http://objectstyle.org/jira/secure/ViewIssue.jspa?key=CAY-146
    >
    > This will be fixed in M7, which is just around the corner.
    >
    > Andrus
    >
    >
    > On Jun 13, 2004, at 3:33 PM, Matt Kerr wrote:
    >> i have a code path which "used to work".
    >> and now i'm receiving the vague ConcurrentModificationException
    >> (stack trace below)
    >>
    >> i think i've triple checked those entities in my model,
    >> and have stared at the generate sql.
    >> i emptied the table, so i really confused what the snag is-
    >> i'm only trying to save a handful of objects.
    >>
    >> i see this reference post ...
    >>
    >> http://www.objectstyle.org/cayenne/lists/cayenne-user/2003/11/
    >> 0028.html
    >>
    >> i'm running OSX 10.3.4 w/mysql 4.0.16-standard, and cayenne 1.1M6
    >> is that relevant?
    >>
    >>
    >> any suggestions greatly appreciated.
    >> thanks,
    >> matt
    >>
    >> ~~~
    >> java.util.ConcurrentModificationException
    >> Stack Trace:
    >> * java.util.HashMap$HashIterator.nextEntry(HashMap.java:782)
    >> * java.util.HashMap$ValueIterator.next(HashMap.java:812)
    >> *
    >> org.objectstyle.cayenne.access.ObjectStore.validateUncommittedObjects(
    >> ObjectStore.java:856)
    >> *
    >> org.objectstyle.cayenne.access.DataContext.commitChanges(DataContext.j
    >> ava:1211)
    >> *
    >> org.objectstyle.cayenne.access.DataContext.commitChanges(DataContext.j
    >> ava:1187)
    >> *
    >> com.sophora.processing.pages.MoreTasksMenu.updateMonthlyActivityAction
    >> (MoreTasksMenu.java:126)
    >> 8<
    >>
    >>
    >
    >
    ~~
    act first to desire your own good opinion



    This archive was generated by hypermail 2.0.0 : Sun Jun 13 2004 - 20:55:44 EDT