[ 
https://issues.apache.org/jira/browse/ROCKETMQ-39?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15833316#comment-15833316
 ] 

ASF GitHub Bot commented on ROCKETMQ-39:
----------------------------------------

Github user WillemJiang commented on a diff in the pull request:

    https://github.com/apache/incubator-rocketmq/pull/34#discussion_r97214481
  
    --- Diff: 
filtersrv/src/main/java/org/apache/rocketmq/filtersrv/FiltersrvStartup.java ---
    @@ -139,7 +139,7 @@ public static FiltersrvController 
createController(String[] args) {
     
                 Runtime.getRuntime().addShutdownHook(new 
ShutdownHookThread(log, new Callable() {
                     @Override
    -                public Object call() throws Exception {
    +                public Void call() throws Exception {
                         controller.shutdown();
                         return null;
    --- End diff --
    
    @wu-sheng ,  oh, it's my mistake, I just wrote a code and the return 
statement need to be kept.
    As I'm not a big fan of null,  I always want to kill it if possible. 


> Duplicated codes in both filtersrv and namesrv modules
> ------------------------------------------------------
>
>                 Key: ROCKETMQ-39
>                 URL: https://issues.apache.org/jira/browse/ROCKETMQ-39
>             Project: Apache RocketMQ
>          Issue Type: Improvement
>          Components: rocketmq-namesrv
>            Reporter: Wu Sheng
>            Assignee: Xiaorui Wang
>            Priority: Minor
>
> In FiltersrvStartup.class and NamesrvStartup.class, exist the exact same code 
> about add jvm shutdown hook, and execute somthing on shutting down.
> Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
>                 private volatile boolean hasShutdown = false;
>                 private AtomicInteger shutdownTimes = new AtomicInteger(0);
>                 @Override
>                 public void run() {
>                     synchronized (this) {
>                         log.info("shutdown hook was invoked, " + 
> this.shutdownTimes.incrementAndGet());
>                         if (!this.hasShutdown) {
>                             this.hasShutdown = true;
>                             long begineTime = System.currentTimeMillis();
>                             controller.shutdown();
>                             long consumingTimeTotal = 
> System.currentTimeMillis() - begineTime;
>                             log.info("shutdown hook over, consuming time 
> total(ms): " + consumingTimeTotal);
>                         }
>                     }
>                 }
>             }, "ShutdownHook"));



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to