THRIFT-2470 THttpHandler swallows exceptions from processor
Client: C#
Patch: Adam Conelly
This closes #100
commit 6dcb1c3dc5d3259574863f0bc6af67b241b4653e
Author: Adam Connelly <adam@resdiary.com>
Date: 2014-04-16T14:37:54Z
THRIFT-2470: Stop THttpHandler from swallowing processor exceptions
The problem with the way it works currently is that it makes it very difficult to figure out what's going on when I've got a handler running on a remote web server. If the handler just allows the exceptions to bubble up like normal, they get caught by our normal exception handling code and logged.
I also added a new project for unit tests, and some tests for the changes I've made.
diff --git a/lib/csharp/src/Transport/THttpHandler.cs b/lib/csharp/src/Transport/THttpHandler.cs
index 0a10d79..884f1ad 100644
--- a/lib/csharp/src/Transport/THttpHandler.cs
+++ b/lib/csharp/src/Transport/THttpHandler.cs
@@ -63,30 +63,23 @@
{
TTransport transport = new TStreamTransport(input,output);
- TProtocol inputProtocol = null;
- TProtocol outputProtocol = null;
-
try
{
- inputProtocol = inputProtocolFactory.GetProtocol(transport);
- outputProtocol = outputProtocolFactory.GetProtocol(transport);
+ var inputProtocol = inputProtocolFactory.GetProtocol(transport);
+ var outputProtocol = outputProtocolFactory.GetProtocol(transport);
- while (processor.Process(inputProtocol, outputProtocol)) { }
+ while (processor.Process(inputProtocol, outputProtocol))
+ {
+ }
}
catch (TTransportException)
{
// Client died, just move on
}
- catch (TApplicationException tx)
+ finally
{
- Console.Error.Write(tx);
+ transport.Close();
}
- catch (Exception x)
- {
- Console.Error.Write(x);
- }
-
- transport.Close();
}
public bool IsReusable