Skip to content

"Duplicate key" error when using repeated matches with the same name and type #117

@bmcfeely

Description

@bmcfeely

When I try to compile the following with 0.1.9:

"%{NUMBER:myValue:int} %{NUMBER:myValue:int}";

I get:

java.lang.IllegalStateException: Duplicate key myValue (attempted merging values INT and INT)
	at java.base/java.util.stream.Collectors.duplicateKeyException(Collectors.java:133)
	at java.base/java.util.stream.Collectors.lambda$uniqKeysMapAccumulator$1(Collectors.java:180)
	at java.base/java.util.stream.ReduceOps$3ReducingSink.accept(ReduceOps.java:169)
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
	at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177)
	at java.base/java.util.HashMap$ValueSpliterator.forEachRemaining(HashMap.java:1675)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
	at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578)
	at io.krakens.grok.api.Converter.getGroupTypes(Converter.java:85)
	at io.krakens.grok.api.Grok.<init>(Grok.java:72)
	at io.krakens.grok.api.GrokCompiler.compile(GrokCompiler.java:197)
	at io.krakens.grok.api.GrokCompiler.compile(GrokCompiler.java:124)
	at io.krakens.grok.api.GrokCompiler.compile(GrokCompiler.java:120)

However, when I try:

"%{NUMBER:myValue} %{NUMBER:myValue}"

It works just fine.

So maybe a different version of toMap needs to be called, maybe the one that takes BinaryOperator<U> mergeFunction as the third argument? 🤔 Not sure what merge function to pass it, though.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions