Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-15893

onJobExecute method of org.apache.camel.routepolicy.quartz2.ScheduledRoutePolicy should be public

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • None
    • 3.7.0, 2.25.3
    • camel-quartz2, osgi
    • None
    • Unknown

    Description

      Other wise can't access this method from a proxy.
      For example, if we expose the service in blueprint from one bundle like

      <bean id="myPolicy" class="org.apache.camel.routepolicy.quartz2.CronScheduledRoutePolicy">
                      <property name="routeStartTime" value="....."/>
                      <property name="routeStopTime" value="...."/>
              </bean>
      
              
      
              <service ref="myPolicy" auto-export="all-classes"/>
      

      And refer it in another bundle like this

                       <reference id="remote-policy"
                                      interface="org.apache.camel.routepolicy.quartz2.ScheduledRoutePolicy"
                                      ext:proxy-method='classes'" />
                       <route id="route-remote" routePolicyRef="remote-policy" autoStartup="false">
                              ....
                      </route>
      

      Since here the remote-policy reference from aries blueprint is actually a proxy, so we will run into error like

      at org.apache.camel.routepolicy.quartz2.ScheduledJob.execute(ScheduledJob.java:62) ~[!/:2.21.0.fuse-770013-redhat-00001]
      	at org.quartz.core.JobRunShell.run(JobRunShell.java:202) [!/:2.3.2.redhat-00007]
      	at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573) [!/:2.3.2.redhat-00007]
      Caused by: java.lang.IllegalAccessException: Class org.apache.aries.proxy.impl.ProxyHandler$1 can not access a member of class org.apache.camel.routepolicy.quartz2.ScheduledRoutePolicy with modifiers "protected"
      	at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:102) ~[?:1.8.0_221]
      	at java.lang.reflect.AccessibleObject.slowCheckMemberAccess(AccessibleObject.java:296) ~[?:1.8.0_221]
      	at java.lang.reflect.AccessibleObject.checkAccess(AccessibleObject.java:288) ~[?:1.8.0_221]
      	at java.lang.reflect.Method.invoke(Method.java:491) ~[?:1.8.0_221]
      	at org.apache.aries.proxy.impl.ProxyHandler$1.invoke(ProxyHandler.java:54) ~[?:?]
      	at org.apache.aries.proxy.impl.ProxyHandler.invoke(ProxyHandler.java:119) ~[?:?]
      	at org.apache.camel.routepolicy.quartz2.$ScheduledRoutePolicy566505575.onJobExecute(Unknown Source) ~[!/:2.21.0.fuse-770013-redhat-00001]
      	at org.apache.camel.routepolicy.quartz2.ScheduledJob.execute(ScheduledJob.java:53) ~[!/:2.21.0.fuse-770013-redhat-00001]
      

      So to make this method available for the proxy, we should change its modifier as "public"

      If there's no objection, I will make this change

      Attachments

        Activity

          People

            ffang Freeman Yue Fang
            ffang Freeman Yue Fang
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: