Re: ConcurrentModificationException - ?

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Sun Jun 13 2004 - 22:06:46 EDT

  • Next message: Matt Kerr: "Re: ConcurrentModificationException - ?"

    My pleasure.

    Hmm.. In your case I actually don't see why the problem occurs :-/.
    "getIsProcessingOnly()" and "setIsTranscriptionClient" seem like benign
    property accessors without side effects. Is this so?

    Anyway I guess logically it should be a no-no to change object state
    when commit is in progress (not sure if this is what actually happens
    in your case?). However I still thought that users should be allowed to
    perform select during the validation, as an object may need extra data
    to validate itself. So I opened the bug report and already changed the
    code to run the validation outside the iterator.

    Andrus

    On Jun 13, 2004, at 8:54 PM, Matt Kerr wrote:

    > 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.
    >>> java:1211)
    >>> *
    >>> org.objectstyle.cayenne.access.DataContext.commitChanges(DataContext.
    >>> java:1187)
    >>> *
    >>> com.sophora.processing.pages.MoreTasksMenu.updateMonthlyActivityActio
    >>> n(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 - 22:06:53 EDT