소스 검색

优化代码

everywhere.z 1 년 전
부모
커밋
252c81dd15
1개의 변경된 파일4개의 추가작업 그리고 4개의 파일을 삭제
  1. 4 4
      liteflow-rule-plugin/liteflow-rule-sql/src/main/java/com/yomahub/liteflow/parser/sql/read/SqlReadFactory.java

+ 4 - 4
liteflow-rule-plugin/liteflow-rule-sql/src/main/java/com/yomahub/liteflow/parser/sql/read/SqlReadFactory.java

@@ -23,16 +23,16 @@ public class SqlReadFactory {
     private static final Map<ReadType, SqlReadPollTask> POLL_TASK_MAP = new HashMap<>();
 
     public static void registerRead(SQLParserVO config) {
-        READ_MAP.put(ReadType.CHAIN, new ChainRead(config));
-        READ_MAP.put(ReadType.SCRIPT, new ScriptRead(config));
+        READ_MAP.putIfAbsent(ReadType.CHAIN, new ChainRead(config));
+        READ_MAP.putIfAbsent(ReadType.SCRIPT, new ScriptRead(config));
     }
 
     public static void registerSqlReadPollTask(ReadType readType) {
         SqlRead sqlRead = getSqlRead(readType);
         if (ReadType.CHAIN.equals(readType)) {
-            POLL_TASK_MAP.put(ReadType.CHAIN, new ChainReadPollTask(sqlRead));
+            POLL_TASK_MAP.putIfAbsent(ReadType.CHAIN, new ChainReadPollTask(sqlRead));
         } else if (ReadType.SCRIPT.equals(readType)) {
-            POLL_TASK_MAP.put(ReadType.SCRIPT, new ScriptReadPollTask(sqlRead));
+            POLL_TASK_MAP.putIfAbsent(ReadType.SCRIPT, new ScriptReadPollTask(sqlRead));
         }
     }