Community
Participate
Working Groups
DescriptorQueryManagerMultithreadedTest$DescriptorQueryManagerAddQueryTest Exception Description: Fatal error occurred. Internal Exception: java.util.NoSuchElementException Local Exception Stack: Exception [EclipseLink-0] (Eclipse Persistence Services - 2.1.1.v20100717-r7852): org.eclipse.persistence.testing.framework.TestErrorException Exception Description: Fatal error occurred. Internal Exception: java.util.NoSuchElementException at org.eclipse.persistence.testing.framework.TestCase.execute(TestCase.java:164) at org.eclipse.persistence.testing.framework.TestCase.runBare(TestCase.java:263) at org.eclipse.persistence.testing.framework.TestExecutor.execute(TestExecutor.java:248) at org.eclipse.persistence.testing.tests.simultaneous.TestExecutorWithClientSession.runTest(TestExecutorWithClientSession.java:153) at org.eclipse.persistence.testing.framework.ui.SynchronizedTestExecutor.run(SynchronizedTestExecutor.java:61) Caused by: java.util.NoSuchElementException at org.eclipse.persistence.internal.helper.NonSynchronizedVector.firstElement(NonSynchronizedVector.java:172) at org.eclipse.persistence.descriptors.DescriptorQueryManager.getLocalQuery(DescriptorQueryManager.java:535) at org.eclipse.persistence.descriptors.DescriptorQueryManager.getQuery(DescriptorQueryManager.java:499) at org.eclipse.persistence.descriptors.DescriptorQueryManager.getQuery(DescriptorQueryManager.java:484) at org.eclipse.persistence.testing.tests.simultaneous.DescriptorQueryManagerMultithreadedTest$DescriptorQueryManagerAddQueryTest.verify(DescriptorQueryManagerMultithreadedTest.java:70) at org.eclipse.persistence.testing.framework.TestCase.execute(TestCase.java:155) This happens when a very narrow window is hit: in DescriptorQueryManager.addQuery method one thread has already removed the ith query but hasn't yet added the new one; another thread at this moment in DescriptorQueryManager.getLocalQuery() has verified that queries.size()==1 (before the first thread has removed the query); then the next statement queries.firstElement() throws exception - because the first thread has removed the only element there was. The fix is simple: in DescriptorQueryManager.addQuery instead of: queriesByName.remove(i); queriesByName.add(i, query); use: queriesByName.set(i, query);
Created attachment 174627 [details] the patch
Fixed in bot trunk and 2.1.1
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink