Uploaded image for project: 'Magnolia REST Framework'
  1. Magnolia REST Framework
  2. MGNLREST-156

SwaggerRestDispatcherServlet (re)register endpoint without provider validation.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: Neutral Neutral
    • None
    • None
    • tools
    • None
    • Saigon 124, Saigon 125, Saigon 126, Saigon 127
    • 3

      We have issue with SwaggerRestDispatcherServlet which executes delegation calls to info.magnolia.rest.RestDispatcherServlet methods. Unfortunately, those call is not secured with provider.isValid check --> endpoint ends up failed to re-register.

      Prefer:
      info.magnolia.rest.tools.SwaggerRestDispatcherServlet#onEndpointRegistered
      info.magnolia.rest.tools.SwaggerRestDispatcherServlet#onEndpointReregistered

      Stack trace:

      2017-12-13 10:41:49,649 WARN  fig.source.yaml.decoration.YamlDefinitionDecorator: 
      Severity type:   MAJOR 
      Title:           /: [Definition decoration] - Failed to parse decoration data from [/1_decor/decorations/rest-content-delivery/restEndpoints/restDelivery.yaml] 
      Problem details: Illegal state: Only support maps with String keys 0 in {0=mgnl:page, 1=mgnl:area, 2=mgnl:component}
      2017-12-13 10:41:49,653 ERROR info.magnolia.event.SimpleEventBus                : Exception caught when dispatching info.magnolia.rest.registry.EndpointDefinitionRegistryEvent with info.magnolia.rest.tools.SwaggerRestDispatcherServlet eventHandler.
      info.magnolia.objectfactory.MgnlInstantiationException: Unable to resolve parameters for constructor public info.magnolia.rest.delivery.jcr.v1.JcrDeliveryEndpoint(info.magnolia.rest.delivery.jcr.v1.JcrDeliveryEndpointDefinition,javax.inject.Provider). Unresolved parameter(s) are: 1st parameter which is of type info.magnolia.rest.delivery.jcr.v1.JcrDeliveryEndpointDefinition
      	at info.magnolia.objectfactory.ObjectManufacturer.newInstance(ObjectManufacturer.java:97) ~[magnolia-core-5.6.jar:?]
      	at info.magnolia.objectfactory.guice.GuiceComponentProvider.newInstanceWithParameterResolvers(GuiceComponentProvider.java:132) ~[magnolia-core-5.6.jar:?]
      	at info.magnolia.objectfactory.guice.GuiceComponentProvider.newInstanceWithParameterResolvers(GuiceComponentProvider.java:119) ~[magnolia-core-5.6.jar:?]
      	at info.magnolia.objectfactory.guice.GuiceComponentProvider.newInstance(GuiceComponentProvider.java:114) ~[magnolia-core-5.6.jar:?]
      	at info.magnolia.rest.RestDispatcherServlet.instantiateEndpoint(RestDispatcherServlet.java:211) ~[magnolia-rest-integration-2.0.jar:?]
      	at info.magnolia.rest.RestDispatcherServlet.registerEndpoint(RestDispatcherServlet.java:189) ~[magnolia-rest-integration-2.0.jar:?]
      	at info.magnolia.rest.RestDispatcherServlet.onEndpointReregistered(RestDispatcherServlet.java:155) ~[magnolia-rest-integration-2.0.jar:?]
      	at info.magnolia.rest.tools.SwaggerRestDispatcherServlet.onEndpointReregistered(SwaggerRestDispatcherServlet.java:161) ~[magnolia-rest-tools-2.0.jar:?]
      	at info.magnolia.rest.registry.EndpointDefinitionRegistryEvent.dispatch(EndpointDefinitionRegistryEvent.java:106) ~[magnolia-rest-integration-2.0.jar:?]
      	at info.magnolia.rest.registry.EndpointDefinitionRegistryEvent.dispatch(EndpointDefinitionRegistryEvent.java:55) ~[magnolia-rest-integration-2.0.jar:?]
      	at info.magnolia.event.SimpleEventBus.fireEvent(SimpleEventBus.java:75) ~[magnolia-core-5.6.jar:?]
      	at info.magnolia.rest.registry.EndpointDefinitionRegistry.lambda$addDecorator$8(EndpointDefinitionRegistry.java:137) ~[magnolia-rest-integration-2.0.jar:?]
      	at java.util.Optional.ifPresent(Optional.java:159) ~[?:1.8.0_131]
      	at info.magnolia.rest.registry.EndpointDefinitionRegistry.addDecorator(EndpointDefinitionRegistry.java:137) ~[magnolia-rest-integration-2.0.jar:?]
      	at info.magnolia.config.source.yaml.AbstractFileResourceConfigurationSource$DefinitionDecoratorResolutionFunction.doWith(AbstractFileResourceConfigurationSource.java:302) ~[magnolia-configuration-5.6.jar:?]
      	at info.magnolia.config.source.yaml.AbstractFileResourceConfigurationSource$DefinitionDecoratorResolutionFunction.doWith(AbstractFileResourceConfigurationSource.java:290) ~[magnolia-configuration-5.6.jar:?]
      	at info.magnolia.resourceloader.util.VoidFunction.apply(VoidFunction.java:49) ~[magnolia-resource-loader-5.6.jar:?]
      	at info.magnolia.config.source.yaml.AbstractFileResourceConfigurationSource.lambda$startDecoration$3(AbstractFileResourceConfigurationSource.java:190) ~[magnolia-configuration-5.6.jar:?]
      	at info.magnolia.resourceloader.layered.LayeredResourceOrigin$RelayingChangeHandler.onResourceChanged(LayeredResourceOrigin.java:285) [magnolia-resource-loader-5.6.jar:?]
      	at info.magnolia.resourceloader.AbstractResourceOrigin.dispatchResourceChange(AbstractResourceOrigin.java:132) [magnolia-resource-loader-5.6.jar:?]
      	at info.magnolia.resourceloader.file.FileWatcherCallback.dispatchResourceChange(FileWatcherCallback.java:117) [magnolia-resource-loader-5.6.jar:?]
      	at info.magnolia.resourceloader.file.FileWatcherCallback.modified(FileWatcherCallback.java:88) [magnolia-resource-loader-5.6.jar:?]
      	at info.magnolia.dirwatch.DirectoryWatcher.processEvent(DirectoryWatcher.java:307) [magnolia-resource-loader-5.6.jar:?]
      	at info.magnolia.dirwatch.DirectoryWatcher.run(DirectoryWatcher.java:253) [magnolia-resource-loader-5.6.jar:?]
      	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_131]
      	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_131]
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [?:1.8.0_131]
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [?:1.8.0_131]
      	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_131]
      

      Environments to re-produce:
      1. Magnolia 5.6 release:
      + bundle loaded with rest-tool 2.0
      2. Magnolia 5.6.1:
      + bundle loaded with rest-tool 2.0 (before the fix MAGNOLIA-7193) (this ticket include yaml definition and yaml decoration that can re-produce issue easily before MAGNOLIA-7193. After MAGNOLIA-7193, issue still possible to happens but would harder to make it occurs.)

      Step to reproduce:
      1) Get bundle start successfully with rest-tool enabled (tried with release bundles, can't add rest-tool without manually provide swagger dependencies).
      2) Add yaml definition module for rest
      3) Add yaml decoration for previously add rest definition --> this definition would not effect due to MGNLREST-157
      4) Try to modify decoration file --> without rest-tool, this modification would result in an effective decoration. With rest-tool, this is causing above exception and original endpoint unregister.

        Acceptance criteria

              dai.ha Dai Ha
              dai.ha Dai Ha
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved:

                  Bug DoR
                  Task DoD

                    Estimated:
                    Original Estimate - 2d
                    2d
                    Remaining:
                    Remaining Estimate - 0d
                    0d
                    Logged:
                    Time Spent - 2d
                    2d