flowers-59f commented on code in PR #12107:
URL: https://github.com/apache/inlong/pull/12107#discussion_r3314916104


##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/group/InlongGroupServiceImpl.java:
##########
@@ -215,7 +215,27 @@ public String save(InlongGroupRequest request, String 
operator) {
         if (request.getEnableZookeeper() == null) {
             request.setEnableZookeeper(enableZookeeper ? 
InlongConstants.ENABLE_ZK : InlongConstants.DISABLE_ZK);
         }
-        InlongGroupOperator instance = 
groupOperatorFactory.getInstance(request.getMqType());
+
+        if (request.getEnableCreateResource() == null) {
+            
request.setEnableCreateResource(InlongConstants.ENABLE_CREATE_RESOURCE);
+        }
+
+        if (request.getInlongGroupMode() == null) {
+            request.setInlongGroupMode(InlongConstants.STANDARD_MODE);

Review Comment:
   Yes. The database will assign a default value to this field when no value is 
set. However, it may also be assigned another value, so I think we still need 
to add a judgment here.But we can remove the code that sets the default value 
and adjust the judgment logic as follows.
   ```java
   if ((request.getInlongGroupMode() == null || 
InlongConstants.STANDARD_MODE.equals(request.getInlongGroupMode()))  
   && (request.getEnableCreateResource() == null || 
InlongConstants.ENABLE_CREATE_RESOURCE.equals(request.getEnableCreateResource())))
 {
       String clusterTag = request.getInlongClusterTag();
       List<InlongClusterEntity> clusterEntities = 
clusterEntityMapper.selectByKey(clusterTag, null, mqType);
       if (CollectionUtils.isEmpty(clusterEntities)) {
            throw new BusinessException(String.format("cannot find any cluster 
by tag %s and type %s",
            clusterTag, mqType));
       }
   }
   ```
   Here's my opinion.
   
   Or, there's no need to set a default value and verify GroupMode and 
EnableCreateResource. Just proceed directly with the following checks.
   ```java
   String clusterTag = request.getInlongClusterTag();
   List<InlongClusterEntity> clusterEntities = 
clusterEntityMapper.selectByKey(clusterTag, null, mqType);
   if (CollectionUtils.isEmpty(clusterEntities)) {
        throw new BusinessException(String.format("cannot find any cluster by 
tag %s and type %s",
        clusterTag, mqType));
   }
   ```



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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to