diff --git a/OpenSim/Framework/WebUtil.cs b/OpenSim/Framework/WebUtil.cs index bcf6af8849..54a6c0ce4b 100644 --- a/OpenSim/Framework/WebUtil.cs +++ b/OpenSim/Framework/WebUtil.cs @@ -1030,7 +1030,7 @@ namespace OpenSim.Framework finally { if (requestStream != null) - requestStream.Close(); + requestStream.Dispose(); // capture how much time was spent writing tickdata = Util.EnvironmentTickCountSubtract(tickstart); @@ -1183,7 +1183,7 @@ namespace OpenSim.Framework finally { if (requestStream != null) - requestStream.Close(); + requestStream.Dispose(); // capture how much time was spent writing tickdata = Util.EnvironmentTickCountSubtract(tickstart); @@ -1268,4 +1268,4 @@ namespace OpenSim.Framework return deserial; } } -} \ No newline at end of file +} diff --git a/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs b/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs index b21082fd74..9ae7452c85 100644 --- a/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs @@ -1290,9 +1290,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.UserProfiles webRequest.ContentType = "application/json-rpc"; webRequest.Method = "POST"; - Stream dataStream = webRequest.GetRequestStream(); - dataStream.Write(content, 0, content.Length); - dataStream.Close(); + using (Stream dataStream = webRequest.GetRequestStream()) + dataStream.Write(content, 0, content.Length); WebResponse webResponse = null; try @@ -1306,26 +1305,18 @@ namespace OpenSim.Region.OptionalModules.Avatar.UserProfiles return false; } - Stream rstream = webResponse.GetResponseStream(); - - OSDMap mret = new OSDMap(); - try + using (webResponse) + using (Stream rstream = webResponse.GetResponseStream()) { - mret = (OSDMap)OSDParser.DeserializeJson(rstream); - } - catch (Exception e) - { - m_log.DebugFormat("[PROFILES]: JsonRpcRequest Error {0} - remote user with legacy profiles?", e.Message); - return false; - } + OSDMap mret = (OSDMap)OSDParser.DeserializeJson(rstream); + if (mret.ContainsKey("error")) + return false; - if (mret.ContainsKey("error")) - return false; - - // get params... - OSD.DeserializeMembers(ref parameters, (OSDMap) mret["result"]); - return true; + // get params... + OSD.DeserializeMembers(ref parameters, (OSDMap)mret["result"]); + return true; + } } /// @@ -1366,9 +1357,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.UserProfiles webRequest.ContentType = "application/json-rpc"; webRequest.Method = "POST"; - Stream dataStream = webRequest.GetRequestStream(); - dataStream.Write(content, 0, content.Length); - dataStream.Close(); + using (Stream dataStream = webRequest.GetRequestStream()) + dataStream.Write(content, 0, content.Length); WebResponse webResponse = null; try @@ -1382,29 +1372,32 @@ namespace OpenSim.Region.OptionalModules.Avatar.UserProfiles return false; } - Stream rstream = webResponse.GetResponseStream(); - - OSDMap response = new OSDMap(); - try + using (webResponse) + using (Stream rstream = webResponse.GetResponseStream()) { - response = (OSDMap)OSDParser.DeserializeJson(rstream); - } - catch (Exception e) - { - m_log.DebugFormat("[PROFILES]: JsonRpcRequest Error {0} - remote user with legacy profiles?", e.Message); - return false; - } + OSDMap response = new OSDMap(); + try + { + response = (OSDMap)OSDParser.DeserializeJson(rstream); + } + catch (Exception e) + { + m_log.DebugFormat("[PROFILES]: JsonRpcRequest Error {0} - remote user with legacy profiles?", e.Message); + return false; + } - if(response.ContainsKey("error")) - { - data = response["error"]; - return false; + if (response.ContainsKey("error")) + { + data = response["error"]; + return false; + } + + data = response; + + return true; } - - data = response; - - return true; } + #endregion Web Util } -} \ No newline at end of file +} diff --git a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs index c3a8afdf93..a7237ea34a 100644 --- a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs +++ b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs @@ -488,9 +488,8 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest byte[] data = Util.UTF8.GetBytes(OutboundBody); Request.ContentLength = data.Length; - Stream bstream = Request.GetRequestStream(); - bstream.Write(data, 0, data.Length); - bstream.Close(); + using (Stream bstream = Request.GetRequestStream()) + bstream.Write(data, 0, data.Length); } try @@ -584,4 +583,4 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest Request.Abort(); } } -} \ No newline at end of file +} diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs index cf2ef29090..03e044b73e 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs @@ -915,7 +915,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap finally { if (os != null) - os.Close(); + os.Dispose(); } string response_mapItems_reply = null; diff --git a/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs b/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs index eb386fe423..e10b9add8c 100644 --- a/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs @@ -301,7 +301,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady finally { if (os != null) - os.Close(); + os.Dispose(); } } } diff --git a/OpenSim/Services/Connectors/Neighbour/NeighbourServicesConnector.cs b/OpenSim/Services/Connectors/Neighbour/NeighbourServicesConnector.cs index 774fe2a11a..96a756d724 100644 --- a/OpenSim/Services/Connectors/Neighbour/NeighbourServicesConnector.cs +++ b/OpenSim/Services/Connectors/Neighbour/NeighbourServicesConnector.cs @@ -162,7 +162,7 @@ namespace OpenSim.Services.Connectors finally { if (os != null) - os.Close(); + os.Dispose(); } // Let's wait for the response @@ -202,4 +202,4 @@ namespace OpenSim.Services.Connectors return true; } } -} \ No newline at end of file +}