Skip to content

Illegal state exception (duplicate key) on Apache commons-collections #139

@sinha108

Description

@sinha108

Describe the bug
Running codeanalyzer on Apache commons-collections at analysis level 1 results in this failure:

Caused by: java.lang.IllegalStateException: Duplicate key copy(T[]) (attempted merging values Callable(filePath=.../commons-collections/src/main/java/org/apache/commons/collections4/functors/FunctorUtils.java, signature=copy(T[]), comments=[Comment(content=
     * Clones the consumers to ensure that the internal references can't be updated.
     *
     * @param consumers  the consumers to copy.
     * @return the cloned consumers.
     , startLine=81, endLine=86, startColumn=5, endColumn=7, isJavadoc=true)], annotations=[@SuppressWarnings("unchecked")], modifiers=[static], thrownExceptions=[], declaration=static T[] copy(final T... consumers), parameters=[ParameterInCallable(type=T, name=consumers, annotations=[], modifiers=[final], startLine=88, endLine=88, startColumn=45, endColumn=64)], code={
        return clone(consumers);
    }, startLine=87, endLine=90, codeStartLine=88, returnType=T[], isImplicit=false, isConstructor=false, referencedTypes=[], accessedFields=[], callSites=[CallSite(methodName=clone, comment=null, receiverExpr=, receiverType=, argumentTypes=[], argumentExpr=[consumers], returnType=, calleeSignature=clone(java.lang.Object[]), isPublic=false, isProtected=false, isPrivate=true, isUnspecified=false, isStaticCall=false, isConstructorCall=false, crudOperation=null, crudQuery=null, startLine=89, startColumn=16, endLine=89, endColumn=31)], variableDeclarations=[], crudOperations=[], crudQueries=[], cyclomaticComplexity=1, isEntrypoint=false) and Callable(filePath=.../commons-collections/src/main/java/org/apache/commons/collections4/functors/FunctorUtils.java, signature=copy(T[]), comments=[Comment(content=
     * Clone the predicates to ensure that the internal reference can't be messed with.
     * Due to the {@link Predicate#test(T)} method, Predicate<? super T> is
     * able to be coerced to Predicate<T> without casting issues.
     *
     * @param predicates  the predicates to copy
     * @return the cloned predicates
     , startLine=92, endLine=99, startColumn=5, endColumn=7, isJavadoc=true)], annotations=[@SuppressWarnings("unchecked")], modifiers=[static], thrownExceptions=[], declaration=static T[] copy(final T... predicates), parameters=[ParameterInCallable(type=T, name=predicates, annotations=[], modifiers=[final], startLine=101, endLine=101, startColumn=65, endColumn=85)], code={
        return clone(predicates);
    }, startLine=100, endLine=103, codeStartLine=101, returnType=T[], isImplicit=false, isConstructor=false, referencedTypes=[], accessedFields=[], callSites=[CallSite(methodName=clone, comment=null, receiverExpr=, receiverType=, argumentTypes=[], argumentExpr=[predicates], returnType=, calleeSignature=clone(java.lang.Object[]), isPublic=false, isProtected=false, isPrivate=true, isUnspecified=false, isStaticCall=false, isConstructorCall=false, crudOperation=null, crudQuery=null, startLine=102, startColumn=16, endLine=102, endColumn=32)], variableDeclarations=[], crudOperations=[], crudQueries=[], cyclomaticComplexity=1, isEntrypoint=false))
	at java.base/java.util.stream.Collectors.duplicateKeyException(Collectors.java:135)
	at java.base/java.util.stream.Collectors.lambda$uniqKeysMapAccumulator$1(Collectors.java:182)
	at java.base/java.util.stream.ReduceOps$3ReducingSink.accept(ReduceOps.java:169)
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
	at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179)
	at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1708)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
	at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682)
	at com.ibm.cldk.SymbolTable.lambda$processCompilationUnit$23(SymbolTable.java:283)
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
	at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179)
	at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1708)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
	at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682)
	at com.ibm.cldk.SymbolTable.processCompilationUnit(SymbolTable.java:290)
	at com.ibm.cldk.SymbolTable.extractAll(SymbolTable.java:1166)
	at com.ibm.cldk.CodeAnalyzer.analyze(CodeAnalyzer.java:196)
	at com.ibm.cldk.CodeAnalyzer.run(CodeAnalyzer.java:119)

To Reproduce
Steps to reproduce the behavior:
1.

Expected behavior
A clear and concise description of what you expected to happen.

Logs
If applicable, add logs to help explain your problem.

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions