You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "jamespfaulkner (via GitHub)" <gi...@apache.org> on 2023/12/07 09:52:44 UTC

[PR] Bugfix: Prevent java.lang.UnsupportedOperationException. [kafka]

jamespfaulkner opened a new pull request, #14955:
URL: https://github.com/apache/kafka/pull/14955

   `logDirDescription.replicaInfos()` returns an `UnmodifiableMap` causing the call to `put` to result in an UnsupportedOperationException.
   
   ### Committer Checklist (excluded from commit message)
   - [ ] Verify design and implementation 
   - [ ] Verify test coverage and CI build status
   - [ ] Verify documentation (including upgrade notes)
   


-- 
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: jira-unsubscribe@kafka.apache.org

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


Re: [PR] Bugfix: Prevent java.lang.UnsupportedOperationException. [kafka]

Posted by "vamossagar12 (via GitHub)" <gi...@apache.org>.
vamossagar12 commented on PR #14955:
URL: https://github.com/apache/kafka/pull/14955#issuecomment-1874218869

   @divijvaidya , do you mind taking a look at this one? Once the checkstyles are fixed, It looks good to go from my side (will approve once the changes are made).


-- 
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: jira-unsubscribe@kafka.apache.org

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


Re: [PR] MINOR: Prevent java.lang.UnsupportedOperationException in MockAdminClient [kafka]

Posted by "divijvaidya (via GitHub)" <gi...@apache.org>.
divijvaidya merged PR #14955:
URL: https://github.com/apache/kafka/pull/14955


-- 
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: jira-unsubscribe@kafka.apache.org

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


Re: [PR] Bugfix: Prevent java.lang.UnsupportedOperationException. [kafka]

Posted by "vamossagar12 (via GitHub)" <gi...@apache.org>.
vamossagar12 commented on code in PR #14955:
URL: https://github.com/apache/kafka/pull/14955#discussion_r1439583795


##########
clients/src/test/java/org/apache/kafka/clients/admin/MockAdminClient.java:
##########
@@ -1014,7 +1014,9 @@ synchronized public DescribeLogDirsResult describeLogDirs(Collection<Integer> br
                 for (Node node : nodes) {
                     Map<String, LogDirDescription> logDirDescriptionMap = unwrappedResults.get(node.id());
                     LogDirDescription logDirDescription = logDirDescriptionMap.getOrDefault(partitionLogDirs.get(0), new LogDirDescription(null, new HashMap<>()));
-                    logDirDescription.replicaInfos().put(new TopicPartition(topicName, topicPartitionInfo.partition()), new ReplicaInfo(0, 0, false));
+                    Map<TopicPartition, ReplicaInfo> topicPartitionReplicaInfoMap = new HashMap<>(logDirDescription.replicaInfos());
+                    topicPartitionReplicaInfoMap.put(new TopicPartition(topicName, topicPartitionInfo.partition()), new ReplicaInfo(0, 0, false));
+                    logDirDescriptionMap.put(partitionLogDirs.get(0), new LogDirDescription(logDirDescription.error(), topicPartitionReplicaInfoMap));

Review Comment:
   Thanks



-- 
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: jira-unsubscribe@kafka.apache.org

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


Re: [PR] Bugfix: Prevent java.lang.UnsupportedOperationException. [kafka]

Posted by "vamossagar12 (via GitHub)" <gi...@apache.org>.
vamossagar12 commented on code in PR #14955:
URL: https://github.com/apache/kafka/pull/14955#discussion_r1438796599


##########
clients/src/test/java/org/apache/kafka/clients/admin/MockAdminClient.java:
##########
@@ -1014,7 +1014,9 @@ synchronized public DescribeLogDirsResult describeLogDirs(Collection<Integer> br
                 for (Node node : nodes) {
                     Map<String, LogDirDescription> logDirDescriptionMap = unwrappedResults.get(node.id());
                     LogDirDescription logDirDescription = logDirDescriptionMap.getOrDefault(partitionLogDirs.get(0), new LogDirDescription(null, new HashMap<>()));
-                    logDirDescription.replicaInfos().put(new TopicPartition(topicName, topicPartitionInfo.partition()), new ReplicaInfo(0, 0, false));
+                    Map<TopicPartition, ReplicaInfo> topicPartitionReplicaInfoMap = new HashMap<>(logDirDescription.replicaInfos());
+                    topicPartitionReplicaInfoMap.put(new TopicPartition(topicName, topicPartitionInfo.partition()), new ReplicaInfo(0, 0, false));
+                    logDirDescriptionMap.put(partitionLogDirs.get(0), new LogDirDescription(logDirDescription.error(), topicPartitionReplicaInfoMap));

Review Comment:
   Instead of setting unknown bytes for `totalBytes` and `usableBytes` for the new `LogDirDescription` object, I think we should use the `totalBytes` and `usableBytes` as well from the existing `LogDirDescription` object.



-- 
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: jira-unsubscribe@kafka.apache.org

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


Re: [PR] Bugfix: Prevent java.lang.UnsupportedOperationException. [kafka]

Posted by "jamespfaulkner (via GitHub)" <gi...@apache.org>.
jamespfaulkner commented on code in PR #14955:
URL: https://github.com/apache/kafka/pull/14955#discussion_r1439519451


##########
clients/src/test/java/org/apache/kafka/clients/admin/MockAdminClient.java:
##########
@@ -1014,7 +1014,9 @@ synchronized public DescribeLogDirsResult describeLogDirs(Collection<Integer> br
                 for (Node node : nodes) {
                     Map<String, LogDirDescription> logDirDescriptionMap = unwrappedResults.get(node.id());
                     LogDirDescription logDirDescription = logDirDescriptionMap.getOrDefault(partitionLogDirs.get(0), new LogDirDescription(null, new HashMap<>()));
-                    logDirDescription.replicaInfos().put(new TopicPartition(topicName, topicPartitionInfo.partition()), new ReplicaInfo(0, 0, false));
+                    Map<TopicPartition, ReplicaInfo> topicPartitionReplicaInfoMap = new HashMap<>(logDirDescription.replicaInfos());
+                    topicPartitionReplicaInfoMap.put(new TopicPartition(topicName, topicPartitionInfo.partition()), new ReplicaInfo(0, 0, false));
+                    logDirDescriptionMap.put(partitionLogDirs.get(0), new LogDirDescription(logDirDescription.error(), topicPartitionReplicaInfoMap));

Review Comment:
   Good point, thanks for the feedback. I've made this change.



-- 
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: jira-unsubscribe@kafka.apache.org

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


Re: [PR] MINOR: Prevent java.lang.UnsupportedOperationException in MockAdminClient [kafka]

Posted by "divijvaidya (via GitHub)" <gi...@apache.org>.
divijvaidya commented on PR #14955:
URL: https://github.com/apache/kafka/pull/14955#issuecomment-1877769128

   JDK 8 tests are all successful and other failing tests don't look related


-- 
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: jira-unsubscribe@kafka.apache.org

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


Re: [PR] MINOR: Prevent java.lang.UnsupportedOperationException in MockAdminClient [kafka]

Posted by "vamossagar12 (via GitHub)" <gi...@apache.org>.
vamossagar12 commented on PR #14955:
URL: https://github.com/apache/kafka/pull/14955#issuecomment-1875226073

   > Looks good! Out of curiosity, do you happen to know tests which are failing with this UnsupportedOperationException?
   
   yeah even I was interested to know this.


-- 
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: jira-unsubscribe@kafka.apache.org

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


Re: [PR] MINOR: Prevent java.lang.UnsupportedOperationException in MockAdminClient [kafka]

Posted by "jamespfaulkner (via GitHub)" <gi...@apache.org>.
jamespfaulkner commented on PR #14955:
URL: https://github.com/apache/kafka/pull/14955#issuecomment-1875517539

   > Looks good! Out of curiosity, do you happen to know tests which are failing with this UnsupportedOperationException?
   
   Ah, sorry I missed this question first time round. I have a small app that constantly polls the `describeLogDirs`. When I saw the `MockAdminClient` had changed it's implementation of `describeLogDirs` to no longer immediately throw a `UnsupportedOperationException` I took the opportunity to improve my tests and spotted this 😄.


-- 
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: jira-unsubscribe@kafka.apache.org

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