@@ -7,7 +7,7 @@ namespace Nest
77 public partial interface IElasticClient
88 {
99 /// <summary>
10- /// The bulk API makes it possible to perform many index/delete operations in a single API call.
10+ /// The bulk API makes it possible to perform many index/delete operations in a single API call.
1111 /// This can greatly increase the indexing speed.
1212 /// <para> </para>http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/docs-bulk.html
1313 /// </summary>
@@ -28,23 +28,33 @@ public partial interface IElasticClient
2828 public partial class ElasticClient
2929 {
3030 /// <inheritdoc/>
31- public IBulkResponse Bulk ( IBulkRequest request ) =>
31+ public IBulkResponse Bulk ( IBulkRequest request ) =>
3232 this . Dispatcher . Dispatch < IBulkRequest , BulkRequestParameters , BulkResponse > (
3333 request , this . LowLevelDispatch . BulkDispatch < BulkResponse >
3434 ) ;
3535
3636 /// <inheritdoc/>
37- public IBulkResponse Bulk ( Func < BulkDescriptor , IBulkRequest > selector = null ) =>
38- this . Bulk ( selector . InvokeOrDefault ( new BulkDescriptor ( ) ) ) ;
37+ public IBulkResponse Bulk ( Func < BulkDescriptor , IBulkRequest > selector = null )
38+ {
39+ // selector should not be nullable, but we can't change it for backwards compatibility reasons
40+ if ( selector == null )
41+ throw new ArgumentNullException ( nameof ( selector ) ) ;
42+ return this . Bulk ( selector . InvokeOrDefault ( new BulkDescriptor ( ) ) ) ;
43+ }
3944
4045 /// <inheritdoc/>
41- public Task < IBulkResponse > BulkAsync ( IBulkRequest request ) =>
46+ public Task < IBulkResponse > BulkAsync ( IBulkRequest request ) =>
4247 this . Dispatcher . DispatchAsync < IBulkRequest , BulkRequestParameters , BulkResponse , IBulkResponse > (
4348 request , this . LowLevelDispatch . BulkDispatchAsync < BulkResponse >
4449 ) ;
4550
4651 /// <inheritdoc/>
47- public Task < IBulkResponse > BulkAsync ( Func < BulkDescriptor , IBulkRequest > selector = null ) =>
48- this . BulkAsync ( selector . InvokeOrDefault ( new BulkDescriptor ( ) ) ) ;
52+ public Task < IBulkResponse > BulkAsync ( Func < BulkDescriptor , IBulkRequest > selector = null )
53+ {
54+ // selector should not be nullable, but we can't change it for backwards compatibility reasons
55+ if ( selector == null )
56+ throw new ArgumentNullException ( nameof ( selector ) ) ;
57+ return this . BulkAsync ( selector . InvokeOrDefault ( new BulkDescriptor ( ) ) ) ;
58+ }
4959 }
50- }
60+ }
0 commit comments