Skip to content

Commit 80c58e8

Browse files
Do null checking on partition instead of checking falsiness (#24)
1 parent 740344c commit 80c58e8

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/producer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ function Producer(conf, topicConf) {
7575
this.globalConfig = conf;
7676
this.topicConfig = topicConf;
7777
this.defaultTopic = gTopic || null;
78-
this.defaultPartition = gPart || null;
78+
this.defaultPartition = gPart == null ? -1 : gPart;
7979

8080
this.outstandingMessages = 0;
8181
this.sentMessages = 0;
@@ -189,7 +189,7 @@ Producer.prototype.produceSync = function(msg) {
189189
this.sentMessages++;
190190

191191
var topic = msg.topic || false;
192-
var partition = msg.partition || this.defaultPartition;
192+
var partition = msg.partition == null ? this.defaultPartition : msg.partition;
193193

194194
if (!topic) {
195195
throw new TypeError('"topic" needs to be set');

0 commit comments

Comments
 (0)