Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 320276 - Intermittent issue in DescriptorQueryManagerMultithreadedTest$DescriptorQueryManagerAddQueryTest
Summary: Intermittent issue in DescriptorQueryManagerMultithreadedTest$DescriptorQuery...
Status: CLOSED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Nobody - feel free to take it CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-07-19 11:02 EDT by Andrei Ilitchev CLA
Modified: 2022-06-09 10:31 EDT (History)
0 users

See Also:


Attachments
the patch (920 bytes, patch)
2010-07-19 11:05 EDT, Andrei Ilitchev CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andrei Ilitchev CLA 2010-07-19 11:02:00 EDT
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);
Comment 1 Andrei Ilitchev CLA 2010-07-19 11:05:01 EDT
Created attachment 174627 [details]
the patch
Comment 2 Andrei Ilitchev CLA 2010-07-19 11:10:25 EDT
Fixed in bot trunk and 2.1.1
Comment 3 Eclipse Webmaster CLA 2022-06-09 10:15:52 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink
Comment 4 Eclipse Webmaster CLA 2022-06-09 10:31:22 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink