From c37fb7c4b27419cae13c45fb38e24506fd009ea4 Mon Sep 17 00:00:00 2001 From: Robert Greig Date: Fri, 5 Jan 2007 17:00:41 +0000 Subject: Qpid-246-2 patch applied. Adds serializability to exceptions missed by the first patch. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@493087 13f79535-47bb-0310-9956-ffa450edef68 --- .../Qpid.Client/Client/AMQConnectionException.cs | 9 +++- .../Qpid.Client/Client/Message/QpidBytesMessage.cs | 7 +++ .../Message/UnexpectedBodyReceivedException.cs | 8 +++ .../State/IllegalStateTransitionException.cs | 17 ++++++ dotnet/Qpid.Client/qms/UrlSyntaxException.cs | 18 +++++++ dotnet/Qpid.Codec/ProtocolDecoderException.cs | 17 +++++- dotnet/Qpid.Codec/ProtocolEncoderException.cs | 8 +++ dotnet/Qpid.Common/AMQChannelClosedException.cs | 10 ++++ dotnet/Qpid.Common/AMQConnectionClosedException.cs | 10 ++++ dotnet/Qpid.Common/AMQDisconnectedException.cs | 10 ++++ dotnet/Qpid.Common/AMQUndeliveredException.cs | 18 +++++++ .../Framing/AMQFrameDecodingException.cs | 9 +++- .../Framing/AMQProtocolHeaderException.cs | 10 ++++ dotnet/Qpid.Common/build.xml | 62 +++++++++++++--------- .../Qpid.Messaging/ChannelLimitReachedException.cs | 17 ++++++ .../Qpid.Messaging/MessageNotReadableException.cs | 10 ++++ .../Qpid.Messaging/MessageNotWritableException.cs | 9 ++++ .../Qpid.Messaging/ResourceAllocationException.cs | 10 ++++ 18 files changed, 230 insertions(+), 29 deletions(-) diff --git a/dotnet/Qpid.Client/Client/AMQConnectionException.cs b/dotnet/Qpid.Client/Client/AMQConnectionException.cs index 603a7b2a1c..a4caf02e2c 100644 --- a/dotnet/Qpid.Client/Client/AMQConnectionException.cs +++ b/dotnet/Qpid.Client/Client/AMQConnectionException.cs @@ -19,13 +19,20 @@ * */ using System; +using System.Runtime.Serialization; namespace Qpid.Client { + [Serializable] public class AMQConnectionException : AMQException { public AMQConnectionException(String message, Exception e) : base(message, e) { } + + protected AMQConnectionException(SerializationInfo info, StreamingContext ctxt) + : base(info, ctxt) + { + } } -} \ No newline at end of file +} diff --git a/dotnet/Qpid.Client/Client/Message/QpidBytesMessage.cs b/dotnet/Qpid.Client/Client/Message/QpidBytesMessage.cs index 8788856062..044dec58b1 100644 --- a/dotnet/Qpid.Client/Client/Message/QpidBytesMessage.cs +++ b/dotnet/Qpid.Client/Client/Message/QpidBytesMessage.cs @@ -20,6 +20,7 @@ */ using System; using System.IO; +using System.Runtime.Serialization; using System.Text; using Qpid.Framing; using Qpid.Messaging; @@ -27,11 +28,17 @@ using Qpid.Buffer; namespace Qpid.Client.Message { + [Serializable] class MessageEOFException : QpidException { public MessageEOFException(string message) : base(message) { } + + protected MessageEOFException(SerializationInfo info, StreamingContext ctxt) + : base(info, ctxt) + { + } } public class QpidBytesMessage : AbstractQmsMessage, IBytesMessage diff --git a/dotnet/Qpid.Client/Client/Message/UnexpectedBodyReceivedException.cs b/dotnet/Qpid.Client/Client/Message/UnexpectedBodyReceivedException.cs index 679114d105..a671f608d1 100644 --- a/dotnet/Qpid.Client/Client/Message/UnexpectedBodyReceivedException.cs +++ b/dotnet/Qpid.Client/Client/Message/UnexpectedBodyReceivedException.cs @@ -19,6 +19,7 @@ * */ using System; +using System.Runtime.Serialization; using log4net; namespace Qpid.Client.Message @@ -27,6 +28,7 @@ namespace Qpid.Client.Message /// Raised when a message body is received unexpectedly by the client. This typically occurs when the /// length of bodies received does not match with the declared length in the content header. /// + [Serializable] public class UnexpectedBodyReceivedException : AMQException { public UnexpectedBodyReceivedException(ILog logger, string msg, Exception t) @@ -43,6 +45,12 @@ namespace Qpid.Client.Message : base(logger, errorCode, msg) { } + + protected UnexpectedBodyReceivedException(SerializationInfo info, StreamingContext ctxt) + : base(info, ctxt) + { + } } } + diff --git a/dotnet/Qpid.Client/Client/State/IllegalStateTransitionException.cs b/dotnet/Qpid.Client/Client/State/IllegalStateTransitionException.cs index 723ae04397..86b625951e 100644 --- a/dotnet/Qpid.Client/Client/State/IllegalStateTransitionException.cs +++ b/dotnet/Qpid.Client/Client/State/IllegalStateTransitionException.cs @@ -19,9 +19,11 @@ * */ using System; +using System.Runtime.Serialization; namespace Qpid.Client.State { + [Serializable] public class IllegalStateTransitionException : AMQException { private AMQState _originalState; @@ -36,6 +38,13 @@ namespace Qpid.Client.State _frame = frame; } + protected IllegalStateTransitionException(SerializationInfo info, StreamingContext ctxt) + : base(info, ctxt) + { + _originalState = (AMQState)info.GetValue("OriginalState", typeof(AMQState)); + _frame = (Type)info.GetValue("FrameType", typeof(Type)); + } + public AMQState OriginalState { get @@ -51,6 +60,14 @@ namespace Qpid.Client.State return _frame; } } + + public override void GetObjectData(SerializationInfo info, StreamingContext context) + { + base.GetObjectData(info, context); + info.AddValue("OriginalState", OriginalState); + info.AddValue("FrameType", FrameType); + } } } + diff --git a/dotnet/Qpid.Client/qms/UrlSyntaxException.cs b/dotnet/Qpid.Client/qms/UrlSyntaxException.cs index f7aaf56085..e6da62a829 100644 --- a/dotnet/Qpid.Client/qms/UrlSyntaxException.cs +++ b/dotnet/Qpid.Client/qms/UrlSyntaxException.cs @@ -19,10 +19,12 @@ * */ using System; +using System.Runtime.Serialization; using System.Text; namespace Qpid.Client.qms { + [Serializable] public class UrlSyntaxException : UriFormatException { private string _url; @@ -53,6 +55,22 @@ namespace Qpid.Client.qms _length = length; } + protected UrlSyntaxException(SerializationInfo info, StreamingContext ctxt) + : base(info, ctxt) + { + _url = info.GetString("Url"); + _index = info.GetInt32("Index"); + _length = info.GetInt32("Length"); + } + + public override void GetObjectData(SerializationInfo info, StreamingContext context) + { + base.GetObjectData(info, context); + info.AddValue("Url", _url); + info.AddValue("Index", _index); + info.AddValue("Length", _length); + } + private static String getPositionString(int index, int length) { StringBuilder sb = new StringBuilder(index + 1); diff --git a/dotnet/Qpid.Codec/ProtocolDecoderException.cs b/dotnet/Qpid.Codec/ProtocolDecoderException.cs index 94f3e6a591..562145288c 100644 --- a/dotnet/Qpid.Codec/ProtocolDecoderException.cs +++ b/dotnet/Qpid.Codec/ProtocolDecoderException.cs @@ -19,9 +19,11 @@ * */ using System; +using System.Runtime.Serialization; namespace Qpid.Codec { + [Serializable] public class ProtocolDecoderException : ProtocolCodecException { private string _hexdump; @@ -37,7 +39,13 @@ namespace Qpid.Codec public ProtocolDecoderException(Exception cause) : base(cause) { } - + + protected ProtocolDecoderException(SerializationInfo info, StreamingContext ctxt) + : base(info, ctxt) + { + _hexdump = info.GetString("HexDump"); + } + public string HexDump { get @@ -49,6 +57,13 @@ namespace Qpid.Codec _hexdump = value; } } + + public override void GetObjectData(SerializationInfo info, StreamingContext context) + { + base.GetObjectData(info, context); + info.AddValue("HexDump", _hexdump); + } } } + diff --git a/dotnet/Qpid.Codec/ProtocolEncoderException.cs b/dotnet/Qpid.Codec/ProtocolEncoderException.cs index db589c6c00..801cacbd54 100644 --- a/dotnet/Qpid.Codec/ProtocolEncoderException.cs +++ b/dotnet/Qpid.Codec/ProtocolEncoderException.cs @@ -19,9 +19,11 @@ * */ using System; +using System.Runtime.Serialization; namespace Qpid.Codec { + [Serializable] public class ProtocolEncoderException : ProtocolCodecException { public ProtocolEncoderException() : base() @@ -35,6 +37,12 @@ namespace Qpid.Codec public ProtocolEncoderException(Exception cause) : base(cause) { } + + protected ProtocolEncoderException(SerializationInfo info, StreamingContext ctxt) + : base(info, ctxt) + { + } } } + diff --git a/dotnet/Qpid.Common/AMQChannelClosedException.cs b/dotnet/Qpid.Common/AMQChannelClosedException.cs index 957e3b627d..77d8c06802 100644 --- a/dotnet/Qpid.Common/AMQChannelClosedException.cs +++ b/dotnet/Qpid.Common/AMQChannelClosedException.cs @@ -18,13 +18,23 @@ * under the License. * */ + +using System; +using System.Runtime.Serialization; + namespace Qpid { + [Serializable] public class AMQChannelClosedException : AMQException { public AMQChannelClosedException(int errorCode, string message) : base(errorCode, message) { } + + protected AMQChannelClosedException(SerializationInfo info, StreamingContext ctxt) + : base(info, ctxt) + { + } } } diff --git a/dotnet/Qpid.Common/AMQConnectionClosedException.cs b/dotnet/Qpid.Common/AMQConnectionClosedException.cs index 06d30e3d0a..977dcee73a 100644 --- a/dotnet/Qpid.Common/AMQConnectionClosedException.cs +++ b/dotnet/Qpid.Common/AMQConnectionClosedException.cs @@ -18,13 +18,23 @@ * under the License. * */ + +using System; +using System.Runtime.Serialization; + namespace Qpid { + [Serializable] public class AMQConnectionClosedException : AMQException { public AMQConnectionClosedException(int errorCode, string message) : base(errorCode, message) { } + + protected AMQConnectionClosedException(SerializationInfo info, StreamingContext ctxt) + : base(info, ctxt) + { + } } } diff --git a/dotnet/Qpid.Common/AMQDisconnectedException.cs b/dotnet/Qpid.Common/AMQDisconnectedException.cs index e7cb2ff590..5ea9672839 100644 --- a/dotnet/Qpid.Common/AMQDisconnectedException.cs +++ b/dotnet/Qpid.Common/AMQDisconnectedException.cs @@ -18,8 +18,13 @@ * under the License. * */ + +using System; +using System.Runtime.Serialization; + namespace Qpid { + [Serializable] public class AMQDisconnectedException : AMQException { public AMQDisconnectedException(int errorCode, string message) @@ -31,5 +36,10 @@ namespace Qpid : base(message) { } + + protected AMQDisconnectedException(SerializationInfo info, StreamingContext ctxt) + : base(info, ctxt) + { + } } } diff --git a/dotnet/Qpid.Common/AMQUndeliveredException.cs b/dotnet/Qpid.Common/AMQUndeliveredException.cs index 1cbc56c0ce..225a94e9b8 100644 --- a/dotnet/Qpid.Common/AMQUndeliveredException.cs +++ b/dotnet/Qpid.Common/AMQUndeliveredException.cs @@ -18,13 +18,19 @@ * under the License. * */ + +using System; +using System.Runtime.Serialization; + namespace Qpid { /// /// Thrown when a message has been bounced by the broker, indicating it could not be delivered. /// + [Serializable] public class AMQUndeliveredException : AMQException { + // TODO: Warning, no guarantee that the value stored here is serializable! private object _bounced; public AMQUndeliveredException(int errorCode, string message, object bounced) @@ -33,6 +39,18 @@ namespace Qpid _bounced = bounced; } + protected AMQUndeliveredException(SerializationInfo info, StreamingContext ctxt) + : base(info, ctxt) + { + _bounced = info.GetValue("bounced", typeof(object)); + } + + public override void GetObjectData(SerializationInfo info, StreamingContext context) + { + base.GetObjectData(info, context); + info.AddValue("bounced", _bounced); + } + public object GetUndeliveredMessage() { return _bounced; diff --git a/dotnet/Qpid.Common/Framing/AMQFrameDecodingException.cs b/dotnet/Qpid.Common/Framing/AMQFrameDecodingException.cs index e7223c9850..82891b5986 100644 --- a/dotnet/Qpid.Common/Framing/AMQFrameDecodingException.cs +++ b/dotnet/Qpid.Common/Framing/AMQFrameDecodingException.cs @@ -19,6 +19,7 @@ * */ using System; +using System.Runtime.Serialization; using log4net; namespace Qpid.Framing @@ -27,6 +28,7 @@ namespace Qpid.Framing /// Thrown when a frame cannot be decoded. This generally indicates a mismatch between the broker and the /// client. /// + [Serializable] public class AMQFrameDecodingException : AMQException { public AMQFrameDecodingException(string message) @@ -47,6 +49,11 @@ namespace Qpid.Framing public AMQFrameDecodingException(ILog logger, string message, Exception innerException) : base(logger, message, innerException) { - } + } + + protected AMQFrameDecodingException(SerializationInfo info, StreamingContext ctxt) + : base(info, ctxt) + { + } } } diff --git a/dotnet/Qpid.Common/Framing/AMQProtocolHeaderException.cs b/dotnet/Qpid.Common/Framing/AMQProtocolHeaderException.cs index 7ea509c78a..555cf1e6af 100644 --- a/dotnet/Qpid.Common/Framing/AMQProtocolHeaderException.cs +++ b/dotnet/Qpid.Common/Framing/AMQProtocolHeaderException.cs @@ -18,12 +18,22 @@ * under the License. * */ + +using System; +using System.Runtime.Serialization; + namespace Qpid.Framing { + [Serializable] public class AMQProtocolHeaderException : AMQException { public AMQProtocolHeaderException(string message) : base(message) { } + + protected AMQProtocolHeaderException(SerializationInfo info, StreamingContext ctxt) + : base(info, ctxt) + { + } } } diff --git a/dotnet/Qpid.Common/build.xml b/dotnet/Qpid.Common/build.xml index fa3dd50338..e976859b15 100644 --- a/dotnet/Qpid.Common/build.xml +++ b/dotnet/Qpid.Common/build.xml @@ -1,15 +1,9 @@ + - - - - - - - - + @@ -20,25 +14,42 @@ - - - - + + - - - + - + + + + + + + + - - + + + + + + + + + - + + + + @@ -47,6 +58,7 @@ + @@ -55,10 +67,8 @@ - - - - - + + + diff --git a/dotnet/Qpid.Messaging/ChannelLimitReachedException.cs b/dotnet/Qpid.Messaging/ChannelLimitReachedException.cs index 645c0d0cdd..0cfd2f24bc 100644 --- a/dotnet/Qpid.Messaging/ChannelLimitReachedException.cs +++ b/dotnet/Qpid.Messaging/ChannelLimitReachedException.cs @@ -18,8 +18,13 @@ * under the License. * */ + +using System; +using System.Runtime.Serialization; + namespace Qpid.Messaging { + [Serializable] public class ChannelLimitReachedException : ResourceAllocationException { private long _limit; @@ -32,6 +37,12 @@ namespace Qpid.Messaging _limit = limit; } + protected ChannelLimitReachedException(SerializationInfo info, StreamingContext ctxt) + : base(info, ctxt) + { + _limit = info.GetInt64("Limit"); + } + public long Limit { get @@ -39,5 +50,11 @@ namespace Qpid.Messaging return _limit; } } + + public override void GetObjectData(SerializationInfo info, StreamingContext context) + { + base.GetObjectData(info, context); + info.AddValue("Limit", _limit); + } } } diff --git a/dotnet/Qpid.Messaging/MessageNotReadableException.cs b/dotnet/Qpid.Messaging/MessageNotReadableException.cs index 077a15e719..5a919c2ced 100644 --- a/dotnet/Qpid.Messaging/MessageNotReadableException.cs +++ b/dotnet/Qpid.Messaging/MessageNotReadableException.cs @@ -18,12 +18,22 @@ * under the License. * */ + +using System; +using System.Runtime.Serialization; + namespace Qpid.Messaging { + [Serializable] public class MessageNotReadableException : QpidException { public MessageNotReadableException(string reason) : base(reason) { } + + protected MessageNotReadableException(SerializationInfo info, StreamingContext ctxt) + : base(info, ctxt) + { + } } } diff --git a/dotnet/Qpid.Messaging/MessageNotWritableException.cs b/dotnet/Qpid.Messaging/MessageNotWritableException.cs index 26905e28f3..6d4068c8c4 100644 --- a/dotnet/Qpid.Messaging/MessageNotWritableException.cs +++ b/dotnet/Qpid.Messaging/MessageNotWritableException.cs @@ -18,12 +18,21 @@ * under the License. * */ +using System; +using System.Runtime.Serialization; + namespace Qpid.Messaging { + [Serializable] public class MessageNotWriteableException : QpidException { public MessageNotWriteableException(string reason) : base(reason) { } + + protected MessageNotWriteableException(SerializationInfo info, StreamingContext ctxt) + : base(info, ctxt) + { + } } } diff --git a/dotnet/Qpid.Messaging/ResourceAllocationException.cs b/dotnet/Qpid.Messaging/ResourceAllocationException.cs index 076e374d60..a208b3cbbb 100644 --- a/dotnet/Qpid.Messaging/ResourceAllocationException.cs +++ b/dotnet/Qpid.Messaging/ResourceAllocationException.cs @@ -18,12 +18,22 @@ * under the License. * */ + +using System; +using System.Runtime.Serialization; + namespace Qpid.Messaging { + [Serializable] public class ResourceAllocationException : QpidException { public ResourceAllocationException(string reason) : base(reason) { } + + protected ResourceAllocationException(SerializationInfo info, StreamingContext ctxt) + : base(info, ctxt) + { + } } } -- cgit v1.2.1