Skip to content

Commit b71f56a

Browse files
author
Martin Daetz
committed
fix [] response on single notification
1 parent b718183 commit b71f56a

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

AustinHarris.JsonRpcTest/UnitTest1.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1340,10 +1340,16 @@ public void TestBatchResult()
13401340
string request =
13411341
@"[{},{""jsonrpc"":""2.0"",""id"":4},{""jsonrpc"":""2.0"",""method"":""ReturnsDateTime"",""params"":{},""id"":1},{""jsonrpc"":""2.0"",""method"":""Notify"",""params"":[""Hello World!""]}]";
13421342

1343+
var secondRequest = @"{""jsonrpc"":""2.0"",""method"":""Notify"",""params"":[""Hello World!""]}";
13431344
var result = JsonRpcProcessor.Process(request);
13441345
result.Wait();
13451346

13461347
Assert.IsFalse(result.Result.EndsWith(@",]"), "result.Result.EndsWith(@',]')");
1348+
1349+
result = JsonRpcProcessor.Process(secondRequest);
1350+
result.Wait();
1351+
1352+
Assert.IsTrue(string.IsNullOrEmpty(result.Result));
13471353
}
13481354
}
13491355
}

Json-Rpc/JsonRpcProcessor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ private static string ProcessInternal(string sessionId, string jsonRpc, object j
121121
responses[idx++] = JsonConvert.SerializeObject(resp.Item2);
122122
}
123123

124-
return responses.Length == 1 ? responses[0] : string.Format("[{0}]", string.Join(",", responses));
124+
return responses.Length == 0 ? string.Empty : responses.Length == 1 ? responses[0] : string.Format("[{0}]", string.Join(",", responses));
125125
}
126126
catch (Exception ex)
127127
{

0 commit comments

Comments
 (0)