THRIFT-2259 C# unexpected null logDelegate() pointer causes AV in TServer.serve()
authorJens Geyer <jensg@apache.org>
Mon, 11 Nov 2013 20:33:54 +0000 (21:33 +0100)
committerJens Geyer <jensg@apache.org>
Mon, 11 Nov 2013 20:34:40 +0000 (21:34 +0100)
Patch: Jens Geyer

lib/csharp/src/Server/TServer.cs

index 7bf2747..19f11e4 100644 (file)
@@ -59,8 +59,14 @@ namespace Thrift.Server
                 * Output Protocol Factory
                 */
                protected TProtocolFactory outputProtocolFactory;
-               public delegate void LogDelegate(string str);
-               protected LogDelegate logDelegate;
+
+        public delegate void LogDelegate(string str);\r
+        private LogDelegate _logDelegate;\r
+        protected LogDelegate logDelegate\r
+        {\r
+            get { return _logDelegate; }\r
+            set { _logDelegate = (value != null) ? value : DefaultLogDelegate; } 
+        }
 
                /**
                 * Default constructors.
@@ -120,7 +126,7 @@ namespace Thrift.Server
                        this.outputTransportFactory = outputTransportFactory;
                        this.inputProtocolFactory = inputProtocolFactory;
                        this.outputProtocolFactory = outputProtocolFactory;
-                       this.logDelegate = logDelegate;
+                       this.logDelegate = (logDelegate != null) ? logDelegate : DefaultLogDelegate;
                }
 
                /**