Issue Details (XML | Word | Printable)

Key: OPENJPA-122
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Minor Minor
Assignee: Craig Russell
Reporter: Craig Russell
Votes: 0
Watchers: 0
Operations

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

EntityManager does not throw exceptions after close() in required cases

Created: 01/Feb/07 05:34 AM   Updated: 01/Mar/07 02:13 AM
Return to search
Component/s: jpa
Affects Version/s: None
Fix Version/s: 0.9.7

Time Tracking:
Not Specified

File Attachments:
  Size
Text File Licensed for inclusion in ASF works EntityManagerImpl.patch.txt 2007-02-01 06:17 AM Craig Russell 1 kB
Java Source File Licensed for inclusion in ASF works TestEntityManagerMethodsThrowAfterClose.java 2007-02-01 05:36 AM Craig Russell 7 kB
Issue Links:
Reference
 

Resolution Date: 01/Feb/07 08:06 PM


 Description  « Hide
A new test case TestEntityManagerMethodsThrowAfterClose has 2 failures and 2 errors.

The test case has not been checked in so that the build does not fail. The test case is attached.

1. Wrong exception thrown for flush after close:

testFlushAfterClose(org.apache.openjpa.persistence.simple.TestEntityManagerMethodsThrowAfterClose) Time elapsed: 1.294 sec <<< ERROR!
<4|false|0.9.7-incubating-SNAPSHOT> org.apache.openjpa.persistence.TransactionRequiredException: Can only perform operation while a transaction is active.
        at org.apache.openjpa.kernel.BrokerImpl.assertActiveTransaction(BrokerImpl.java:4252)
        at org.apache.openjpa.kernel.DelegatingBroker.assertActiveTransaction(DelegatingBroker.java:1292)
        at org.apache.openjpa.persistence.EntityManagerImpl.flush(EntityManagerImpl.java:472)
        at org.apache.openjpa.persistence.simple.TestEntityManagerMethodsThrowAfterClose.testFlushAfterClose(TestEntityManagerMethodsThrowAfterClose.java:113)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at junit.framework.TestCase.runTest(TestCase.java:154)
        at junit.framework.TestCase.runBare(TestCase.java:127)
        at junit.framework.TestResult$1.protect(TestResult.java:106)
        at junit.framework.TestResult.runProtected(TestResult.java:124)
        at junit.framework.TestResult.run(TestResult.java:109)
        at junit.framework.TestCase.run(TestCase.java:118)
        at junit.framework.TestSuite.runTest(TestSuite.java:208)
        at junit.framework.TestSuite.run(TestSuite.java:203)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.apache.maven.surefire.junit.JUnitTestSet.execute(JUnitTestSet.java:210)
        at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:135)
        at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:122)
        at org.apache.maven.surefire.Surefire.run(Surefire.java:129)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:225)
        at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:747)

2. No exception thrown for setFlushMode after close:

testSetFlushModeAfterClose(org.apache.openjpa.persistence.simple.TestEntityManagerMethodsThrowAfterClose) Time elapsed: 0.338 sec <<< FAILURE!
junit.framework.AssertionFailedError: Expected exception for method setFlushMode after em.close()
        at junit.framework.Assert.fail(Assert.java:47)
        at org.apache.openjpa.persistence.simple.TestEntityManagerMethodsThrowAfterClose.testSetFlushModeAfterClose(TestEntityManagerMethodsThrowAfterClose.java:123)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at junit.framework.TestCase.runTest(TestCase.java:154)
        at junit.framework.TestCase.runBare(TestCase.java:127)
        at junit.framework.TestResult$1.protect(TestResult.java:106)
        at junit.framework.TestResult.runProtected(TestResult.java:124)
        at junit.framework.TestResult.run(TestResult.java:109)
        at junit.framework.TestCase.run(TestCase.java:118)
        at junit.framework.TestSuite.runTest(TestSuite.java:208)
        at junit.framework.TestSuite.run(TestSuite.java:203)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.apache.maven.surefire.junit.JUnitTestSet.execute(JUnitTestSet.java:210)
        at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:135)
        at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:122)
        at org.apache.maven.surefire.Surefire.run(Surefire.java:129)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:225)
        at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:747)

3. No exception thrown for getFlushMode after close:

testGetFlushModeAfterClose(org.apache.openjpa.persistence.simple.TestEntityManagerMethodsThrowAfterClose) Time elapsed: 0.227 sec <<< FAILURE!
junit.framework.AssertionFailedError: Expected exception for method getFlushMode after em.close()
        at junit.framework.Assert.fail(Assert.java:47)
        at org.apache.openjpa.persistence.simple.TestEntityManagerMethodsThrowAfterClose.testGetFlushModeAfterClose(TestEntityManagerMethodsThrowAfterClose.java:132)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at junit.framework.TestCase.runTest(TestCase.java:154)
        at junit.framework.TestCase.runBare(TestCase.java:127)
        at junit.framework.TestResult$1.protect(TestResult.java:106)
        at junit.framework.TestResult.runProtected(TestResult.java:124)
        at junit.framework.TestResult.run(TestResult.java:109)
        at junit.framework.TestCase.run(TestCase.java:118)
        at junit.framework.TestSuite.runTest(TestSuite.java:208)
        at junit.framework.TestSuite.run(TestSuite.java:203)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.apache.maven.surefire.junit.JUnitTestSet.execute(JUnitTestSet.java:210)
        at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:135)
        at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:122)
        at org.apache.maven.surefire.Surefire.run(Surefire.java:129)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:225)
        at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:747)

4. Wrong exception thrown for createNamedQuery after close:

testCreateNamedQueryAfterClose(org.apache.openjpa.persistence.simple.TestEntityManagerMethodsThrowAfterClose) Time elapsed: 0.26 sec <<< ERROR!
<4|true|0.9.7-incubating-SNAPSHOT> org.apache.openjpa.persistence.ArgumentException: There is no query with the name "NamedQuery" defined for any of the known persistent classes: [org.apache.openjpa.persistence.simple.AllFieldTypes].
        at org.apache.openjpa.meta.MetaDataRepository.getQueryMetaData(MetaDataRepository.java:1494)
        at org.apache.openjpa.persistence.EntityManagerImpl.createNamedQuery(EntityManagerImpl.java:765)
        at org.apache.openjpa.persistence.EntityManagerImpl.createNamedQuery(EntityManagerImpl.java:62)
        at org.apache.openjpa.persistence.simple.TestEntityManagerMethodsThrowAfterClose.testCreateNamedQueryAfterClose(TestEntityManagerMethodsThrowAfterClose.java:185)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at junit.framework.TestCase.runTest(TestCase.java:154)
        at junit.framework.TestCase.runBare(TestCase.java:127)
        at junit.framework.TestResult$1.protect(TestResult.java:106)
        at junit.framework.TestResult.runProtected(TestResult.java:124)
        at junit.framework.TestResult.run(TestResult.java:109)
        at junit.framework.TestCase.run(TestCase.java:118)
        at junit.framework.TestSuite.runTest(TestSuite.java:208)
        at junit.framework.TestSuite.run(TestSuite.java:203)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.apache.maven.surefire.junit.JUnitTestSet.execute(JUnitTestSet.java:210)
        at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:135)
        at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:122)
        at org.apache.maven.surefire.Surefire.run(Surefire.java:129)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:225)
        at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:747)



 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Craig Russell added a comment - 01/Feb/07 05:36 AM
This test cannot be checked in until the bugs are fixed, or the build will break.

Craig Russell made changes - 01/Feb/07 05:36 AM
Field Original Value New Value
Attachment TestEntityManagerMethodsThrowAfterClose.java [ 12350109 ]
Craig Russell added a comment - 01/Feb/07 06:17 AM
Please review this patch.

This patch fixes the issue but I'd like to have it reviewed.

Craig Russell made changes - 01/Feb/07 06:17 AM
Attachment EntityManagerImpl.patch.txt [ 12350114 ]
Patrick Linskey made changes - 01/Feb/07 07:31 AM
Link This issue relates to OPENJPA-123 [ OPENJPA-123 ]
Abe White added a comment - 01/Feb/07 04:00 PM
I personally would put the _broker.assertOpen() calls before the assertNotCloseInvoked() calls, just because it seems like the sensible progression to check whether the broker is closed and then check whether it isn't closed yet but close() has been invoked and it's waiting for a transaction commit. But it makes absolutely no functional difference, so the patch looks good to me.

Repository Revision Date User Message
ASF #502325 Thu Feb 01 19:35:30 UTC 2007 clr OPENJPA-122 Added check for methods that require the EntityManager to be open but where the Broker would throw a different exception
Files Changed
MODIFY /incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerImpl.java

Repository Revision Date User Message
ASF #502341 Thu Feb 01 20:05:16 UTC 2007 clr OPENJPA-122 Added test for throwing IllegalStateException after EntityManager.close
Files Changed
ADD /incubator/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/simple/TestEntityManagerMethodsThrowAfterClose.java

Craig Russell added a comment - 01/Feb/07 08:06 PM
svn commit -m "OPENJPA-122 Added check for methods that require the EntityManager to be open but where the Broker would throw a different exception" openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerImpl.java
Sending openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerImpl.java
Transmitting file data .
Committed revision 502325.

svn commit -m "OPENJPA-122 Added test for throwing IllegalStateException after EntityManager.close" src/test/java/org/apache/openjpa/persistence/simple/TestEntityManagerMethodsThrowAfterClose.java
Adding src/test/java/org/apache/openjpa/persistence/simple/TestEntityManagerMethodsThrowAfterClose.java
Transmitting file data .
Committed revision 502341.

Craig Russell made changes - 01/Feb/07 08:06 PM
Assignee Craig Russell [ clr ]
Resolution Fixed [ 1 ]
Status Open [ 1 ] Resolved [ 5 ]
Repository Revision Date User Message
ASF #502352 Thu Feb 01 20:49:11 UTC 2007 clr OPENJPA-122 Removed unnecessary import
Files Changed
MODIFY /incubator/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/simple/TestEntityManagerMethodsThrowAfterClose.java

Patrick Linskey made changes - 01/Mar/07 02:13 AM
Fix Version/s 0.9.7 [ 12312340 ]