CPM setAnalysisEngine throws IndexOutOfBounds ---------------------------------------------
Key: UIMA-1732 URL: https://issues.apache.org/jira/browse/UIMA-1732 Project: UIMA Issue Type: Bug Components: Collection Processing Affects Versions: 2.3 Reporter: Marshall Schor Assignee: Jerry Cwiklik Priority: Minor A user tried to do several calls to aCPM.setAnalysisEngine(xxx). This method is set up to remove a previous AE if it exists, replacing it with the new one. See http://markmail.org/message/3s2w7hxb24l3czky There are several issues: The method CPMEngine removeCasProcessor(int aCasProcessorIndex) has a bad bounds test, need to change {noformat} if (aCasProcessorIndex < 0 || aCasProcessorIndex > annotatorList.size()) to if (aCasProcessorIndex < 0 || aCasProcessorIndex >= annotatorList.size()) {noformat} The CPMEngine class uses two different collections to represent lists of analysis engines: * casprocessorList (an array - includes AEs and Cas Consumers) * annotatorList (a linked list, not sure if it has both AEs and Cas Consumers) The CPMImpl setAnalysisEngine seems to have set something which shows up in the array from getCasProcessors call, while the "annotatorList" is not updated and remains empty. This method: {noformat} public void removeCasProcessor(CasProcessor aCasProcessor) { cpEngine.removeCasProcessor(0); } {noformat} ignores its argument, and removes the 0'th CasProcessor. This seems wrong, given the Javadoc. The Javadoc for setAnalysisEngine's javadoc should emphasize that this is a convenience method for the common case of supporting a single AE. If it is called multiple times, it will replace the first AE (if it exists) . The Javadocs should be expanded to say if you want to add multiple AEs to a pipe line, to not use this method, but use addCasProcessor instead. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.