[ https://issues.apache.org/jira/browse/LUCENENET-308?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Digy resolved LUCENENET-308. ---------------------------- Resolution: Fixed patch committed. DIGY > TestIndexWriter.TestThreadInterruptDeadlock > ------------------------------------------- > > Key: LUCENENET-308 > URL: https://issues.apache.org/jira/browse/LUCENENET-308 > Project: Lucene.Net > Issue Type: Bug > Reporter: Andrei Iliev > Attachments: TestIndexWriter.patch > > > 2 problems with the test: > 1) There is no .Net equivalent for java's java.lang.Thread.interrupted() and > interrupted bit => we can not check if IW restored interrupted bit (there is > no such bit). > 2) Sometimes test fails with exception: > An unhandled System.NullReferenceException was thrown while executing this > test : Object reference not set to an instance of an object. > In seems that in java statement "synchronized(this) " > will never throw an InterruptedException but in .Net statement lock(this) > can throw such exception. Because of this the inner exception sometimes will > be null => cause System.NullReferenceException exception. > Here's a snippet of code from the ConcurrentMergeScheduler > ============= > lock (this) // (1) > { > MergeThread merger; > while (MergeThreadCount() >= maxThreadCount) > { > if (Verbose()) > Message(" too many merge threads running; > stalling..."); > try > { > System.Threading.Monitor.Wait(this); // (2) > } > catch > (System.Threading.ThreadInterruptedException ie) > { > // In 3.0 we will change this to throw > // InterruptedException instead > > SupportClass.ThreadClass.Current().Interrupt(); > throw new System.SystemException(ie.Message, > ie); > } > } > ============= > In java ThreadInterruptedException can be thrown only in position (2). But > in .Net it can be at postion (1) as well. > I choose the easiest fix: check not only inner exception but the exception > as well > if(re is System.Threading.ThreadInterruptedException || e is > System.Threading.ThreadInterruptedException) > As alternative we have to fix many places in ConcurrentMergeScheduler by > -finding lock(this), > -add try , and catch blocks in the following way: > catch (System.Threading.ThreadInterruptedException ie) > { > // In 3.0 we will change this to throw > // InterruptedException instead > > SupportClass.ThreadClass.Current().Interrupt(); > throw new System.SystemException(ie.Message, > ie); > } -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.