You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@reef.apache.org by we...@apache.org on 2016/09/08 18:54:45 UTC
reef git commit: [REEF-1559] Remove unused methods of Exceptions
Repository: reef
Updated Branches:
refs/heads/master 8c0856114 -> fba47fa2c
[REEF-1559] Remove unused methods of Exceptions
This change removes methods of Exceptions class which are unused
or used in a single place.
JIRA:
[REEF-1559](https://issues.apache.org/jira/browse/REEF-1559)
Pull request:
This closes #1116
Project: http://git-wip-us.apache.org/repos/asf/reef/repo
Commit: http://git-wip-us.apache.org/repos/asf/reef/commit/fba47fa2
Tree: http://git-wip-us.apache.org/repos/asf/reef/tree/fba47fa2
Diff: http://git-wip-us.apache.org/repos/asf/reef/diff/fba47fa2
Branch: refs/heads/master
Commit: fba47fa2cfb605dc7d664ef796e31d87ca9af4ce
Parents: 8c08561
Author: Mariia Mykhailova <ma...@apache.org>
Authored: Thu Sep 8 10:21:28 2016 -0700
Committer: Markus Weimer <we...@apache.org>
Committed: Thu Sep 8 11:51:24 2016 -0700
----------------------------------------------------------------------
.../Diagnostics/Exceptions.cs | 124 -------------------
.../Remote/Impl/StreamingTransportClient.cs | 5 +-
2 files changed, 4 insertions(+), 125 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/reef/blob/fba47fa2/lang/cs/Org.Apache.REEF.Utilities/Diagnostics/Exceptions.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Org.Apache.REEF.Utilities/Diagnostics/Exceptions.cs b/lang/cs/Org.Apache.REEF.Utilities/Diagnostics/Exceptions.cs
index dcf6366..c5c5819 100644
--- a/lang/cs/Org.Apache.REEF.Utilities/Diagnostics/Exceptions.cs
+++ b/lang/cs/Org.Apache.REEF.Utilities/Diagnostics/Exceptions.cs
@@ -17,7 +17,6 @@
using System;
using System.Runtime.ExceptionServices;
-using System.Text;
using Org.Apache.REEF.Utilities.Logging;
using Org.Apache.REEF.Utilities.Attributes;
@@ -155,129 +154,6 @@ namespace Org.Apache.REEF.Utilities.Diagnostics
}
ExceptionDispatchInfo.Capture(exception).Throw();
}
-
- /// <summary>
- /// This method returns true if the exception passed as parameter is a critical exception
- /// that should have not been caught. Examples for such exceptions are StackOverflowException
- /// and OutOfMemoryException.
- /// </summary>
- /// <remarks>
- /// Catch statements which catch all exceptions must call this method immediately and rethrow
- /// without further processing if the method returns true.
- /// </remarks>
- /// <example>
- /// try
- /// {
- /// // Some code that can throw
- /// }
- /// catch (Exception e)
- /// {
- /// if (Exceptions.MustRethrow(e))
- /// {
- /// throw;
- /// }
- /// // Exception handling code
- /// }
- /// </example>
- /// <param name="exception">The exception to be checked.</param>
- /// <returns>True if the exceptions is critical one and should not be caught and false otherwise.</returns>
- public static bool MustRethrow(Exception exception)
- {
- return exception is OutOfMemoryException ||
- exception is StackOverflowException;
- }
-
- /// <summary>
- /// Gets an exception message that includes the messages of the inner exceptions.
- /// </summary>
- /// <param name="e">The exception.</param>
- /// <returns>The message</returns>
- public static string GetFullMessage(Exception e)
- {
- var fullMessage = new StringBuilder();
- bool firstLevel = true;
- while (e != null)
- {
- if (firstLevel)
- {
- firstLevel = false;
- }
- else
- {
- fullMessage.Append("-->");
- }
- fullMessage.Append(e.Message);
- e = e.InnerException;
- }
-
- return fullMessage.ToString();
- }
-
- /// <summary>
- /// Call this method to throw ArgumentException for an invalid argument.
- /// </summary>
- /// <param name="argumentName">The invalid argument name.</param>
- /// <param name="message">A message explaining the reason for th exception.</param>
- /// <param name="logger">The logger of the caller class.</param>
- public static void ThrowInvalidArgument(string argumentName, string message, Logger logger)
- {
- Throw(new ArgumentException(message, argumentName), logger);
- }
-
- /// <summary>
- /// Call this method to throw ArgumentOutOfRangeException exception.
- /// </summary>
- /// <param name="argumentName">The invalid argument name.</param>
- /// <param name="message">A message explaining the reason for th exception.</param>
- /// <param name="logger">The logger of the caller class.</param>
- public static void ThrowArgumentOutOfRange(string argumentName, string message, Logger logger)
- {
- Throw(new ArgumentOutOfRangeException(argumentName, message), logger);
- }
-
- /// <summary>
- /// Call this method to check if an argument is null and throw ArgumentNullException exception.
- /// </summary>
- /// <param name="argument">The argument to be checked.</param>
- /// <param name="name">The name of the argument.</param>
- /// <param name="logger">The logger of the caller class.</param>
- public static void ThrowIfArgumentNull(object argument, string name, Logger logger)
- {
- if (argument == null)
- {
- Exceptions.Throw(new ArgumentNullException(name), logger);
- }
- }
-
- /// <summary>
- /// Call this method to throw ObjectDisposedException if an object is disposed.
- /// </summary>
- /// <remarks>
- /// All disposable objects should check their state and throw in the beginning of each public method.
- /// This helper method provides a shorter way to do this.
- /// </remarks>
- /// <example>
- /// class SomeClass : IDisposable
- /// {
- /// bool _disposed;
- /// // ...
- /// public void SomePublicMethod()
- /// {
- /// Exceptions.ThrowIfObjectDisposed(_disposed, this);
- /// // Method's code
- /// }
- /// }
- /// </example>
- /// <param name="disposed">True if the object is disposed.</param>
- /// <param name="o">The object.</param>
- /// <param name="logger">The logger of the caller class.</param>
- public static void ThrowIfObjectDisposed(bool disposed, object o, Logger logger)
- {
- if (disposed)
- {
- Throw(new ObjectDisposedException(o.GetType().Name), logger);
- }
- }
#endregion
}
}
http://git-wip-us.apache.org/repos/asf/reef/blob/fba47fa2/lang/cs/Org.Apache.REEF.Wake/Remote/Impl/StreamingTransportClient.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Org.Apache.REEF.Wake/Remote/Impl/StreamingTransportClient.cs b/lang/cs/Org.Apache.REEF.Wake/Remote/Impl/StreamingTransportClient.cs
index cca8abd..05c259e 100644
--- a/lang/cs/Org.Apache.REEF.Wake/Remote/Impl/StreamingTransportClient.cs
+++ b/lang/cs/Org.Apache.REEF.Wake/Remote/Impl/StreamingTransportClient.cs
@@ -47,7 +47,10 @@ namespace Org.Apache.REEF.Wake.Remote.Impl
/// <param name="clientFactory">TcpClient factory</param>
internal StreamingTransportClient(IPEndPoint remoteEndpoint, IStreamingCodec<T> streamingCodec, ITcpClientConnectionFactory clientFactory)
{
- Exceptions.ThrowIfArgumentNull(remoteEndpoint, "remoteEndpoint", Logger);
+ if (remoteEndpoint == null)
+ {
+ Exceptions.Throw(new ArgumentNullException("remoteEndpoint"), Logger);
+ }
_link = new StreamingLink<T>(remoteEndpoint, streamingCodec, clientFactory);
_cancellationSource = new CancellationTokenSource();