Skip to content

Commit

Permalink
MINOR: [C#] Handle Empty Schema (#42132)
Browse files Browse the repository at this point in the history
### 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 <hramkir@gmail.com>
Signed-off-by: Curt Hagenlocher <curt@hagenlocher.org>
  • Loading branch information
gloomweaver authored Jun 14, 2024
1 parent d078d5c commit 3333648
Showing 1 changed file with 1 addition and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ internal static class FlightMessageSerializer
{
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);
Expand Down

0 comments on commit 3333648

Please sign in to comment.