Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

null ref in TwoStepDeviceBuilder.ElaborateTwoStepDeviceWithToken with some user agent strings from googlebot and bingbot #3

Open
jamesmanning opened this issue Mar 6, 2013 · 2 comments

Comments

@jamesmanning
Copy link

Exception type: NullReferenceException 
Exception message: Object reference not set to an instance of an object.
   at Oddr.Builders.Devices.TwoStepDeviceBuilder.ElaborateTwoStepDeviceWithToken(UserAgent userAgent, String step1Token, String step2Token)
   at Oddr.Builders.Devices.TwoStepDeviceBuilder.Build(UserAgent userAgent, Int32 confidenceTreshold)
   at Oddr.Identificators.DeviceIdentificator.Get(UserAgent userAgent, Int32 confidenceTreshold)
   at Oddr.ODDRService.GetPropertyValues(IEvidence evdnc, IPropertyRef[] prs)
   at Oddr.ODDRService.GetPropertyValue(IEvidence evdnc, IPropertyRef pr)

User agent strings that appear to trigger it include these (the +'s are there

@bubbafat
Copy link

bubbafat commented Mar 7, 2013

The problem is that in TwoStepDeviceBuilder.AferOrderingCompleteInit the collection orderedRules is modified during enumeration. It causes an exception to be thrown which results in the devices field to never be set which results in the null ref exception in ElaborateTwoStepDeviceWithToken

@bubbafat
Copy link

bubbafat commented Mar 7, 2013

This fixes it.

    protected override void AfterOrderingCompleteInit(Dictionary<string, Device> devices)
    {
        List<string> keys = new List<string>();
        foreach (string key in orderedRules.Keys)
        {
            keys.Add(key);
        }

        foreach (String step1Token in keys)
        {

            SortElement(step1Token);
        }...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants