Bug #2838
closedSearch "soil" in metacat causes an exception
0%
Description
After release 1.7, we made some changes in metacat search part. I found search "datos" caused an exception:
[ERROR]: Exception in DBQuery.findDocuments: null [edu.ucsb.nceas.metacat.DBQuery]
java.util.ConcurrentModificationException
at java.util.AbstractList$Itr.checkForComodification(AbstractList.java:449)
at java.util.AbstractList$Itr.next(AbstractList.java:420)
at edu.ucsb.nceas.metacat.DBQuery.addRelationship(DBQuery.java:1249)
at edu.ucsb.nceas.metacat.DBQuery.handleSubsetResult(DBQuery.java:844)
at edu.ucsb.nceas.metacat.DBQuery.findResultDoclist(DBQuery.java:760)
at edu.ucsb.nceas.metacat.DBQuery.createResultDocument(DBQuery.java:410)
at edu.ucsb.nceas.metacat.DBQuery.findDocuments(DBQuery.java:307)
at edu.ucsb.nceas.metacat.DBQuery.findDocuments(DBQuery.java:234)
at edu.ucsb.nceas.metacat.MetaCatServlet.handleQuery(MetaCatServlet.java:1096)
at edu.ucsb.nceas.metacat.MetaCatServlet.handleGetOrPost(MetaCatServlet.java:644)
at edu.ucsb.nceas.metacat.MetaCatServlet.doPost(MetaCatServlet.java:294)
I digged around and found the problem was that there were duplicate docids in DocumentResutlSet object and it caused to remove docid (key) from a hashtable mutiple times, which only had one key for a docid. The reason the object had duplicated docids was the back tracing process didn't get rid of the duplicated docids. I fixed the problem and search "datos" works.
However, search "soil" and other stuff still bring the exception. We need to fix it.
Updated by Jing Tao over 17 years ago
This bug was caused by the new private class ResultDocumentSet. In addRelationship method, we have Iterator docidkey which is got from a Vector docid in class ResultDocumentSet. Then there is a while loop for Iterator docidkey. However, during this while loop, if there is a beta6 doc, the docid Vector will be have remove and put operation. Those operations to Vector will cause original Iterator docidkeys be invalid. So call "docidkey.next()" will cause the exception.
Solution, rather than remove and put action to the Vector, a set() method was added to ResultDocumentSet. This method would NOT cause concurrent modification to the Vector.