avro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject [avro] branch master updated: AVRO-1981: Catch exceptions loading types from assemblies in C#
Date Fri, 01 Mar 2019 20:42:02 GMT
This is an automated email from the ASF dual-hosted git repository.

dkulp pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/avro.git


The following commit(s) were added to refs/heads/master by this push:
     new 846a9a1  AVRO-1981: Catch exceptions loading types from assemblies in C#
846a9a1 is described below

commit 846a9a1bb85e9832b696970c96e6089d43c3ee6b
Author: Brian Lachniet <blachniet@gmail.com>
AuthorDate: Thu Feb 28 19:33:39 2019 -0500

    AVRO-1981: Catch exceptions loading types from assemblies in C#
    
    Loading all types from all assemblies in the current domain
    could throw an exception for a variety of non-fatal reasons.
    Simply catch these exceptions and continue.
---
 lang/csharp/src/apache/main/Specific/ObjectCreator.cs | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/lang/csharp/src/apache/main/Specific/ObjectCreator.cs b/lang/csharp/src/apache/main/Specific/ObjectCreator.cs
index d1daa95..1164053 100644
--- a/lang/csharp/src/apache/main/Specific/ObjectCreator.cs
+++ b/lang/csharp/src/apache/main/Specific/ObjectCreator.cs
@@ -138,7 +138,16 @@ namespace Avro.Specific
                     if (assembly.FullName.StartsWith("MonoDevelop.NUnit"))
                         continue;
 
-                    types = assembly.GetTypes();
+                    // Loading all types from all assemblies could fail for a variety of
non-fatal
+                    // reasons. If we fail to load types from an assembly, continue.
+                    try
+                    {
+                        types = assembly.GetTypes();
+                    }
+                    catch
+                    {
+                        continue;
+                    }
 
                     // Change the search to look for Types by both NAME and FULLNAME
                     foreach (Type t in types)


Mime
View raw message