akkadotnet / akkadotnet/Hyperion

NullReferenceException throws when serializing a JObject

Open
#72 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
281
Forks
62
PR merge metrics
No merged PRs in 30d

Description

When JObject is used for messaging then Akka fails to route such messages due to serialization problem.

In my particular case I have a strong typed message class with `IDictionary` property and `Akka.Serialization.Hyperion` configured as default serializer. At some moment this dictionary may contain JObject. Such messages destroy actor life-cycle due to serialization problem.

I made a test project to illustrate such behavior
[JObjectSerializationTest.zip](https://github.com/akkadotnet/Hyperion/files/1232008/JObjectSerializationTest.zip)

```
System.NullReferenceException: Object reference not set to an instance of an object.
at Hyperion.SerializerFactories.DictionarySerializerFactory.<>c__DisplayClass3_0.b__1(Stream stream, Object obj, SerializerSession session)
at Akka.Serialization.HyperionSerializer.ToBinary(Object obj)
at JObjectSerializationTest.UnitTest.<>c__DisplayClass1_0.b__0(Serializer serializer, Object entity)
```

Used packages versions
```





```

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure with the attached JObjectSerializationTest project, then inspect DictionarySerializerFactory.BuildSerializer and the Akka.Serialization.HyperionSerializer.ToBinary call shown in the stack trace. Use UnitTest.ShouldBeSerializedByHyperion as the starting test; done means the dictionary containing a JObject serializes without a NullReferenceException.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.