Payara
Payara copied to clipboard
Bug Report: duplicateKeyException in OpenAPI after upgrade to Payara 6.2023.6 / FISH-7965
Brief Summary
After upgrade Payara from 6.2023.4 to 6.2023.6 we're getting exception from OpenAPI:
StandardWrapperValve[microprofile-openapi-servlet]: Servlet.service() for servlet microprofile-openapi-servlet threw exception
java.lang.IllegalStateException: Duplicate key net.bytebuddy.implementation.bind.annotation.Argument (attempted merging values AnnotationTypeImpl{name='net.bytebuddy.implementation.bind.annotation.Argument', annotations=[ java.lang.annotation.Documented java.lang.annotation.Retention java.lang.annotation.Target], subclasses=[], parent=null, interfaces=[], implementors=[], referenced from [ ParameterImpl{null} ParameterImpl{null}]} and InterfaceModelImpl{name='net.bytebuddy.implementation.bind.annotation.Argument', annotations=[], subclasses=[], parent=null, interfaces=[], implementors=[ net.bytebuddy.implementation.bind.annotation.TargetMethodAnnotationDrivenBinder$DelegationProcessor$Handler$Unbound$DefaultArgument]})
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.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1655)
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 fish.payara.microprofile.openapi.impl.OpenAPISupplier.typesToMap(OpenAPISupplier.java:198)
at fish.payara.microprofile.openapi.impl.OpenAPISupplier.collectTypesFromArchive(OpenAPISupplier.java:192)
at fish.payara.microprofile.openapi.impl.OpenAPISupplier.get(OpenAPISupplier.java:126)
at fish.payara.microprofile.openapi.impl.OpenApiService.getDocument(OpenApiService.java:149)
at fish.payara.microprofile.openapi.impl.rest.app.service.OpenApiResource.getResponse(OpenApiResource.java:84)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
Function TypesCtr.getAllTypes() which is used in OpenAPISupplier.typesToMap may return collection of duplicated classes so Collectors.toMap throws exception. Probably merge function should be used in Collectors.toMap. Ex. :
public static Map<String, Type> typesToMap(Types types) {
return types.getAllTypes().stream()
.collect(Collectors.toMap((t) -> t.getName(), Function.identity(), (type1, type2) -> type1));
}
Expected Outcome
No exception
Current Outcome
Exception: StandardWrapperValve[microprofile-openapi-servlet]: Servlet.service() for servlet microprofile-openapi-servlet threw exception java.lang.IllegalStateException: Duplicate key net.bytebuddy.implementation.bind.annotation.Argument (attempted merging values AnnotationTypeImpl{name='net.bytebuddy.implementation.bind.annotation.Argument', annotations=[ java.lang.annotation.Documented java.lang.annotation.Retention java.lang.annotation.Target], subclasses=[], parent=null, interfaces=[], implementors=[], referenced from [ ParameterImpl{null} ParameterImpl{null}]} and InterfaceModelImpl{name='net.bytebuddy.implementation.bind.annotation.Argument', annotations=[], subclasses=[], parent=null, interfaces=[], implementors=[ net.bytebuddy.implementation.bind.annotation.TargetMethodAnnotationDrivenBinder$DelegationProcessor$Handler$Unbound$DefaultArgument]}) 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.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1655) 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 fish.payara.microprofile.openapi.impl.OpenAPISupplier.typesToMap(OpenAPISupplier.java:198) at fish.payara.microprofile.openapi.impl.OpenAPISupplier.collectTypesFromArchive(OpenAPISupplier.java:192) at fish.payara.microprofile.openapi.impl.OpenAPISupplier.get(OpenAPISupplier.java:126) at fish.payara.microprofile.openapi.impl.OpenApiService.getDocument(OpenApiService.java:149) at fish.payara.microprofile.openapi.impl.rest.app.service.OpenApiResource.getResponse(OpenApiResource.java:84) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
Reproducer
- Configure OpenAPI in application deployed on Payara
- Visit http://host:8080/openapi/
Operating System
Ubuntu 20.04.6 LTS
JDK Version
openjdk 11.0.19 2023-04-18 LTS
Payara Distribution
Payara Server Full Profile
Hi @marcinpaton, would you be able to test this in the latest version of Payara?
hi, I've tested it on 6.2023.9 and the problem still exists.
Hi @marcinpaton,
Can you provide more details on how to reproduce this issue?
I have deployed the following application https://github.com/payara/Payara-Examples/tree/Payara6/microprofile/openapi-example and I am unable to reproduce this issue.
Greetings, It's been more than 5 days since we requested more information or an update from you on the details of this issue. Could you provide an update soon, please? We're afraid that if we do not receive an update, we'll have to close this issue due to inactivity.
hi, ok I will try to reproduce the issue in this sample application this or next week
Greetings, It's been more than 5 days since we requested more information or an update from you on the details of this issue. Could you provide an update soon, please? We're afraid that if we do not receive an update, we'll have to close this issue due to inactivity.
Hi @kalinchan Please do the following steps to reproduce the bug:
- Clone and build this sample application: https://github.com/marcinpaton/payaraSwagger
- Deploy payaraSwagger.war on newest version of payara
- To verify if application started properly open link: http://localhost:8080/payaraSwagger/api/hello-world - 'Hello, World!' message should appear.
- Open this link in browser: http://localhost:8080/payaraSwagger/api/openapi-ui/index.html - you will see the following error message: 'Failed to load API definition'.
- Check server.log to see exceptions.
Hi @marcinpaton,
Many thanks for providing the reproducer, I was able to reproduce the issue and I have escalated this to the platform development team as FISH-7965
.
Thank you, Elif
@kalinchan @Elifzeynepedman hi! I'm glad you're able to reproduce the bug thanks to @marcinpaton.
Any news on FISH-7965
or a fix? We've been using /openapi
to programmatically generate client code and we (the Dataverse team) would love to have it working again.
Thanks for Payara! It's a great product! ❤️
This issue is affecting all the applications across my teams as well. Unfortunately, we've not found a workaround yet.
I've opened PR https://github.com/payara/Payara/pull/6563 with @marcinpaton's suggested solution. Local testing confirms this change addresses the issue for our applications.
Feel free to let me know if there's anything I can help with this one. Thanks!