You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "Debraj Manna (Jira)" <ji...@apache.org> on 2021/11/26 12:05:00 UTC

[jira] [Comment Edited] (KAFKA-12791) ConcurrentModificationException in KafkaProducer constructor

    [ https://issues.apache.org/jira/browse/KAFKA-12791?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17449532#comment-17449532 ] 

Debraj Manna edited comment on KAFKA-12791 at 11/26/21, 12:04 PM:
------------------------------------------------------------------

The fix is released in Kafka 3.0. Can this be resolved now?

https://github.com/apache/kafka/blob/3.0.0/clients/src/main/java/org/apache/kafka/common/config/AbstractConfig.java


was (Author: tuk):
The fix is released in Kafka 3.0. Can this be resolved now?

> ConcurrentModificationException in KafkaProducer constructor
> ------------------------------------------------------------
>
>                 Key: KAFKA-12791
>                 URL: https://issues.apache.org/jira/browse/KAFKA-12791
>             Project: Kafka
>          Issue Type: Bug
>            Reporter: Lucas Bradstreet
>            Priority: Minor
>
> Recently we have noticed multiple instances where KafkaProducers have failed to constructe due to the following exception:
> {noformat}
> org.apache.kafka.common.KafkaException: Failed to construct kafka producer at org.apache.kafka.clients.producer.KafkaProducer.<init>(KafkaProducer.java:440) at org.apache.kafka.clients.producer.KafkaProducer.<init>(KafkaProducer.java:291) at org.apache.kafka.clients.producer.KafkaProducer.<init>(KafkaProducer.java:318) java.base/java.lang.Thread.run(Thread.java:832) Caused by: java.util.ConcurrentModificationException at java.base/java.util.HashMap$HashIterator.nextNode(HashMap.java:1584) at java.base/java.util.HashMap$KeyIterator.next(HashMap.java:1607) at java.base/java.util.AbstractSet.removeAll(AbstractSet.java:171) at org.apache.kafka.common.config.AbstractConfig.unused(AbstractConfig.java:221) at org.apache.kafka.common.config.AbstractConfig.logUnused(AbstractConfig.java:379) at org.apache.kafka.clients.producer.KafkaProducer.<init>(KafkaProducer.java:433) ... 9 more exception.class:org.apache.kafka.common.KafkaException exception.message:Failed to construct kafka producer
> {noformat}
> It appears that this is due to the fact that `used` below is a synchronized set:
>  
> {code:java}
> public Set<String> unused() {
>  Set<String> keys = new HashSet<>(originals.keySet());
>  keys.removeAll(used);
>  return keys;
> }{code}
> It appears that `used` is being modified while removeAll is being called. This may be due to the way that keys are added to it when used:
> {code:java}
> protected Object get(String key) {
>  if (!values.containsKey(key))
>  throw new ConfigException(String.format("Unknown configuration '%s'", key));
>  used.add(key);
>  return values.get(key);
> }{code}
>  



--
This message was sent by Atlassian Jira
(v8.20.1#820001)