From 3f76f721372496011efc9328783f9f446b91a92b Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Fri, 18 Apr 2014 16:21:59 +0300 Subject: Better error-handling when storing assets: recognize that 'null' is an error value --- .../Connectors/Asset/AssetServicesConnector.cs | 23 +++++++++++----------- OpenSim/Services/Interfaces/IAssetService.cs | 2 +- 2 files changed, 12 insertions(+), 13 deletions(-) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs b/OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs index 32415e9..910c0d7 100644 --- a/OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs +++ b/OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs @@ -221,7 +221,7 @@ namespace OpenSim.Services.Connectors AsynchronousRestObjectRequester.MakeRequest("GET", uri, 0, delegate(AssetBase a) { - if (m_Cache != null) + if (a != null && m_Cache != null) m_Cache.Cache(a); AssetRetrievedEx handlers; @@ -287,7 +287,7 @@ namespace OpenSim.Services.Connectors string uri = m_ServerURI + "/assets/"; - string newID = string.Empty; + string newID; try { newID = SynchronousRestObjectRequester. @@ -295,19 +295,18 @@ namespace OpenSim.Services.Connectors } catch (Exception e) { - m_log.WarnFormat("[ASSET CONNECTOR]: Unable to send asset {0} to asset server. Reason: {1}", asset.ID, e.Message); + m_log.Warn(string.Format("[ASSET CONNECTOR]: Unable to send asset {0} to asset server. Reason: {1} ", asset.ID, e.Message), e); + return string.Empty; } - if (newID != String.Empty) - { - // Placing this here, so that this work with old asset servers that don't send any reply back - // SynchronousRestObjectRequester returns somethins that is not an empty string - if (newID != null) - asset.ID = newID; + if (string.IsNullOrEmpty(newID)) + return string.Empty; + + asset.ID = newID; + + if (m_Cache != null) + m_Cache.Cache(asset); - if (m_Cache != null) - m_Cache.Cache(asset); - } return newID; } diff --git a/OpenSim/Services/Interfaces/IAssetService.cs b/OpenSim/Services/Interfaces/IAssetService.cs index 8f1e039..28c3315 100644 --- a/OpenSim/Services/Interfaces/IAssetService.cs +++ b/OpenSim/Services/Interfaces/IAssetService.cs @@ -90,7 +90,7 @@ namespace OpenSim.Services.Interfaces /// Returns a random ID if none is passed via the asset argument. /// /// - /// + /// The Asset ID, or string.Empty if an error occurred string Store(AssetBase asset); /// -- cgit v1.1