You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2022/07/28 00:20:50 UTC

[GitHub] [flink] mas-chen commented on a diff in pull request #19654: [FLINK-27529][connector/common] Replace HybridSourceSplitEnumerator readerSourceIndex to safely Integer check

mas-chen commented on code in PR #19654:
URL: https://github.com/apache/flink/pull/19654#discussion_r931679580


##########
flink-connectors/flink-connector-base/src/main/java/org/apache/flink/connector/base/source/hybrid/HybridSourceSplitEnumerator.java:
##########
@@ -355,7 +355,8 @@ public Map<Integer, ReaderInfo> registeredReaders() {
         private Map<Integer, ReaderInfo> filterRegisteredReaders(Map<Integer, ReaderInfo> readers) {
             Map<Integer, ReaderInfo> readersForSource = new HashMap<>(readers.size());
             for (Map.Entry<Integer, ReaderInfo> e : readers.entrySet()) {
-                if (readerSourceIndex.get(e.getKey()) == (Integer) sourceIndex) {
+                // readerSourceIndex get value could be null

Review Comment:
   You can simplify it as: readerSourceIndex.get(e.getKey())).equals(sourceIndex)
   
   There are other instances where we should use `.equals` instead of `==`. e.g. https://github.com/apache/flink/blob/5c87b69b5300e8678629aa8b769d60ec2fdbf3d1/flink-connectors/flink-connector-base/src/main/java/org/apache/flink/connector/base/source/hybrid/HybridSourceSplitEnumerator.java#L167
   
   Can you do another pass here and fix the relevant spots in the code?



-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org