[ 
https://issues.apache.org/jira/browse/KAFKA-7208?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Sean Policarpio updated KAFKA-7208:
-----------------------------------
    Description: 
The following exception is thrown from the Kafka server when an 
AlterConfigsRequest API request is made via the binary protocol where the 
CONFIG_ENTRY's CONFIG_VALUE is set to null:
{noformat}
[2018-07-26 15:53:01,487] ERROR [Admin Manager on Broker 1000]: Error 
processing alter configs request for resource Resource(type=TOPIC, name='foo'}, 
config org.apache.kafka.common.requests.AlterConfigsRequest$Config@692d8300 
(kafka.server.AdminManager)
java.lang.NullPointerException
        at java.util.Hashtable.put(Hashtable.java:459)
        at java.util.Properties.setProperty(Properties.java:166)
        at 
kafka.server.AdminManager$$anonfun$alterConfigs$1$$anonfun$apply$18.apply(AdminManager.scala:357)
        at 
kafka.server.AdminManager$$anonfun$alterConfigs$1$$anonfun$apply$18.apply(AdminManager.scala:356)
        at scala.collection.Iterator$class.foreach(Iterator.scala:891)
        at scala.collection.AbstractIterator.foreach(Iterator.scala:1334)
        at scala.collection.IterableLike$class.foreach(IterableLike.scala:72)
        at scala.collection.AbstractIterable.foreach(Iterable.scala:54)
        at 
kafka.server.AdminManager$$anonfun$alterConfigs$1.apply(AdminManager.scala:356)
        at 
kafka.server.AdminManager$$anonfun$alterConfigs$1.apply(AdminManager.scala:339)
        at 
scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:234)
        at 
scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:234)
        at scala.collection.Iterator$class.foreach(Iterator.scala:891)
        at scala.collection.AbstractIterator.foreach(Iterator.scala:1334)
        at scala.collection.IterableLike$class.foreach(IterableLike.scala:72)
        at scala.collection.AbstractIterable.foreach(Iterable.scala:54)
        at scala.collection.TraversableLike$class.map(TraversableLike.scala:234)
        at scala.collection.AbstractTraversable.map(Traversable.scala:104)
        at kafka.server.AdminManager.alterConfigs(AdminManager.scala:339)
        at 
kafka.server.KafkaApis.handleAlterConfigsRequest(KafkaApis.scala:1994)
        at kafka.server.KafkaApis.handle(KafkaApis.scala:143)
        at kafka.server.KafkaRequestHandler.run(KafkaRequestHandler.scala:69)
        at java.lang.Thread.run(Thread.java:745)
{noformat}
As a first guess, I'd say the issue is happening 
[here|https://github.com/apache/kafka/blob/49db5a63c043b50c10c2dfd0648f8d74ee917b6a/core/src/main/scala/kafka/server/AdminManager.scala#L361],
 since HashTable/Property can't take a null value.

The reason I'm sending a null for the configuration value is I assumed that 
since the API documentation says that the value is nullable (see 
[here|http://kafka.apache.org/protocol.html#The_Messages_AlterConfigs] and 
[here|https://github.com/apache/kafka/blob/49db5a63c043b50c10c2dfd0648f8d74ee917b6a/clients/src/main/java/org/apache/kafka/common/requests/AlterConfigsRequest.java#L53]),
 this meant the (override) configuration itself would be deleted when a null 
value was received.

Contradictory to that, I did notice null checks throughout the code, like 
[here|https://github.com/apache/kafka/blob/49db5a63c043b50c10c2dfd0648f8d74ee917b6a/clients/src/main/java/org/apache/kafka/common/requests/AlterConfigsRequest.java#L92].

If null is in fact not meant to be accepted by the binary API, this probably 
needs to be addressed at the protocol level. Further to that, can someone show 
me how to then remove a configuration override via the binary API?

For clarity sake, here's what my request looked like (pseudo/Rust):
{noformat}
AlterConfigsRequest {
  resources: [
    Resource
    {
      resource_type: 2,
      resource_name: "foo",
      config_entries: [
        ConfigEntry
        {
          config_name: "file.delete.delay.ms",
          config_value: None // serialized as a 16-bit '-1'
        }
      ]
    }
  ],
  validate_only: false
}
{noformat}
 

  was:
The following exception is thrown from the Kafka server when an 
AlterConfigsRequest API request is made via the binary protocol where the 
CONFIG_ENTRY's CONFIG_VALUE is set to null:
{noformat}
[2018-07-26 15:53:01,487] ERROR [Admin Manager on Broker 1000]: Error 
processing alter configs request for resource Resource(type=TOPIC, name='foo'}, 
config org.apache.kafka.common.requests.AlterConfigsRequest$Config@692d8300 
(kafka.server.AdminManager)
java.lang.NullPointerException
        at java.util.Hashtable.put(Hashtable.java:459)
        at java.util.Properties.setProperty(Properties.java:166)
        at 
kafka.server.AdminManager$$anonfun$alterConfigs$1$$anonfun$apply$18.apply(AdminManager.scala:357)
        at 
kafka.server.AdminManager$$anonfun$alterConfigs$1$$anonfun$apply$18.apply(AdminManager.scala:356)
        at scala.collection.Iterator$class.foreach(Iterator.scala:891)
        at scala.collection.AbstractIterator.foreach(Iterator.scala:1334)
        at scala.collection.IterableLike$class.foreach(IterableLike.scala:72)
        at scala.collection.AbstractIterable.foreach(Iterable.scala:54)
        at 
kafka.server.AdminManager$$anonfun$alterConfigs$1.apply(AdminManager.scala:356)
        at 
kafka.server.AdminManager$$anonfun$alterConfigs$1.apply(AdminManager.scala:339)
        at 
scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:234)
        at 
scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:234)
        at scala.collection.Iterator$class.foreach(Iterator.scala:891)
        at scala.collection.AbstractIterator.foreach(Iterator.scala:1334)
        at scala.collection.IterableLike$class.foreach(IterableLike.scala:72)
        at scala.collection.AbstractIterable.foreach(Iterable.scala:54)
        at scala.collection.TraversableLike$class.map(TraversableLike.scala:234)
        at scala.collection.AbstractTraversable.map(Traversable.scala:104)
        at kafka.server.AdminManager.alterConfigs(AdminManager.scala:339)
        at 
kafka.server.KafkaApis.handleAlterConfigsRequest(KafkaApis.scala:1994)
        at kafka.server.KafkaApis.handle(KafkaApis.scala:143)
        at kafka.server.KafkaRequestHandler.run(KafkaRequestHandler.scala:69)
        at java.lang.Thread.run(Thread.java:745)
{noformat}
As a first guess, I'd say the issue is happening 
[here|https://github.com/apache/kafka/blob/49db5a63c043b50c10c2dfd0648f8d74ee917b6a/core/src/main/scala/kafka/server/AdminManager.scala#L361],
 since HashTable/Property can't take a null value.

The reason I'm sending a null for the configuration value is I assumed that 
since the API documentation says that the value is nullable (see 
[here|http://kafka.apache.org/protocol.html#The_Messages_AlterConfigs] and 
[here|https://github.com/apache/kafka/blob/49db5a63c043b50c10c2dfd0648f8d74ee917b6a/clients/src/main/java/org/apache/kafka/common/requests/AlterConfigsRequest.java#L53]),
 this meant the (override) configuration itself would be deleted when a null 
value was received.

Contradictory to that, I did notice null checks throughout the code, like 
[here|https://github.com/apache/kafka/blob/49db5a63c043b50c10c2dfd0648f8d74ee917b6a/clients/src/main/java/org/apache/kafka/common/requests/AlterConfigsRequest.java#L92].

If null is in fact not meant to be accepted by the binary API, this probably 
needs to be addressed at the protocol level. Further to that, can someone show 
me how to then remove a configuration override via the binary API?

For clarity sake, here's what my request looked like (pseudo/Rust):
{noformat}
AlterConfigsRequest { 
  resources: [ 
    Resource { 
      resource_type: 2, 
      resource_name: "foo", 
      config_entries: [ 
        ConfigEntry { 
          config_name: "file.delete.delay.ms", 
          config_value: None // serialized as a 16-bit '-1' 
        } 
       ] 
      } 
     ], 
     validate_only: false 
}
{noformat}
 


> AlterConfigsRequest with null config value throws NullPointerException
> ----------------------------------------------------------------------
>
>                 Key: KAFKA-7208
>                 URL: https://issues.apache.org/jira/browse/KAFKA-7208
>             Project: Kafka
>          Issue Type: Bug
>          Components: admin, config, core
>    Affects Versions: 1.1.1
>            Reporter: Sean Policarpio
>            Priority: Major
>
> The following exception is thrown from the Kafka server when an 
> AlterConfigsRequest API request is made via the binary protocol where the 
> CONFIG_ENTRY's CONFIG_VALUE is set to null:
> {noformat}
> [2018-07-26 15:53:01,487] ERROR [Admin Manager on Broker 1000]: Error 
> processing alter configs request for resource Resource(type=TOPIC, 
> name='foo'}, config 
> org.apache.kafka.common.requests.AlterConfigsRequest$Config@692d8300 
> (kafka.server.AdminManager)
> java.lang.NullPointerException
>       at java.util.Hashtable.put(Hashtable.java:459)
>       at java.util.Properties.setProperty(Properties.java:166)
>       at 
> kafka.server.AdminManager$$anonfun$alterConfigs$1$$anonfun$apply$18.apply(AdminManager.scala:357)
>       at 
> kafka.server.AdminManager$$anonfun$alterConfigs$1$$anonfun$apply$18.apply(AdminManager.scala:356)
>       at scala.collection.Iterator$class.foreach(Iterator.scala:891)
>       at scala.collection.AbstractIterator.foreach(Iterator.scala:1334)
>       at scala.collection.IterableLike$class.foreach(IterableLike.scala:72)
>       at scala.collection.AbstractIterable.foreach(Iterable.scala:54)
>       at 
> kafka.server.AdminManager$$anonfun$alterConfigs$1.apply(AdminManager.scala:356)
>       at 
> kafka.server.AdminManager$$anonfun$alterConfigs$1.apply(AdminManager.scala:339)
>       at 
> scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:234)
>       at 
> scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:234)
>       at scala.collection.Iterator$class.foreach(Iterator.scala:891)
>       at scala.collection.AbstractIterator.foreach(Iterator.scala:1334)
>       at scala.collection.IterableLike$class.foreach(IterableLike.scala:72)
>       at scala.collection.AbstractIterable.foreach(Iterable.scala:54)
>       at scala.collection.TraversableLike$class.map(TraversableLike.scala:234)
>       at scala.collection.AbstractTraversable.map(Traversable.scala:104)
>       at kafka.server.AdminManager.alterConfigs(AdminManager.scala:339)
>       at 
> kafka.server.KafkaApis.handleAlterConfigsRequest(KafkaApis.scala:1994)
>       at kafka.server.KafkaApis.handle(KafkaApis.scala:143)
>       at kafka.server.KafkaRequestHandler.run(KafkaRequestHandler.scala:69)
>       at java.lang.Thread.run(Thread.java:745)
> {noformat}
> As a first guess, I'd say the issue is happening 
> [here|https://github.com/apache/kafka/blob/49db5a63c043b50c10c2dfd0648f8d74ee917b6a/core/src/main/scala/kafka/server/AdminManager.scala#L361],
>  since HashTable/Property can't take a null value.
> The reason I'm sending a null for the configuration value is I assumed that 
> since the API documentation says that the value is nullable (see 
> [here|http://kafka.apache.org/protocol.html#The_Messages_AlterConfigs] and 
> [here|https://github.com/apache/kafka/blob/49db5a63c043b50c10c2dfd0648f8d74ee917b6a/clients/src/main/java/org/apache/kafka/common/requests/AlterConfigsRequest.java#L53]),
>  this meant the (override) configuration itself would be deleted when a null 
> value was received.
> Contradictory to that, I did notice null checks throughout the code, like 
> [here|https://github.com/apache/kafka/blob/49db5a63c043b50c10c2dfd0648f8d74ee917b6a/clients/src/main/java/org/apache/kafka/common/requests/AlterConfigsRequest.java#L92].
> If null is in fact not meant to be accepted by the binary API, this probably 
> needs to be addressed at the protocol level. Further to that, can someone 
> show me how to then remove a configuration override via the binary API?
> For clarity sake, here's what my request looked like (pseudo/Rust):
> {noformat}
> AlterConfigsRequest {
>   resources: [
>     Resource
>     {
>       resource_type: 2,
>       resource_name: "foo",
>       config_entries: [
>         ConfigEntry
>         {
>           config_name: "file.delete.delay.ms",
>           config_value: None // serialized as a 16-bit '-1'
>         }
>       ]
>     }
>   ],
>   validate_only: false
> }
> {noformat}
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to