You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2020/10/09 01:21:19 UTC

[GitHub] [shardingsphere-elasticjob] TeslaCN commented on a change in pull request #1547: Redesign SPI factory to make them into one class (#1537)

TeslaCN commented on a change in pull request #1547:
URL: https://github.com/apache/shardingsphere-elasticjob/pull/1547#discussion_r502119684



##########
File path: elasticjob-infra/elasticjob-infra-common/src/main/java/org/apache/shardingsphere/elasticjob/infra/listener/ElasticJobListenerFactory.java
##########
@@ -40,6 +40,6 @@
      * @return optional job listener instance
      */
     public static Optional<ElasticJobListener> createListener(final String type) {
-        return ElasticJobServiceLoader.newServiceInstances(ElasticJobListener.class).stream().filter(listener -> listener.getType().equalsIgnoreCase(type)).findFirst();
+        return Optional.of(ElasticJobServiceLoader.newTypedServiceInstance(ElasticJobListener.class, type));

Review comment:
       `Optional.of()` will throw exception if parameter is null, which makes caller invoke `orElseThrow` is meaningless.

##########
File path: elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-general/src/main/java/org/apache/shardingsphere/elasticjob/error/handler/JobErrorHandlerFactory.java
##########
@@ -48,8 +48,8 @@
         }
         return newHandlerInstance(type);
     }
-    

Review comment:
       Keep indents (including blank lines) consistent with the previous one, please.
   Ref https://shardingsphere.apache.org/community/en/contribute/code-conduct/




----------------------------------------------------------------
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