Skip to content

Commit 4fb9f5c

Browse files
committed
Allow multiple calls to SetLogHandler / SetErrorHandler / SetStatisticsHandler
1 parent 196e1b5 commit 4fb9f5c

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/Confluent.Kafka/ConsumerBuilder.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ public ConsumerBuilder<TKey, TValue> SetStatisticsHandler(
159159
{
160160
if (this.StatisticsHandler != null)
161161
{
162-
throw new InvalidOperationException("Statistics handler may not be specified more than once.");
162+
this.StatisticsHandler += statisticsHandler;
163163
}
164164
this.StatisticsHandler = statisticsHandler;
165165
return this;
@@ -182,7 +182,7 @@ public ConsumerBuilder<TKey, TValue> SetErrorHandler(
182182
{
183183
if (this.ErrorHandler != null)
184184
{
185-
throw new InvalidOperationException("Error handler may not be specified more than once.");
185+
this.ErrorHandler += errorHandler;
186186
}
187187
this.ErrorHandler = errorHandler;
188188
return this;
@@ -212,7 +212,7 @@ public ConsumerBuilder<TKey, TValue> SetLogHandler(
212212
{
213213
if (this.LogHandler != null)
214214
{
215-
throw new InvalidOperationException("Log handler may not be specified more than once.");
215+
this.LogHandler += logHandler;
216216
}
217217
this.LogHandler = logHandler;
218218
return this;

src/Confluent.Kafka/ProducerBuilder.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ public ProducerBuilder<TKey, TValue> SetStatisticsHandler(Action<IProducer<TKey,
169169
{
170170
if (this.StatisticsHandler != null)
171171
{
172-
throw new InvalidOperationException("Statistics handler may not be specified more than once.");
172+
this.StatisticsHandler += statisticsHandler;
173173
}
174174
this.StatisticsHandler = statisticsHandler;
175175
return this;
@@ -224,7 +224,7 @@ public ProducerBuilder<TKey, TValue> SetErrorHandler(Action<IProducer<TKey, TVal
224224
{
225225
if (this.ErrorHandler != null)
226226
{
227-
throw new InvalidOperationException("Error handler may not be specified more than once.");
227+
this.ErrorHandler += errorHandler;
228228
}
229229
this.ErrorHandler = errorHandler;
230230
return this;
@@ -253,7 +253,7 @@ public ProducerBuilder<TKey, TValue> SetLogHandler(Action<IProducer<TKey, TValue
253253
{
254254
if (this.LogHandler != null)
255255
{
256-
throw new InvalidOperationException("Log handler may not be specified more than once.");
256+
this.LogHandler += logHandler;
257257
}
258258
this.LogHandler = logHandler;
259259
return this;

0 commit comments

Comments
 (0)