You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by GitBox <gi...@apache.org> on 2020/03/09 10:24:14 UTC

[GitHub] [druid] leventov opened a new issue #9482: An ExecutorService must not be created for each KerberosHttpClient; Don't assign ExecutorService into variable of Executor type

leventov opened a new issue #9482: An ExecutorService must not be created for each KerberosHttpClient; Don't assign ExecutorService into variable of Executor type
URL: https://github.com/apache/druid/issues/9482
 
 
   Similarly to #9286, we should catch assignments of `ExecutorService` (within type hierarchy) into variables of `Executor` type.
   
   Two Structural search patterns are needed:
    - "Java" pattern: `$x$ = $y$;`, where the Type of `$x$` is `Executor` and the Type of `$y$` is `ExecutorService`.
    - "Java - Class Member" pattern: `$Type$ $x$ = $y$;`, where the Text of `$Type$` is `Executor` and the Type of `$y$` is `ExecutorService`.
   
   (BTW, there is only "Java" pattern suggested in #9286 and added in #9325; a similar "Java - Class Member" pattern should be added for `ExecutorService` - `ScheduledExecutorService` pair, too.)
   
   This is needed because [`ExecutorService` instances must be shut down explicitly](https://github.com/code-review-checklists/java-concurrency#explicit-shutdown) and `Executor` doesn't allow for this.
   
   Incidentally, the sole violation of this rule in Druid code, in `KerberosHttpClient`:
   
   https://github.com/apache/druid/blob/a6776648112917b72c077ba3ac0cb7f61993a2d0/extensions-core/druid-kerberos/src/main/java/org/apache/druid/security/kerberos/KerberosHttpClient.java#L44-L54
   
   Is actually an instance of another Java concurrency problem: [an `ExecutorService` must not be created for each instance of a short-lived object](https://github.com/code-review-checklists/java-concurrency#reuse-threads) like `KerberosHttpClient`. So the `exec` in `KerberosHttpClient` should properly made static, or cached on the DI level as a `@Named` `ExecutorService`.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org