gong commented on code in PR #6193:
URL: https://github.com/apache/inlong/pull/6193#discussion_r996595788


##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/sink/StreamSinkServiceImpl.java:
##########
@@ -97,18 +96,18 @@ public Integer save(SinkRequest request, String operator) {
         String groupId = request.getInlongGroupId();
         groupCheckService.checkGroupStatus(groupId, operator);
 
-        // Make sure that there is no sink info with the current groupId and 
streamId
+        // Make sure that there is no same sink name under the current groupId 
and streamId
         String streamId = request.getInlongStreamId();
         String sinkName = request.getSinkName();
         // Check whether the stream exist or not
         InlongStreamEntity streamEntity = 
streamMapper.selectByIdentifier(groupId, streamId);
         Preconditions.checkNotNull(streamEntity, 
ErrorCodeEnum.STREAM_NOT_FOUND.getMessage());
-        List<StreamSinkEntity> sinkList = 
sinkMapper.selectByRelatedId(groupId, streamId, sinkName);
-        for (StreamSinkEntity sinkEntity : sinkList) {
-            if (sinkEntity != null && Objects.equals(sinkEntity.getSinkName(), 
sinkName)) {
-                String err = "sink name=%s already exists with the groupId=%s 
streamId=%s";
-                throw new BusinessException(String.format(err, sinkName, 
groupId, streamId));
-            }
+
+        // Check whether the sink name exists with the same groupId and 
streamId
+        StreamSinkEntity exists = sinkMapper.selectByUniqueKey(groupId, 
streamId, sinkName);
+        if (exists != null && exists.getSinkName().equals(sinkName)) {
+            String err = "sink name=%s already exists with the groupId=%s 
streamId=%s";

Review Comment:
   It would throw exception if `exists.getSinkName()` is null



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