THRIFT-2456 THttpClient fails when using async support outside Silverlight
Client: C#
Patch: Adam Connelly & Jens Geyer
This closes #97
commit 080b28eac31516ef9e3f988a87d890769f0751cd
Author: Adam Connelly <adam@resdiary.com>
Date: 2014-04-09T12:46:27Z
THRIFT-2456 Support async operations outside Silverlight
I altered TTransport to throw the NotSupportedExceptions to make it more obvious what's going on if someone generates their client using the async option, and then uses a transport that doesn't support it.
diff --git a/.gitignore b/.gitignore
index bff0826..1afe0de 100644
--- a/.gitignore
+++ b/.gitignore
@@ -110,8 +110,8 @@
/lib/c_glib/test/testtransportsocket
/lib/c_glib/thriftc.pc
/lib/c_glib/thrift_c_glib.pc
-/lib/csharp/src/bin/
-/lib/csharp/src/obj/
+/lib/csharp/**/bin/
+/lib/csharp/**/obj/
/lib/d/libthriftd.a
/lib/d/test/serialization_benchmark
/lib/d/test/transport_test
diff --git a/lib/csharp/src/Transport/THttpClient.cs b/lib/csharp/src/Transport/THttpClient.cs
index 78653f3..d19b7a7 100644
--- a/lib/csharp/src/Transport/THttpClient.cs
+++ b/lib/csharp/src/Transport/THttpClient.cs
@@ -216,7 +216,6 @@
return connection;
}
-#if SILVERLIGHT
public override IAsyncResult BeginFlush(AsyncCallback callback, object state)
{
// Extract request and reset buffer
@@ -267,7 +266,6 @@
}
-
private void GetRequestStreamCallback(IAsyncResult asynchronousResult)
{
var flushAsyncResult = (FlushAsyncResult)asynchronousResult.AsyncState;
@@ -375,7 +373,6 @@
}
}
-#endif
#region " IDisposable Support "
private bool _IsDisposed;
diff --git a/lib/csharp/src/Transport/TTransport.cs b/lib/csharp/src/Transport/TTransport.cs
index c03e9c2..745aa78 100644
--- a/lib/csharp/src/Transport/TTransport.cs
+++ b/lib/csharp/src/Transport/TTransport.cs
@@ -76,11 +76,16 @@
public virtual IAsyncResult BeginFlush(AsyncCallback callback, object state)
{
- return null;
+ throw new TTransportException(
+ TTransportException.ExceptionType.Unknown,
+ "Asynchronous operations are not supported by this transport.");
}
public virtual void EndFlush(IAsyncResult asyncResult)
{
+ throw new TTransportException(
+ TTransportException.ExceptionType.Unknown,
+ "Asynchronous operations are not supported by this transport.");
}
#region " IDisposable Support "