If shape properties fail SOP parsing (e.g. due to commas instead of decimal points) print out one short message listing the failing node names rather than lots of exceptions.
Adds skeleton bad float values deserialization testxassetservice
parent
80ec2ac167
commit
2b842958cc
|
@ -148,6 +148,113 @@ namespace OpenSim.Region.CoreModules.World.Serialiser.Tests
|
|||
<OtherParts />
|
||||
</SceneObjectGroup>";
|
||||
|
||||
private string badFloatsXml = @"
|
||||
<SceneObjectGroup>
|
||||
<RootPart>
|
||||
<SceneObjectPart xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"">
|
||||
<AllowedDrop>false</AllowedDrop>
|
||||
<CreatorID><Guid>a6dacf01-4636-4bb9-8a97-30609438af9d</Guid></CreatorID>
|
||||
<FolderID><Guid>e6a5a05e-e8cc-4816-8701-04165e335790</Guid></FolderID>
|
||||
<InventorySerial>1</InventorySerial>
|
||||
<TaskInventory />
|
||||
<ObjectFlags>0</ObjectFlags>
|
||||
<UUID><Guid>e6a5a05e-e8cc-4816-8701-04165e335790</Guid></UUID>
|
||||
<LocalId>2698615125</LocalId>
|
||||
<Name>NaughtyPrim</Name>
|
||||
<Material>0</Material>
|
||||
<PassTouches>false</PassTouches>
|
||||
<RegionHandle>1099511628032000</RegionHandle>
|
||||
<ScriptAccessPin>0</ScriptAccessPin>
|
||||
<GroupPosition><X>147.23</X><Y>92.698</Y><Z>22.78084</Z></GroupPosition>
|
||||
<OffsetPosition><X>0</X><Y>0</Y><Z>0</Z></OffsetPosition>
|
||||
<RotationOffset><X>-4.371139E-08</X><Y>-1</Y><Z>-4.371139E-08</Z><W>0</W></RotationOffset>
|
||||
<Velocity><X>0</X><Y>0</Y><Z>0</Z></Velocity>
|
||||
<RotationalVelocity><X>0</X><Y>0</Y><Z>0</Z></RotationalVelocity>
|
||||
<AngularVelocity><X>0</X><Y>0</Y><Z>0</Z></AngularVelocity>
|
||||
<Acceleration><X>0</X><Y>0</Y><Z>0</Z></Acceleration>
|
||||
<Description />
|
||||
<Color />
|
||||
<Text />
|
||||
<SitName />
|
||||
<TouchName />
|
||||
<LinkNum>0</LinkNum>
|
||||
<ClickAction>0</ClickAction>
|
||||
<Shape>
|
||||
<ProfileCurve>1</ProfileCurve>
|
||||
<TextureEntry>AAAAAAAAERGZmQAAAAAABQCVlZUAAAAAQEAAAABAQAAAAAAAAAAAAAAAAAAAAA==</TextureEntry>
|
||||
<ExtraParams>AA==</ExtraParams>
|
||||
<PathBegin>0</PathBegin>
|
||||
<PathCurve>16</PathCurve>
|
||||
<PathEnd>0</PathEnd>
|
||||
<PathRadiusOffset>0</PathRadiusOffset>
|
||||
<PathRevolutions>0</PathRevolutions>
|
||||
<PathScaleX>100</PathScaleX>
|
||||
<PathScaleY>100</PathScaleY>
|
||||
<PathShearX>0</PathShearX>
|
||||
<PathShearY>0</PathShearY>
|
||||
<PathSkew>0</PathSkew>
|
||||
<PathTaperX>0</PathTaperX>
|
||||
<PathTaperY>0</PathTaperY>
|
||||
<PathTwist>0</PathTwist>
|
||||
<PathTwistBegin>0</PathTwistBegin>
|
||||
<PCode>9</PCode>
|
||||
<ProfileBegin>0</ProfileBegin>
|
||||
<ProfileEnd>0</ProfileEnd>
|
||||
<ProfileHollow>0</ProfileHollow>
|
||||
<Scale><X>10</X><Y>10</Y><Z>0.5</Z></Scale>
|
||||
<State>0</State>
|
||||
<ProfileShape>Square</ProfileShape>
|
||||
<HollowShape>Same</HollowShape>
|
||||
<SculptTexture><Guid>00000000-0000-0000-0000-000000000000</Guid></SculptTexture>
|
||||
<SculptType>0</SculptType><SculptData />
|
||||
<FlexiSoftness>0</FlexiSoftness>
|
||||
<FlexiTension>0,5</FlexiTension>
|
||||
<FlexiDrag>yo mamma</FlexiDrag>
|
||||
<FlexiGravity>0</FlexiGravity>
|
||||
<FlexiWind>0</FlexiWind>
|
||||
<FlexiForceX>0</FlexiForceX>
|
||||
<FlexiForceY>0</FlexiForceY>
|
||||
<FlexiForceZ>0</FlexiForceZ>
|
||||
<LightColorR>0</LightColorR>
|
||||
<LightColorG>0</LightColorG>
|
||||
<LightColorB>0</LightColorB>
|
||||
<LightColorA>1</LightColorA>
|
||||
<LightRadius>0</LightRadius>
|
||||
<LightCutoff>0</LightCutoff>
|
||||
<LightFalloff>0</LightFalloff>
|
||||
<LightIntensity>1</LightIntensity>
|
||||
<FlexiEntry>false</FlexiEntry>
|
||||
<LightEntry>false</LightEntry>
|
||||
<SculptEntry>false</SculptEntry>
|
||||
</Shape>
|
||||
<Scale><X>10</X><Y>10</Y><Z>0.5</Z></Scale>
|
||||
<UpdateFlag>0</UpdateFlag>
|
||||
<SitTargetOrientation><X>0</X><Y>0</Y><Z>0</Z><W>1</W></SitTargetOrientation>
|
||||
<SitTargetPosition><X>0</X><Y>0</Y><Z>0</Z></SitTargetPosition>
|
||||
<SitTargetPositionLL><X>0</X><Y>0</Y><Z>0</Z></SitTargetPositionLL>
|
||||
<SitTargetOrientationLL><X>0</X><Y>0</Y><Z>0</Z><W>1</W></SitTargetOrientationLL>
|
||||
<ParentID>0</ParentID>
|
||||
<CreationDate>1211330445</CreationDate>
|
||||
<Category>0</Category>
|
||||
<SalePrice>0</SalePrice>
|
||||
<ObjectSaleType>0</ObjectSaleType>
|
||||
<OwnershipCost>0</OwnershipCost>
|
||||
<GroupID><Guid>00000000-0000-0000-0000-000000000000</Guid></GroupID>
|
||||
<OwnerID><Guid>a6dacf01-4636-4bb9-8a97-30609438af9d</Guid></OwnerID>
|
||||
<LastOwnerID><Guid>a6dacf01-4636-4bb9-8a97-30609438af9d</Guid></LastOwnerID>
|
||||
<BaseMask>2147483647</BaseMask>
|
||||
<OwnerMask>2147483647</OwnerMask>
|
||||
<GroupMask>0</GroupMask>
|
||||
<EveryoneMask>0</EveryoneMask>
|
||||
<NextOwnerMask>2147483647</NextOwnerMask>
|
||||
<Flags>None</Flags>
|
||||
<CollisionSound><Guid>00000000-0000-0000-0000-000000000000</Guid></CollisionSound>
|
||||
<CollisionSoundVolume>0</CollisionSoundVolume>
|
||||
</SceneObjectPart>
|
||||
</RootPart>
|
||||
<OtherParts />
|
||||
</SceneObjectGroup>";
|
||||
|
||||
private string xml2 = @"
|
||||
<SceneObjectGroup>
|
||||
<SceneObjectPart xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"">
|
||||
|
@ -256,6 +363,32 @@ namespace OpenSim.Region.CoreModules.World.Serialiser.Tests
|
|||
// TODO: Check other properties
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestDeserializeBadFloatsXml()
|
||||
{
|
||||
TestHelpers.InMethod();
|
||||
log4net.Config.XmlConfigurator.Configure();
|
||||
|
||||
SceneObjectGroup so = SceneObjectSerializer.FromOriginalXmlFormat(badFloatsXml);
|
||||
SceneObjectPart rootPart = so.RootPart;
|
||||
|
||||
Assert.That(rootPart.UUID, Is.EqualTo(new UUID("e6a5a05e-e8cc-4816-8701-04165e335790")));
|
||||
Assert.That(rootPart.CreatorID, Is.EqualTo(new UUID("a6dacf01-4636-4bb9-8a97-30609438af9d")));
|
||||
Assert.That(rootPart.Name, Is.EqualTo("NaughtyPrim"));
|
||||
|
||||
// This terminates the deserialization earlier if couldn't be parsed.
|
||||
// TODO: Need to address this
|
||||
Assert.That(rootPart.GroupPosition.X, Is.EqualTo(147.23f));
|
||||
|
||||
Assert.That(rootPart.Shape.PathCurve, Is.EqualTo(16));
|
||||
|
||||
// Defaults for bad parses
|
||||
Assert.That(rootPart.Shape.FlexiTension, Is.EqualTo(0));
|
||||
Assert.That(rootPart.Shape.FlexiDrag, Is.EqualTo(0));
|
||||
|
||||
// TODO: Check other properties
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSerializeXml()
|
||||
{
|
||||
|
|
|
@ -29,6 +29,7 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Xml;
|
||||
using log4net;
|
||||
|
@ -570,13 +571,15 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
|
|||
|
||||
private static void ProcessShape(SceneObjectPart obj, XmlTextReader reader)
|
||||
{
|
||||
bool errors = false;
|
||||
obj.Shape = ReadShape(reader, "Shape", out errors);
|
||||
List<string> errorNodeNames;
|
||||
obj.Shape = ReadShape(reader, "Shape", out errorNodeNames);
|
||||
|
||||
if (errors)
|
||||
if (errorNodeNames != null)
|
||||
{
|
||||
m_log.DebugFormat(
|
||||
"[SceneObjectSerializer]: Parsing PrimitiveBaseShape for object part {0} {1} encountered errors. Please see earlier log entries.",
|
||||
obj.Name, obj.UUID);
|
||||
"[SceneObjectSerializer]: Parsing PrimitiveBaseShape for object part {0} {1} encountered errors in properties {2}.",
|
||||
obj.Name, obj.UUID, string.Join(", ", errorNodeNames.ToArray()));
|
||||
}
|
||||
}
|
||||
|
||||
private static void ProcessScale(SceneObjectPart obj, XmlTextReader reader)
|
||||
|
@ -1519,37 +1522,44 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
|
|||
/// </summary>
|
||||
/// <param name="reader"></param>
|
||||
/// <param name="name">The name of the xml element containing the shape</param>
|
||||
/// <param name="errors">true if any errors were encountered during parsing, false otherwise</param>
|
||||
/// <param name="errors">a list containing the failing node names. If no failures then null.</param>
|
||||
/// <returns>The shape parsed</returns>
|
||||
public static PrimitiveBaseShape ReadShape(XmlTextReader reader, string name, out bool errors)
|
||||
public static PrimitiveBaseShape ReadShape(XmlTextReader reader, string name, out List<string> errorNodeNames)
|
||||
{
|
||||
errors = false;
|
||||
List<string> internalErrorNodeNames = null;
|
||||
|
||||
PrimitiveBaseShape shape = new PrimitiveBaseShape();
|
||||
|
||||
if (reader.IsEmptyElement)
|
||||
{
|
||||
reader.Read();
|
||||
errorNodeNames = null;
|
||||
return shape;
|
||||
}
|
||||
|
||||
reader.ReadStartElement(name, String.Empty); // Shape
|
||||
|
||||
errors = ExternalRepresentationUtils.ExecuteReadProcessors(
|
||||
ExternalRepresentationUtils.ExecuteReadProcessors(
|
||||
shape,
|
||||
m_ShapeXmlProcessors,
|
||||
reader,
|
||||
(o, nodeName, e)
|
||||
=>
|
||||
{
|
||||
m_log.DebugFormat(
|
||||
"[SceneObjectSerializer]: Exception while parsing Shape property {0}: {1}{2}",
|
||||
nodeName, e.Message, e.StackTrace);
|
||||
// m_log.DebugFormat(
|
||||
// "[SceneObjectSerializer]: Exception while parsing Shape property {0}: {1}{2}",
|
||||
// nodeName, e.Message, e.StackTrace);
|
||||
if (internalErrorNodeNames == null)
|
||||
internalErrorNodeNames = new List<string>();
|
||||
|
||||
internalErrorNodeNames.Add(nodeName);
|
||||
}
|
||||
);
|
||||
|
||||
reader.ReadEndElement(); // Shape
|
||||
|
||||
errorNodeNames = internalErrorNodeNames;
|
||||
|
||||
return shape;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue