Issue Details (XML | Word | Printable)

Key: JDO-186
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Craig Russell
Reporter: Craig Russell
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
JDO

Attach lifecycle listeners are incorrectly implemented

Created: 18/Oct/05 06:01 AM   Updated: 23/Apr/06 03:10 AM
Return to search
Component/s: tck2
Affects Version/s: None
Fix Version/s: JDO 2 beta

Time Tracking:
Not Specified

Environment: JPOX

Resolution Date: 23/Apr/06 03:10 AM


 Description  « Hide
The InstanceLifecycleListenerAttach test case fails with these errors.

    [java] testAttach(org.apache.jdo.tck.api.instancecallbacks.InstanceLifecycleListenerAttach)junit.framework.AssertionFailedError: Assertion A12.15-13 (TestInstanceLifecycleListener) failed:
    [java] Assertion A12.15-14 (TestInstanceLifecycleListener) failed: in postAttach, source object should be persistent.
    [java] Assertion A12.15-14 (TestInstanceLifecycleListener) failed: in postAttach, target expected <org.apache.jdo.tck.api.instancecallbacks.InstanceLifecycleListenerAttach$PC@9ff7c0>, actual <null>
    [java]
    [java] Sequence verification failed for PRE_ATTACH_CALLBACK; expected: <2> actual: <0>
    [java]
    [java] Sequence verification failed for POST_ATTACH_LISTENER; expected: <3> actual: <2>
    [java]
    [java] at org.apache.jdo.tck.api.instancecallbacks.AbstractInstanceLifecycleListener$InstanceLifecycleListenerImpl.verifyCallbacks(AbstractInstanceLifecycleListener.java:464)
    [java] at org.apache.jdo.tck.api.instancecallbacks.InstanceLifecycleListenerAttach.testAttach(InstanceLifecycleListenerAttach.java:111)
    [java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    [java] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    [java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    [java] at org.apache.jdo.tck.JDO_Test.runBare(JDO_Test.java:204)
    [java] at org.apache.jdo.tck.util.BatchTestRunner.start(BatchTestRunner.java:120)
    [java] at org.apache.jdo.tck.util.BatchTestRunner.main(BatchTestRunner.java:95)


 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Craig Russell added a comment - 19/Oct/05 12:54 AM
This appears to be a JPOX bug.

Andy Jefferson added a comment - 22/Oct/05 05:06 PM
Actually was an issue in InstanceCallbacks and not InstanceLifecycleListener. JPOX CVS now uses the objects the other way around on the postAttach and that part of the test passes. The issue about

    [java] Sequence verification failed for PRE_ATTACH_CALLBACK; expected: <2> actual: <0>
    [java]
    [java] Sequence verification failed for POST_ATTACH_LISTENER; expected: <3> actual: <2>

remains. This seems to be down to the TCK test assuming something about ordering. What is the issue here ?

Andy Jefferson added a comment - 23/Oct/05 05:23 AM
JPOX CVS is now updated to match Craigs' proposed spec change

<proposed>
package javax.jdo.listener;
public interface AttachLifecycleListener
     extends InstanceLifecycleListener {
A12.15-13 [void preAttach(InstanceLifecycleEvent event);
}
This method is called before a detached instance is attached. The
source instance is the detached instance. This method is called
before the corresponding jdoPreAttach on the detached instance].
A12.15-14 [void postAttach(InstanceLifecycleEvent event);
}
This method is called after a detached instance is attached. The
source instance is the corresponding persistent instance in the
cache; the target instance is the detached instance. This method is
called after the corresponding jdoPostAttach on the persistent
instance.]
</proposed>

but the test still fails. The issue is that in the test it does

pm.makePersistent(pc);
detachedPc = pm.detachCopy(pc);
pm.attachCopy(detachedPc);

but the "detachedPc" has no "listener" field set (it was set on the "pc", but the detached is created using the default constructor and so has no listener object) and so the callback is received but not registered with the listener object. The test should be changed to be

pm.makePersistent(pc);
detachedPc = pm.detachCopy(pc);
detachedPc.listener = listener;
pm.attachCopy(detachedPc);

and then the test passes.

Craig Russell added a comment - 25/Oct/05 12:08 AM
Andy's analysis is correct. The patch adds the listener to the detached instance and the test now passes.

Checked in version 328080.

Michael Bouschen added a comment - 23/Apr/06 03:08 AM
Reopened to set the Fix Version/s field to JDO 2 beta.