Skip to content
This repository has been archived by the owner on Jan 4, 2021. It is now read-only.

Fixes of serialization issues and null-checks #2

Merged
merged 8 commits into from
May 10, 2018

Conversation

odev-it
Copy link
Contributor

@odev-it odev-it commented Apr 24, 2018

While using the C# library in our Xamarin project we discovered several issues regarding serialization:

  • There were some missing [KnownType] attributes which caused serialization method crashes
  • There were some missing [DataMember] attributes that caused wrong Timestamp readings of downloaded data and wrong Temperature SensorType values.

In addition to that, there were some conditions that caused null references (that were unrecoverable) in Logging.cs file regarding the variable "downloadTask". We added null-checks to prevent crashes.

NOTE: the code is already merged with version 1.0.0

@scaryghost
Copy link
Contributor

Before we can accept pull requests, you will need to sign a contribute license agreement. Please email "hello at mbientlab dot com" to request a copy.

Regarding the fixes:

  1. What are the reproduction steps to trigger the serialization errors?
  2. What are the reproduction steps that have the downloadTask variable set to null during a log download?
  3. downloadTask was changed to throw a fault if d/c during downloading in the previous release. Your merge reverts that, see this line in the diff.

@odev-it
Copy link
Contributor Author

odev-it commented Apr 26, 2018

Regarding the point "What are the reproduction steps to trigger the serialization errors?" the steps to reproduce are very simple:

  1. configure a Route that involves the modules IHumidityBme280 or IBarometerBosch.
  2. call the method SerializeAsync() on the IMetaWearBoard instance

Regarding the point "What are the reproduction steps that have the downloadTask variable set to null during a log download?". The problem is that sometimes happens that this callback bridge.addRegisterResponseHandler(Tuple.Create((byte)LOGGING, READOUT_PROGRESS), response =>
in Logging.cs is being "randomly" triggered even if there's no dowload in progress causing the downloadTask variable to be null. I've reproduced this issue by executing the source code listed in the attached file: StepsToReproduceNullReference.txt

Regarding the point "downloadTask was changed to throw a fault if d/c during downloading in the previous release. Your merge reverts that, see this line in the diff." I just committed the fix. Sorry for that.

@scaryghost
Copy link
Contributor

The null pointer exception is (eventually) caused by calling ClearEntries. You don't need to use it for the typical logging use case so remove it from your code.

That said, the NPE shouldn't happen regardless. Now knowing the root cause, I will be implementing different fix and thus will not be accepting the logging code changes in this PR. Please modify this PR to only be for the serialization code changes.

Regarding the serialization fixes, the code changes look good to me. I have been adding some unit tests that expose the exceptions. When I have confirmed that this PR corrects the unit tests, I will merge it into the code base.

scaryghost added a commit that referenced this pull request May 6, 2018
@scaryghost scaryghost self-assigned this May 7, 2018
@scaryghost scaryghost added the bug label May 7, 2018
@scaryghost
Copy link
Contributor

I pushed some unit tests out over the weekend. Please update the PR's origin to the latest commit on master.

@scaryghost scaryghost merged commit b8fc729 into mbientlab:master May 10, 2018
scaryghost added a commit that referenced this pull request May 10, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants