Pārlūkot izejas kodu

2009-05-13 Atsushi Enomoto <[email protected]>

	* ChannelDispatcher.cs, SecurityHandler.cs,
	  InputOrReplyRequestProcessor.cs, MessageProcessingContext.cs :
	  remove default communication timeouts from several types. They
	  bring bogus NRE. Instead, fill timeouts in ChannelDispatcher and
	  use it when required (it was actually *only* request processor).

	* ChannelDispatcherTest.cs : make sure ctor args are nullable.


svn path=/trunk/mcs/; revision=134044
Atsushi Eno 16 gadi atpakaļ
vecāks
revīzija
7bcaf9bbbc

+ 8 - 0
mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/ChangeLog

@@ -1,3 +1,11 @@
+2009-05-13  Atsushi Enomoto  <[email protected]>
+
+	* ChannelDispatcher.cs, SecurityHandler.cs,
+	  InputOrReplyRequestProcessor.cs, MessageProcessingContext.cs :
+	  remove default communication timeouts from several types. They
+	  bring bogus NRE. Instead, fill timeouts in ChannelDispatcher and
+	  use it when required (it was actually *only* request processor).
+
 2009-05-13  Atsushi Enomoto  <[email protected]>
 
 	* ChannelDispatcher.cs : wrong channel argument.

+ 9 - 14
mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/ChannelDispatcher.cs

@@ -45,7 +45,7 @@ namespace System.ServiceModel.Dispatcher
 		Collection<IErrorHandler> error_handlers
 			= new Collection<IErrorHandler> ();
 		IChannelListener listener;
-		IDefaultCommunicationTimeouts timeouts;
+		internal IDefaultCommunicationTimeouts timeouts; // FIXME: remove internal
 		MessageVersion message_version;
 		bool receive_sync, include_exception_detail_in_faults,
 			manual_addressing, is_tx_receive;
@@ -64,17 +64,14 @@ namespace System.ServiceModel.Dispatcher
 		SynchronizedCollection<EndpointDispatcher> endpoints;
 
 		[MonoTODO ("get binding info from config")]
-		public ChannelDispatcher (IChannelListener listener)			
+		public ChannelDispatcher (IChannelListener listener)
+			: this (listener, null)
 		{
-			if (listener == null)
-				throw new ArgumentNullException ("listener");
-			Init (listener, null, null);
 		}
 
 		public ChannelDispatcher (
 			IChannelListener listener, string bindingName)
-			: this (listener, bindingName, 
-				DefaultCommunicationTimeouts.Instance)
+			: this (listener, bindingName, null)
 		{
 		}
 
@@ -84,10 +81,6 @@ namespace System.ServiceModel.Dispatcher
 		{
 			if (listener == null)
 				throw new ArgumentNullException ("listener");
-			if (bindingName == null)
-				throw new ArgumentNullException ("bindingName");
-			if (timeouts == null)
-				throw new ArgumentNullException ("timeouts");
 			Init (listener, bindingName, timeouts);
 		}
 
@@ -96,7 +89,9 @@ namespace System.ServiceModel.Dispatcher
 		{
 			this.listener = listener;
 			this.binding_name = bindingName;
-			this.timeouts = timeouts;
+			// IChannelListener is often a ChannelListenerBase
+			// which implements IDefaultCommunicationTimeouts.
+			this.timeouts = timeouts ?? listener as IDefaultCommunicationTimeouts ?? DefaultCommunicationTimeouts.Instance;
 			endpoints = new SynchronizedCollection<EndpointDispatcher> ();
 		}
 
@@ -467,7 +462,7 @@ namespace System.ServiceModel.Dispatcher
 						throw new InvalidOperationException ("The reply channel didn't return RequestContext");
 
 					EndpointDispatcher candidate = FindEndpointDispatcher (rc.RequestMessage);
-					new InputOrReplyRequestProcessor (candidate.DispatchRuntime, reply, owner.timeouts).
+					new InputOrReplyRequestProcessor (candidate.DispatchRuntime, reply).
 						ProcessReply (rc);
 				}
 				catch (EndpointNotFoundException ex) {
@@ -482,7 +477,7 @@ namespace System.ServiceModel.Dispatcher
 
 				try {
 					candidate = FindEndpointDispatcher (message);
-					new InputOrReplyRequestProcessor (candidate.DispatchRuntime, input, owner.timeouts).
+					new InputOrReplyRequestProcessor (candidate.DispatchRuntime, input).
 						ProcessInput(message);
 				}
 				catch (EndpointNotFoundException ex) {

+ 3 - 6
mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/InputOrReplyRequestProcessor.cs

@@ -12,11 +12,10 @@ namespace System.ServiceModel.Dispatcher
 	{
 		DispatchRuntime dispatch_runtime;
 		IChannel reply_or_input;
-		IDefaultCommunicationTimeouts communication_timeouts;
 
-		public InputOrReplyRequestProcessor (DispatchRuntime runtime, IChannel replyOrInput, IDefaultCommunicationTimeouts timeouts)
+		public InputOrReplyRequestProcessor (DispatchRuntime runtime, IChannel replyOrInput)
 		{
-			Init (runtime, reply_or_input, timeouts);
+			Init (runtime, reply_or_input);
 
 			//initialization
 			InitializeChain.AddHandler (new InitializingHandler ());
@@ -34,11 +33,10 @@ namespace System.ServiceModel.Dispatcher
 			FinalizationChain.AddHandler (new FinalizeProcessingHandler ());
 		}
 
-		void Init (DispatchRuntime runtime, IChannel replyOrInput, IDefaultCommunicationTimeouts timeouts)
+		void Init (DispatchRuntime runtime, IChannel replyOrInput)
 		{
 			dispatch_runtime = runtime;
 			reply_or_input = replyOrInput;
-			communication_timeouts = timeouts;
 		}
 
 		public void ProcessInput (Message message)
@@ -62,7 +60,6 @@ namespace System.ServiceModel.Dispatcher
 			OperationContext opCtx = new OperationContext (contextChannel);
 			opCtx.IncomingMessage = incoming;
 			opCtx.EndpointDispatcher = dispatch_runtime.EndpointDispatcher;
-			opCtx.CommunicationTimeouts = communication_timeouts;
 			return opCtx;
 		}
 	}

+ 1 - 9
mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/MessageProcessingContext.cs

@@ -11,7 +11,6 @@ namespace System.ServiceModel.Dispatcher
 		OperationContext operation_context;
 		RequestContext request_context;
 		Message incoming_message;
-		IDefaultCommunicationTimeouts timeouts;
 
 		Message reply_message;		
 		InstanceContext instance_context;		
@@ -24,7 +23,6 @@ namespace System.ServiceModel.Dispatcher
 			operation_context = opCtx;
 			request_context = opCtx.RequestContext;
 			incoming_message = opCtx.IncomingMessage;
-			timeouts = opCtx.CommunicationTimeouts;
 			user_events_handler = new UserEventsHandler (this);
 		}
 
@@ -46,12 +44,6 @@ namespace System.ServiceModel.Dispatcher
 			set { reply_message = value; }
 		}
 
-		public IDefaultCommunicationTimeouts CommunicationTimeouts
-		{
-			get { return timeouts; }
-			set { timeouts = value; }
-		}		
-
 		public InstanceContext InstanceContext
 		{
 			get { return instance_context; }
@@ -86,7 +78,7 @@ namespace System.ServiceModel.Dispatcher
 		{
 			EventsHandler.BeforeSendReply ();
 			if (useTimeout)
-				RequestContext.Reply (ReplyMessage, CommunicationTimeouts.SendTimeout);
+				RequestContext.Reply (ReplyMessage, Operation.Parent.ChannelDispatcher.timeouts.SendTimeout);
 			else
 				RequestContext.Reply (ReplyMessage);
 		}		

+ 1 - 1
mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/SecurityHandler.cs

@@ -35,7 +35,7 @@ namespace System.ServiceModel.Dispatcher
 		{
 			negoResponse.Headers.CopyHeadersFrom (mrc.OperationContext.OutgoingMessageHeaders);
 			negoResponse.Properties.CopyProperties (mrc.OperationContext.OutgoingMessageProperties);			
-			mrc.RequestContext.Reply (negoResponse, mrc.CommunicationTimeouts.SendTimeout);
+			mrc.RequestContext.Reply (negoResponse, mrc.Operation.Parent.ChannelDispatcher.timeouts.SendTimeout);
 			return;
 		}
 	}

+ 4 - 0
mcs/class/System.ServiceModel/Test/System.ServiceModel.Dispatcher/ChangeLog

@@ -1,3 +1,7 @@
+2009-05-13  Atsushi Enomoto  <[email protected]>
+
+	* ChannelDispatcherTest.cs : make sure ctor args are nullable.
+
 2009-04-27  Atsushi Enomoto  <[email protected]>
 
 	* ChannelDispatcherTest.cs : added a couple of EndpointDispatcher

+ 7 - 0
mcs/class/System.ServiceModel/Test/System.ServiceModel.Dispatcher/ChannelDispatcherTest.cs

@@ -14,6 +14,13 @@ namespace MonoTests.System.ServiceModel.Dispatcher
 	[TestFixture]
 	public class ChannelDispatcherTest
 	{
+		[Test]
+		public void ConstructorNullBindingName ()
+		{
+			new ChannelDispatcher (new MyChannelListener (new Uri ("urn:foo")), null);
+			new ChannelDispatcher (new MyChannelListener (new Uri ("urn:foo")), null, null);
+		}
+
 		[Test]			
 		public void Collection_Add_Remove () {
 			Console.WriteLine ("STart test Collection_Add_Remove");