dragon-zhang commented on PR #4867:
URL: https://github.com/apache/shenyu/pull/4867#issuecomment-1639773189

   > client shutdown close method call twice ? how to fixed?
   
   ```java
   @Target({ElementType.METHOD, ElementType.ANNOTATION_TYPE})
   @Retention(RetentionPolicy.RUNTIME)
   @Documented
   public @interface Bean {
   
        //......
   
        /**
         * The optional name of a method to call on the bean instance upon 
closing the
         * application context, for example a {@code close()} method on a JDBC
         * {@code DataSource} implementation, or a Hibernate {@code 
SessionFactory} object.
         * The method must have no arguments but may throw any exception.
         * <p>As a convenience to the user, the container will attempt to infer 
a destroy
         * method against an object returned from the {@code @Bean} method. For 
example, given
         * an {@code @Bean} method returning an Apache Commons DBCP {@code 
BasicDataSource},
         * the container will notice the {@code close()} method available on 
that object and
         * automatically register it as the {@code destroyMethod}. This 
'destroy method
         * inference' is currently limited to detecting only public, no-arg 
methods named
         * 'close' or 'shutdown'. The method may be declared at any level of 
the inheritance
         * hierarchy and will be detected regardless of the return type of the 
{@code @Bean}
         * method (i.e., detection occurs reflectively against the bean 
instance itself at
         * creation time).
         * <p>To disable destroy method inference for a particular {@code 
@Bean}, specify an
         * empty string as the value, e.g. {@code @Bean(destroyMethod="")}. 
Note that the
         * {@link org.springframework.beans.factory.DisposableBean} callback 
interface will
         * nevertheless get detected and the corresponding destroy method 
invoked: In other
         * words, {@code destroyMethod=""} only affects custom close/shutdown 
methods and
         * {@link java.io.Closeable}/{@link java.lang.AutoCloseable} declared 
close methods.
         * <p>Note: Only invoked on beans whose lifecycle is under the full 
control of the
         * factory, which is always the case for singletons but not guaranteed 
for any
         * other scope.
         * @see org.springframework.beans.factory.DisposableBean
         * @see 
org.springframework.context.ConfigurableApplicationContext#close()
         */
        String destroyMethod() default AbstractBeanDefinition.INFER_METHOD;
   }
   ```
   
   The `close` in `ShenyuClientRegisterRepository` will be called by spring, so 
just change the `close` method name.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to