U4-2505 - umbraco 6.1.2 throws System.NullReferenceException on the first publish after site compilation

Created by Chester Campbell Jr 12 Jul 2013, 21:38:16 Updated by Sebastiaan Janssen 16 Jul 2013, 08:58:45

I recently upgraded a site from Umbraco 4.7.1.1 to 6.1.2 successfully. I noticed though that upon the first document publish after the site has recompiled (from app-pool reset or web.config change) I get a YSOD and a System.NullReferenceException error. If I click on my content node again it loads and I can see that the Save & Publish actually did work as my changes are there.

All subsequent Save & Publishes work normally.

The stack trace for the error is:

[NullReferenceException: Object reference not set to an instance of an object.] Umbraco.Core.Sync.ConfigServerRegistrar.get_Registrations() +138 Umbraco.Web.Cache.DistributedCache.Refresh(Guid factoryGuid, Func2 getNumericId, T[] instances) +89 Umbraco.Web.Cache.DistributedCacheExtensions.RefreshPageCache(DistributedCache dc, IContent[] content) +190 Umbraco.Core.Events.TypedEventHandler2.Invoke(TSender sender, TEventArgs e) +0 Umbraco.Core.Services.ContentService.SaveAndPublishDo(IContent content, Int32 userId, Boolean raiseEvents) +1156 umbraco.cms.businesslogic.web.Document.SaveAndPublish(User u) +519 umbraco.cms.presentation.editContent.Publish(Object sender, EventArgs e) +318 System.Web.UI.WebControls.ImageButton.OnClick(ImageClickEventArgs e) +133 System.Web.UI.WebControls.ImageButton.RaisePostBackEvent(String eventArgument) +203 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3803

I took a look at the contents of Umbraco.Core.Sync.ConfigServerRegistrar and what I think is happening is that line 38 ...

var nodes = _xmlServers.SelectNodes("./server");

... is throwing the exception because _xmlServers is null. Why is it null? _xmlServers should be populated in the class constructor by the parameter ... UmbracoSettings.DistributedServers.

Looking in Umbraco.Core.Configuration I see that DistributedServers is populated by attempting to read the a key in the umbracoSettings.config file. The key is question ... /settings/distributedCall/servers ... happens to be commented out in my config because I'm not running my server in distributed mode. The read is wrapped in a Try/Catch which of course fails and thus DistributedServers is set to null.

Umbraco.Core.Sync.ConfigServerRegistrar Registrations should test _xmlServers for null before attempting to do a SelectNodes().

thanks, c

Comments

Sebastiaan Janssen 15 Jul 2013, 14:17:51

Fixed in changeset 1e129bcc4d9273732137fe45286e085730822d59

Assigned to Shannon for code review to make sure this is the correct fix.


Shannon Deminick 16 Jul 2013, 01:43:29

Just needs a little adjustment since the _addresses list always needs to be initialized even if _xmlServers is null. will fix up


Sebastiaan Janssen 16 Jul 2013, 08:58:45

D'oh, of course, thanks!


Priority: Normal

Type: Exception

State: Fixed

Assignee: Shannon Deminick

Difficulty: Normal

Category:

Backwards Compatible: True

Fix Submitted:

Affected versions: 6.1.2

Due in version: 6.1.3

Sprint:

Story Points:

Cycle: