You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by GitBox <gi...@apache.org> on 2021/10/11 06:04:17 UTC

[GitHub] [dubbo] sunhk opened a new issue #7896: AwaitingNonWebApplicationListener中的ExecutorService对象未使用守护线程,导致Spring初始化异常进程仍旧运行

sunhk opened a new issue #7896:
URL: https://github.com/apache/dubbo/issues/7896


   java.util.concurrent.Executors#newSingleThreadExecutor()中的ThreadFactory生成的Thread不是守护线程,并且没有相应逻辑在Spring初始化异常出现时调起ExecutorService的shutdown方法,导致spring初始化失败进程依旧存在,无法通过进程是否存在判断程序启动是否正常。建议更换ThreadFactory。可通过错误的application.yml配置复现问题。


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] sunhk edited a comment on issue #7896: AwaitingNonWebApplicationListener中的ExecutorService对象未使用守护线程,导致Spring初始化异常进程仍旧运行

Posted by GitBox <gi...@apache.org>.
sunhk edited a comment on issue #7896:
URL: https://github.com/apache/dubbo/issues/7896#issuecomment-939230733


   > 
   > 
   > 如果启动异常会调用spring的销毁方法,那么Dubbo就可以接收到销毁的通知。通过org.apache.dubbo.config.spring.context.DubboDeployApplicationListener会结束掉这个线程。按道理应该会中止这个线程,所以能否提供能复现的demo。
   
   抱歉问题描述不够严谨,解决方案也过于想当然了,有违此类初衷。今天又重新跟踪了一下,发现简单的dubbo-springboot使用并不会发生此问题,之所以会出现程序报错后进程没有停止的现象是因为我的项目中引入了spring-cloud组件,BootstrapApplicationListener中进行了额外了SpringApplication对象初始化过程,发生了ApplicationReadyEvent事件,导致AwaitingNonWebApplicationListener中的await方法被调用,使线程池中线程提前初始化,#8133 也提到await方法提前调用,可能有相似之处,复现代码如下:
   pom.xml
   ```
   <?xml version="1.0" encoding="UTF-8"?>
   <project xmlns="http://maven.apache.org/POM/4.0.0"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
   
       <modelVersion>4.0.0</modelVersion>
       <groupId>com.example</groupId>
       <artifactId>dubbo-spring</artifactId>
       <version>0.0.1-SNAPSHOT</version>
   
       <dependencies>
           <dependency>
               <groupId>org.springframework.boot</groupId>
               <artifactId>spring-boot-starter</artifactId>
               <version>2.3.10.RELEASE</version>
           </dependency>
           <dependency>
               <groupId>org.apache.dubbo</groupId>
               <artifactId>dubbo-spring-boot-starter</artifactId>
               <version>3.0.3</version>
           </dependency>
           <dependency>
               <groupId>org.springframework.cloud</groupId>
               <artifactId>spring-cloud-context</artifactId>
               <version>2.2.8.RELEASE</version>
           </dependency>
       </dependencies>
   </project>
   ```
   
   application.yml
   ```
   dubbo:
     application:
       name: demo
     registry:
       protocol: multicast
       address: 224.5.6.7:1234
   string: error
   ```
   
   Application.java
   ```
   package com.example;
   
   import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
   import org.springframework.beans.factory.annotation.Value;
   import org.springframework.boot.SpringApplication;
   import org.springframework.boot.autoconfigure.SpringBootApplication;
   
   @SpringBootApplication
   //@EnableDubbo
   public class Application {
       @Value("${string}")
       private Integer value;
   
       public static void main(String[] args) {
           SpringApplication.run(Application.class, args);
       }
   }
   ```
   是否使用@EnableDubbo并不影响此现象发生,是否考虑将AwaitingNonWebApplicationListener的加载像DubboDeployApplicationListener一样与@EnableDubbo关联起来,而不是放在spring.factories中,从而保证只有初始化dubbo环境的SpringApplication才会调用此Listener
   另外,spring.factories中其他与dubbo相关类也有可能存在不受@EnableDubbo控制的问题


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] candyaaa commented on issue #7896: AwaitingNonWebApplicationListener中的ExecutorService对象未使用守护线程,导致Spring初始化异常进程仍旧运行

Posted by GitBox <gi...@apache.org>.
candyaaa commented on issue #7896:
URL: https://github.com/apache/dubbo/issues/7896#issuecomment-930344265


   @i will solve it@


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] sunhk commented on issue #7896: AwaitingNonWebApplicationListener中的ExecutorService对象未使用守护线程,导致Spring初始化异常进程仍旧运行

Posted by GitBox <gi...@apache.org>.
sunhk commented on issue #7896:
URL: https://github.com/apache/dubbo/issues/7896#issuecomment-939707413


   2.7中也存在相同的问题


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] candyaaa commented on issue #7896: AwaitingNonWebApplicationListener中的ExecutorService对象未使用守护线程,导致Spring初始化异常进程仍旧运行

Posted by GitBox <gi...@apache.org>.
candyaaa commented on issue #7896:
URL: https://github.com/apache/dubbo/issues/7896#issuecomment-930737139


   这个问题类似:#8133


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] candyaaa removed a comment on issue #7896: AwaitingNonWebApplicationListener中的ExecutorService对象未使用守护线程,导致Spring初始化异常进程仍旧运行

Posted by GitBox <gi...@apache.org>.
candyaaa removed a comment on issue #7896:
URL: https://github.com/apache/dubbo/issues/7896#issuecomment-930344265


   @i will solve it@


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] sunhk closed issue #7896: AwaitingNonWebApplicationListener中的ExecutorService对象未使用守护线程,导致Spring初始化异常进程仍旧运行

Posted by GitBox <gi...@apache.org>.
sunhk closed issue #7896:
URL: https://github.com/apache/dubbo/issues/7896


   


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] sunhk closed issue #7896: AwaitingNonWebApplicationListener中的ExecutorService对象未使用守护线程,导致Spring初始化异常进程仍旧运行

Posted by GitBox <gi...@apache.org>.
sunhk closed issue #7896:
URL: https://github.com/apache/dubbo/issues/7896


   


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] candyaaa commented on issue #7896: AwaitingNonWebApplicationListener中的ExecutorService对象未使用守护线程,导致Spring初始化异常进程仍旧运行

Posted by GitBox <gi...@apache.org>.
candyaaa commented on issue #7896:
URL: https://github.com/apache/dubbo/issues/7896#issuecomment-929947985


   能否提供错误的application.yml,方便复现问题。


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] candyaaa commented on issue #7896: AwaitingNonWebApplicationListener中的ExecutorService对象未使用守护线程,导致Spring初始化异常进程仍旧运行

Posted by GitBox <gi...@apache.org>.
candyaaa commented on issue #7896:
URL: https://github.com/apache/dubbo/issues/7896#issuecomment-930759888


   如果启动异常会调用spring的销毁方法,那么Dubbo就可以接收到销毁的通知。通过org.apache.dubbo.config.spring.context.DubboDeployApplicationListener会结束掉这个线程。按道理应该会中止这个线程,所以能否提供能复现的demo。


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] AlbumenJ closed issue #7896: AwaitingNonWebApplicationListener中的ExecutorService对象未使用守护线程,导致Spring初始化异常进程仍旧运行

Posted by GitBox <gi...@apache.org>.
AlbumenJ closed issue #7896:
URL: https://github.com/apache/dubbo/issues/7896


   


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] sunhk commented on issue #7896: AwaitingNonWebApplicationListener中的ExecutorService对象未使用守护线程,导致Spring初始化异常进程仍旧运行

Posted by GitBox <gi...@apache.org>.
sunhk commented on issue #7896:
URL: https://github.com/apache/dubbo/issues/7896#issuecomment-939230733


   > 
   > 
   > 如果启动异常会调用spring的销毁方法,那么Dubbo就可以接收到销毁的通知。通过org.apache.dubbo.config.spring.context.DubboDeployApplicationListener会结束掉这个线程。按道理应该会中止这个线程,所以能否提供能复现的demo。
   
   抱歉问题描述不够严谨,解决方案也过于想当然了,有违此类初衷。今天又重新跟踪了一下,发现简单的dubbo-springboot使用并不会发生此问题,之所以会出现程序报错后进程没有停止的现象是因为我的项目中引入了spring-cloud组件,BootstrapApplicationListener中进行了额外了SpringApplication对象初始化过程,发生了ApplicationReadyEvent事件,导致AwaitingNonWebApplicationListener中的await方法被调用,使线程池中线程提前初始化,#8133 也提到await方法提前调用,可能有相似之处,复现代码如下:
   pom.xml
   ```
   <?xml version="1.0" encoding="UTF-8"?>
   <project xmlns="http://maven.apache.org/POM/4.0.0"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
   
       <modelVersion>4.0.0</modelVersion>
       <groupId>com.example</groupId>
       <artifactId>dubbo-spring</artifactId>
       <version>0.0.1-SNAPSHOT</version>
   
       <dependencies>
           <dependency>
               <groupId>org.springframework.boot</groupId>
               <artifactId>spring-boot-starter</artifactId>
               <version>2.3.10.RELEASE</version>
           </dependency>
           <dependency>
               <groupId>org.apache.dubbo</groupId>
               <artifactId>dubbo-spring-boot-starter</artifactId>
               <version>3.0.3</version>
           </dependency>
           <dependency>
               <groupId>org.springframework.cloud</groupId>
               <artifactId>spring-cloud-context</artifactId>
               <version>2.2.8.RELEASE</version>
           </dependency>
       </dependencies>
   </project>
   ```
   
   application.yml
   ```
   dubbo:
     application:
       name: demo
     registry:
       protocol: multicast
       address: 224.5.6.7:1234
   string: error
   ```
   
   Application.java
   ```
   package com.example;
   
   import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
   import org.springframework.beans.factory.annotation.Value;
   import org.springframework.boot.SpringApplication;
   import org.springframework.boot.autoconfigure.SpringBootApplication;
   
   @SpringBootApplication
   //@EnableDubbo
   public class Application {
       @Value("${string}")
       private Integer value;
   
       public static void main(String[] args) {
           SpringApplication.run(Application.class, args);
       }
   }
   ```
   是否使用@EnableDubbo并不影响此现象发生,是否考虑将AwaitingNonWebApplicationListener的加载像DubboDeployApplicationListener一样与@EnableDubbo关联起来,而不是放在spring.factories中,从而保证只有初始化dubbo环境的SpringApplication才会调用此Listener
   


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] candyaaa commented on issue #7896: AwaitingNonWebApplicationListener中的ExecutorService对象未使用守护线程,导致Spring初始化异常进程仍旧运行

Posted by GitBox <gi...@apache.org>.
candyaaa commented on issue #7896:
URL: https://github.com/apache/dubbo/issues/7896#issuecomment-929947985






-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org