This is an automated email from the ASF dual-hosted git repository.
curth pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/main by this push:
new 3333648e78 MINOR: [C#] Handle Empty Schema (#42132)
3333648e78 is described below
commit 3333648e780d18dda8fbb5f95394736117e33cfe
Author: Kirill Khramkov <[email protected]>
AuthorDate: Fri Jun 14 06:45:42 2024 +0400
MINOR: [C#] Handle Empty Schema (#42132)
### Rationale for this change
While developing SDK encountered this error:
```
System.ArgumentOutOfRangeException : Specified argument was out of the
range of valid values. (Parameter 'length')
at
Apache.Arrow.Flight.FlightMessageSerializer.DecodeSchema(ReadOnlyMemory`1
buffer)
```
The issue is the schema buffer is empty, and other libraries don't throw
the error in this case. This PR makes this consistent with libraries for other
languages.
### What changes are included in this PR?
Return null if Schema buffer is empty.
### Are these changes tested?
Tested against our Flight API.
### Are there any user-facing changes?
Fix critical bug this inability to run request against flight service,
which doesn't return schema in GetFlightInfo.
Authored-by: Kirill Khramkov <[email protected]>
Signed-off-by: Curt Hagenlocher <[email protected]>
---
csharp/src/Apache.Arrow.Flight/Internal/FlightMessageSerializer.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/csharp/src/Apache.Arrow.Flight/Internal/FlightMessageSerializer.cs
b/csharp/src/Apache.Arrow.Flight/Internal/FlightMessageSerializer.cs
index 9df28b5033..47ffe43d24 100644
--- a/csharp/src/Apache.Arrow.Flight/Internal/FlightMessageSerializer.cs
+++ b/csharp/src/Apache.Arrow.Flight/Internal/FlightMessageSerializer.cs
@@ -27,6 +27,7 @@ namespace Apache.Arrow.Flight
{
public static Schema DecodeSchema(ReadOnlyMemory<byte> buffer)
{
+ if (buffer.IsEmpty) return null;
int bufferPosition = 0;
int schemaMessageLength =
BinaryPrimitives.ReadInt32LittleEndian(buffer.Span.Slice(bufferPosition));
bufferPosition += sizeof(int);