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

[GitHub] [kafka] pierDipi commented on a diff in pull request #13325: KAFKA-14771: Include threads info in ConcurrentModificationException message

pierDipi commented on code in PR #13325:
URL: https://github.com/apache/kafka/pull/13325#discussion_r1155728488


##########
clients/src/main/java/org/apache/kafka/clients/consumer/KafkaConsumer.java:
##########
@@ -2547,9 +2547,13 @@ private void acquireAndEnsureOpen() {
      * @throws ConcurrentModificationException if another thread already has the lock
      */
     private void acquire() {
-        long threadId = Thread.currentThread().getId();
+        final Thread thread = Thread.currentThread();
+        final long threadId = thread.getId();
         if (threadId != currentThread.get() && !currentThread.compareAndSet(NO_CURRENT_THREAD, threadId))
-            throw new ConcurrentModificationException("KafkaConsumer is not safe for multi-threaded access");
+            throw new ConcurrentModificationException("KafkaConsumer is not safe for multi-threaded access. " +
+                    "currentThread(name: " + thread.getName() + ", id: " + thread.getId() + ")" +

Review Comment:
   ```suggestion
                       "currentThread(name: " + thread.getName() + ", id: " + threadId + ")" +
   ```



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