THRIFT-4772 fully enable server-side usage of framed/buffered transports
Client: netstd
Patch: Jens Geyer
This closes #1729
diff --git a/lib/netstd/Thrift/Server/TServer.cs b/lib/netstd/Thrift/Server/TServer.cs
index 3a70c07..b351913 100644
--- a/lib/netstd/Thrift/Server/TServer.cs
+++ b/lib/netstd/Thrift/Server/TServer.cs
@@ -45,8 +45,8 @@
{
ProcessorFactory = processorFactory ?? throw new ArgumentNullException(nameof(processorFactory));
ServerTransport = serverTransport;
- InputTransportFactory = inputTransportFactory ?? throw new ArgumentNullException(nameof(inputTransportFactory));
- OutputTransportFactory = outputTransportFactory ?? throw new ArgumentNullException(nameof(outputTransportFactory));
+ InputTransportFactory = inputTransportFactory ?? new TTransportFactory();
+ OutputTransportFactory = outputTransportFactory ?? new TTransportFactory();
InputProtocolFactory = inputProtocolFactory ?? throw new ArgumentNullException(nameof(inputProtocolFactory));
OutputProtocolFactory = outputProtocolFactory ?? throw new ArgumentNullException(nameof(outputProtocolFactory));
Logger = logger; // null is absolutely legal
@@ -84,4 +84,4 @@
}
}
}
-}
\ No newline at end of file
+}
diff --git a/lib/netstd/Thrift/TApplicationException.cs b/lib/netstd/Thrift/TApplicationException.cs
index 50f65d6..9c86898 100644
--- a/lib/netstd/Thrift/TApplicationException.cs
+++ b/lib/netstd/Thrift/TApplicationException.cs
@@ -44,7 +44,7 @@
private const int MessageTypeFieldId = 1;
private const int ExTypeFieldId = 2;
- protected ExceptionType Type;
+ public ExceptionType Type { get; private set; }
public TApplicationException()
{
diff --git a/lib/netstd/Thrift/Transport/Client/TBufferedTransport.cs b/lib/netstd/Thrift/Transport/TBufferedTransport.cs
similarity index 96%
rename from lib/netstd/Thrift/Transport/Client/TBufferedTransport.cs
rename to lib/netstd/Thrift/Transport/TBufferedTransport.cs
index b8b5f53..c648f5c 100644
--- a/lib/netstd/Thrift/Transport/Client/TBufferedTransport.cs
+++ b/lib/netstd/Thrift/Transport/TBufferedTransport.cs
@@ -20,7 +20,7 @@
using System.Threading;
using System.Threading.Tasks;
-namespace Thrift.Transport.Client
+namespace Thrift.Transport
{
// ReSharper disable once InconsistentNaming
public class TBufferedTransport : TTransport
@@ -31,6 +31,14 @@
private readonly TTransport _transport;
private bool _isDisposed;
+ public class Factory : TTransportFactory
+ {
+ public override TTransport GetTransport(TTransport trans)
+ {
+ return new TBufferedTransport(trans);
+ }
+ }
+
//TODO: should support only specified input transport?
public TBufferedTransport(TTransport transport, int bufSize = 1024)
{
diff --git a/lib/netstd/Thrift/Transport/Client/TFramedTransport.cs b/lib/netstd/Thrift/Transport/TFramedTransport.cs
similarity index 95%
rename from lib/netstd/Thrift/Transport/Client/TFramedTransport.cs
rename to lib/netstd/Thrift/Transport/TFramedTransport.cs
index 7b764df..59963f1 100644
--- a/lib/netstd/Thrift/Transport/Client/TFramedTransport.cs
+++ b/lib/netstd/Thrift/Transport/TFramedTransport.cs
@@ -20,7 +20,7 @@
using System.Threading;
using System.Threading.Tasks;
-namespace Thrift.Transport.Client
+namespace Thrift.Transport
{
//TODO: check for correct implementation
@@ -35,6 +35,14 @@
private bool _isDisposed;
+ public class Factory : TTransportFactory
+ {
+ public override TTransport GetTransport(TTransport trans)
+ {
+ return new TFramedTransport(trans);
+ }
+ }
+
public TFramedTransport(TTransport transport)
{
_transport = transport ?? throw new ArgumentNullException(nameof(transport));
diff --git a/lib/netstd/Thrift/Transport/TTransportException.cs b/lib/netstd/Thrift/Transport/TTransportException.cs
index 7469b8b..760a178 100644
--- a/lib/netstd/Thrift/Transport/TTransportException.cs
+++ b/lib/netstd/Thrift/Transport/TTransportException.cs
@@ -32,7 +32,7 @@
Interrupted
}
- protected ExceptionType ExType;
+ public ExceptionType ExType { get; private set; }
public TTransportException()
{