Skip to content

Commit 7398541

Browse files
committed
Fix ArgumentNullException in MultiSearch OIS when SearchRequest is untyped
Closes #1279
1 parent 87c4d43 commit 7398541

File tree

3 files changed

+42
-1
lines changed

3 files changed

+42
-1
lines changed

src/Nest/Resolvers/Converters/MultiSearchConverter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist
9696
{
9797
var descriptor = m.Descriptor.Value;
9898
var concreteTypeSelector = descriptor.TypeSelector;
99-
var baseType = m.Descriptor.Value.ClrType;
99+
var baseType = m.Descriptor.Value.ClrType ?? typeof(object);
100100

101101
var generic = MakeDelegateMethodInfo.MakeGenericMethod(baseType);
102102

src/Tests/Nest.Tests.Integration/Nest.Tests.Integration.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@
178178
<Compile Include="Reproduce\Reproduce994Tests.cs" />
179179
<Compile Include="Reproduce\Reproduce986Tests.cs" />
180180
<Compile Include="Reproduce\Reproduce960Tests.cs" />
181+
<Compile Include="Reproduce\Reproduce1279Tests.cs" />
181182
<Compile Include="Search\Filter\AndOrNotFilterTests.cs" />
182183
<Compile Include="Search\Filter\ScriptFilterTests.cs" />
183184
<Compile Include="Search\Filter\MissingExistsFilterTests.cs" />
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
using NUnit.Framework;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
using FluentAssertions;
8+
using Nest.Tests.MockData.Domain;
9+
using Newtonsoft.Json.Linq;
10+
11+
namespace Nest.Tests.Integration.Reproduce
12+
{
13+
[TestFixture]
14+
public class Reproduce1279Tests : IntegrationTests
15+
{
16+
[Test]
17+
public void MultiSearchNullArgumentException()
18+
{
19+
var request = new MultiSearchRequest
20+
{
21+
Operations = new Dictionary<string, ISearchRequest>
22+
{
23+
{ "test", new SearchRequest
24+
{
25+
Query = new QueryContainer(new MatchAllQuery()),
26+
Types = new TypeNameMarker[] { typeof(Product), typeof(ElasticsearchProject) },
27+
TypeSelector = (o, h) => typeof(ElasticsearchProject)
28+
}
29+
}
30+
}
31+
};
32+
33+
var result = Client.MultiSearch(request);
34+
result.IsValid.Should().BeTrue();
35+
var response = result.GetResponse<object>("test");
36+
var projects = response.Documents.OfType<ElasticsearchProject>().ToList();
37+
projects.Count.Should().BeGreaterThan(0);
38+
}
39+
}
40+
}

0 commit comments

Comments
 (0)