[
https://issues.apache.org/jira/browse/THRIFT-1700?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13469320#comment-13469320
]
Maxim Korobov commented on THRIFT-1700:
---------------------------------------
??I finally got to see your code...??
We use C# for client. Seems like thrift don't generates async wrappers for sync
methods when using C#. So we made our hand-made task-based wrappers. Here it is:
{code:title=C#}
public void GetStream (GetStreamAction action, Action <StreamContent>
onSuccess = null,
Action <Exception> onError = null)
{
factory.StartNew<StreamContent> (() => {
try {
ConnectIfNeed ();
var result = Client.getStream (action);
if (onSuccess != null)
onSuccess (result);
return result;
} catch (Exception e) {
if (onError != null)
onError (e);
return null;
}
}
);
}
{code}
{code:title=thrift}
struct GetStreamAction {
1: string authKey
2: commons.StreamId streamId
3: optional commons.Cursor cursor
}
commons.StreamContent getStream( 1 : GetStreamAction action ) throws (1:
BackendException ex)
{code}
??It seems like your frame is just too big :)??
??You'd have to change ReadAll as well in order to be able to read a uint or
you will get a negative value when casing it back to int.??
I will try it out.
??Anyway, it would "only" allow you to read another 2 million bytes, is it
enough for you???
2 billions, maybe?
??did you try with the buffered transport? and what is the other target
language? actually it should NOT send a size bigger than int.Max!??
I will try it out. Our colleagues at server-side uses Java+Scala.
> Number overflow in ReadFrame.
> -----------------------------
>
> Key: THRIFT-1700
> URL: https://issues.apache.org/jira/browse/THRIFT-1700
> Project: Thrift
> Issue Type: Bug
> Components: C# - Library
> Affects Versions: 0.8
> Reporter: Alexey
>
> private void ReadFrame()
> {
> byte[] i32rd = new byte[header_size];
> transport.ReadAll(i32rd, 0, header_size);
> int size =
> ((i32rd[0] & 0xff) << 24) |
> ((i32rd[1] & 0xff) << 16) |
> ((i32rd[2] & 0xff) << 8) |
> ((i32rd[3] & 0xff));
> byte[] buff = new byte[size];
> transport.ReadAll(buff, 0, size);
> readBuffer = new MemoryStream(buff);
> }
> Here, when calculating size, number overflow throws sometimes.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira