Skip to content

Commit aa1992e

Browse files
committed
fix #303 all bulk generation routines should throw on null AND empty
1 parent 498c340 commit aa1992e

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

Diff for: src/Nest/ElasticClient-Bulk.cs

+4-6
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ private string GenerateBulkCommand<T>(IEnumerable<BulkParameters<T>> objects, st
141141
}
142142
private string GenerateBulkCommand<T>(IEnumerable<T> objects, string index, string command) where T : class
143143
{
144-
objects.ThrowIfNull("objects");
144+
objects.ThrowIfEmpty("objects");
145145
index.ThrowIfNullOrEmpty("index");
146146

147147
var type = typeof(T);
@@ -151,7 +151,7 @@ private string GenerateBulkCommand<T>(IEnumerable<T> objects, string index, stri
151151
}
152152
private string GenerateBulkCommand<T>(IEnumerable<BulkParameters<T>> objects, string index, string command) where T : class
153153
{
154-
objects.ThrowIfNull("objects");
154+
objects.ThrowIfEmpty("objects");
155155
index.ThrowIfNullOrEmpty("index");
156156

157157
var type = typeof(T);
@@ -163,8 +163,7 @@ private string GenerateBulkCommand<T>(IEnumerable<BulkParameters<T>> objects, st
163163

164164
private string GenerateBulkCommand<T>(IEnumerable<T> @objects, string index, string typeName, string command) where T : class
165165
{
166-
if (!@objects.Any())
167-
return null;
166+
objects.ThrowIfEmpty("objects");
168167

169168
var sb = new StringBuilder();
170169
var action = "{{ \"{0}\" : {{ \"_index\" : \"{1}\", \"_type\" : \"{2}\"".F(command, index, typeName);
@@ -194,8 +193,7 @@ private string GenerateBulkCommand<T>(IEnumerable<T> @objects, string index, str
194193
}
195194
private string GenerateBulkCommand<T>(IEnumerable<BulkParameters<T>> @objects, string index, string typeName, string command) where T : class
196195
{
197-
if (!@objects.Any())
198-
return null;
196+
objects.ThrowIfEmpty("objects");
199197

200198
var sb = new StringBuilder();
201199
var action = "{{ \"{0}\" : {{ \"_index\" : \"{1}\", \"_type\" : \"{2}\"".F(command, index, typeName);

0 commit comments

Comments
 (0)