File tree Expand file tree Collapse file tree 5 files changed +42
-3
lines changed
slack-api-client/src/main/java/com/slack/api
main/java/com/slack/api/util/thread
test/java/test_locally/util Expand file tree Collapse file tree 5 files changed +42
-3
lines changed Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ public static ExecutorService getDefault(AuditConfig config) {
2222 }
2323
2424 public static ExecutorService getOrCreate (AuditConfig config , String enterpriseId ) {
25- String providerInstanceId = config .getExecutorServiceProvider ().toString ();
25+ String providerInstanceId = config .getExecutorServiceProvider ().getInstanceId ();
2626 Integer orgCustomPoolSize = enterpriseId != null ? config .getCustomThreadPoolSizes ().get (enterpriseId ) : null ;
2727 if (orgCustomPoolSize != null ) {
2828 return ENTERPRISE_CUSTOM
Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ public static ExecutorService getDefault(MethodsConfig config) {
2121 }
2222
2323 public static ExecutorService getOrCreate (MethodsConfig config , String teamId ) {
24- String providerInstanceId = config .getExecutorServiceProvider ().toString ();
24+ String providerInstanceId = config .getExecutorServiceProvider ().getInstanceId ();
2525 Integer teamCustomPoolSize = teamId != null ? config .getCustomThreadPoolSizes ().get (teamId ) : null ;
2626 if (teamCustomPoolSize != null ) {
2727 return TEAM_CUSTOM
Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ public static ExecutorService getDefault(SCIMConfig config) {
2222 }
2323
2424 public static ExecutorService getOrCreate (SCIMConfig config , String enterpriseId ) {
25- String providerInstanceId = config .getExecutorServiceProvider ().toString ();
25+ String providerInstanceId = config .getExecutorServiceProvider ().getInstanceId ();
2626 Integer orgCustomPoolSize = enterpriseId != null ? config .getCustomThreadPoolSizes ().get (enterpriseId ) : null ;
2727 if (orgCustomPoolSize != null ) {
2828 return ENTERPRISE_CUSTOM
Original file line number Diff line number Diff line change @@ -23,4 +23,15 @@ public interface ExecutorServiceProvider {
2323 */
2424 ScheduledExecutorService createThreadScheduledExecutor (String threadGroupName );
2525
26+ /**
27+ * Returns the unique identifier for this instance. The value must be unique among different implementations.
28+ * The default implementation is exactly the same with the default #toString() method.
29+ * The reason why we have this method is to avoid unexpected side effect
30+ * in the case where a developer customizes the #toString() method behavior.
31+ * @return an instance ID
32+ */
33+ default String getInstanceId () {
34+ return this .getClass ().getName () + "@" + Integer .toHexString (this .hashCode ());
35+ }
36+
2637}
Original file line number Diff line number Diff line change 1+ package test_locally .util ;
2+
3+ import com .slack .api .util .thread .ExecutorServiceProvider ;
4+ import org .junit .Test ;
5+
6+ import java .util .concurrent .ExecutorService ;
7+ import java .util .concurrent .ScheduledExecutorService ;
8+
9+ import static org .junit .Assert .assertTrue ;
10+
11+ public class ExecutorServiceProviderTest {
12+
13+ @ Test
14+ public void getInstanceId () {
15+ ExecutorServiceProvider provider = new ExecutorServiceProvider () {
16+ @ Override
17+ public ExecutorService createThreadPoolExecutor (String threadGroupName , int poolSize ) {
18+ return null ;
19+ }
20+
21+ @ Override
22+ public ScheduledExecutorService createThreadScheduledExecutor (String threadGroupName ) {
23+ return null ;
24+ }
25+ };
26+ assertTrue (provider .getInstanceId ().matches ("test_locally.util.ExecutorServiceProviderTest\\ $1\\ @\\ w+$" ));
27+ }
28+ }
You can’t perform that action at this time.
0 commit comments