[CSHARP-416] StackoverflowException occours when I serialize an object witha nhivbernate persistentbag Created: 27/Mar/12 Updated: 02/Jun/22 Resolved: 02/Apr/12 |
|
| Status: | Closed |
| Project: | C# Driver |
| Component/s: | None |
| Affects Version/s: | 1.3.1 |
| Fix Version/s: | 1.4.1 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Gian Maria Ricci | Assignee: | Robert Stam |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Windows 64 bit |
||
| Issue Links: |
|
||||||||
| Description |
|
I'm usingn mongo for logging, when I try to call ToBsonDocument on an object that is mapped with nhibernate and has a property of type IList<T>, nhibernate will create a PErsistentGenericBag<T>, and it cause a StackOverflowException when I call ToBsonDocument The exact type of the property is |
| Comments |
| Comment by Gian Maria Ricci [ 05/Apr/12 ] |
|
Thanks a lot for the quick fix |
| Comment by Robert Stam [ 02/Apr/12 ] |
|
|
| Comment by Robert Stam [ 30/Mar/12 ] |
|
Thank you for your comment. I have created a new ticket |
| Comment by Gian Maria Ricci [ 30/Mar/12 ] |
|
I understand these limitation, but StackOverflowException is not catchable, and it will kill your process immediately. Since I'm using MongoDb as a storage for log4net logs, to save object attached to logs, this problem makes impossibile to adopt this solution, because if someone try to log an object that has a circular reference the program shut down without any possibility to do a Try/Catch. It would be nice, for circular references, to throw some specific exception, or at least a catchable one, or being able to specify to the serializer a maximum deep of serialization. Thanks for your attenction. |
| Comment by Robert Stam [ 27/Mar/12 ] |
|
Not all classes can be serialized by the BsonClassMapSerializer, which works with classes that meet the following requirements: 1. The class has a public no-argument constructor Apparently NHibernate's PersistentGenericBag doesn't meet these requirements and is therefore not serializable by the BsonClassMapSerializer. A StackOverflow during serialization usually indicates a circular reference in the object graph. |