Payara icon indicating copy to clipboard operation
Payara copied to clipboard

Bug Report: duplicateKeyException in OpenAPI after upgrade to Payara 6.2023.6 / FISH-7965

Open marcinpaton opened this issue 1 year ago • 10 comments

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

  1. Configure OpenAPI in application deployed on Payara
  2. 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

marcinpaton avatar Aug 18 '23 10:08 marcinpaton

Hi @marcinpaton, would you be able to test this in the latest version of Payara?

kalinchan avatar Sep 20 '23 12:09 kalinchan

hi, I've tested it on 6.2023.9 and the problem still exists.

marcinpaton avatar Sep 21 '23 06:09 marcinpaton

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.

kalinchan avatar Sep 26 '23 10:09 kalinchan

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.

github-actions[bot] avatar Oct 02 '23 00:10 github-actions[bot]

hi, ok I will try to reproduce the issue in this sample application this or next week

marcinpaton avatar Oct 03 '23 06:10 marcinpaton

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.

github-actions[bot] avatar Oct 18 '23 00:10 github-actions[bot]

Hi @kalinchan Please do the following steps to reproduce the bug:

  1. Clone and build this sample application: https://github.com/marcinpaton/payaraSwagger
  2. Deploy payaraSwagger.war on newest version of payara
  3. To verify if application started properly open link: http://localhost:8080/payaraSwagger/api/hello-world - 'Hello, World!' message should appear.
  4. 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'.
  5. Check server.log to see exceptions.

marcinpaton avatar Oct 19 '23 10:10 marcinpaton

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

Elifzeynepedman avatar Oct 25 '23 06:10 Elifzeynepedman

@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! ❤️

pdurbin avatar Jan 10 '24 15:01 pdurbin

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!

ghunteranderson avatar Feb 13 '24 22:02 ghunteranderson