algesten/jsondiff — Issue #12: NPE in JsonDiff
Author: DrLansing
Created: 2012-02-02 21:18:56+00:00
State: open

Under certain conditions findCorrespondingNode(toArrs, fromNode) returns null, which causes NPE in fixHalfDeletedArrs().
I suspect that the correct behavior might be to return fromNode instead of null, but I don't know enough to be sure.

Test data (sorry so ugly) follows.

#### from:
{
"name" : "Daily Ops Update",
"dateTime" : {
"path" : "/p:Plan/p:timeFrame"
},
"subplanList" : [ {
"name" : "Ships Schedules",
"dateTime" : {
"path" : "/p:Plan/p:timeFrame"
},
"subplanList" : [ {
"name" : "SAPPHIRE PRINCESS",
"dateTime" : {
"path" : "/p:Plan/p:timeFrame"
},
"actionList" : [ {
"name" : "stockdale task 3d",
"dateTime" : {
"path" : "/p:Action/p:plannedTime",
"timePeriod" : {
"start" : "2011-08-02T00:00:00.000Z",
"finish" : "2011-09-10T00:00:00.000Z"
}
}
}, {
"name" : "IPT Los Angeles, California",
"dateTime" : {
"path" : "/p:Action/p:plannedTime",
"timePeriod" : {
"start" : "2010-07-16T00:00:00.000Z",
"finish" : "2010-07-16T00:00:00.000Z"
}
}
}, {
"name" : "U/W Los Angeles, California",
"dateTime" : {
"path" : "/p:Action/p:plannedTime",
"timePeriod" : {
"start" : "2010-07-15T00:00:00.000Z",
"finish" : "2010-07-15T00:00:00.000Z"
}
}
}, {
"name" : "IPT Cabo San Lucas, Mexico",
"dateTime" : {
"path" : "/p:Action/p:plannedTime",
"timePeriod" : {
"start" : "2010-07-14T00:00:00.000Z",
"finish" : "2010-07-14T00:00:00.000Z"
}
}
}, {
"name" : "IPT Mazatlan, Mexico",
"dateTime" : {
"path" : "/p:Action/p:plannedTime",
"timePeriod" : {
"start" : "2010-07-13T00:00:00.000Z",
"finish" : "2010-07-13T00:00:00.000Z"
}
}
}, {
"name" : "IPT Puerto Vallarta, Mexico",
"dateTime" : {
"path" : "/p:Action/p:plannedTime",
"timePeriod" : {
"start" : "2010-07-12T00:00:00.000Z",
"finish" : "2010-07-12T00:00:00.000Z"
}
}
}, {
"name" : "IPT Ixtapa, Mexico",
"dateTime" : {
"path" : "/p:Action/p:plannedTime",
"timePeriod" : {
"start" : "2010-07-11T00:00:00.000Z",
"finish" : "2010-07-11T00:00:00.000Z"
}
}
}, {
"name" : "IPT Acapulco, Mexico",
"dateTime" : {
"path" : "/p:Action/p:plannedTime",
"timePeriod" : {
"start" : "2010-07-10T00:00:00.000Z",
"finish" : "2010-07-10T00:00:00.000Z"
}
}
}, {
"name" : "U/W Acapulco, Mexico",
"dateTime" : {
"path" : "/p:Action/p:plannedTime",
"timePeriod" : {
"start" : "2010-07-07T00:00:00.000Z",
"finish" : "2010-07-09T00:00:00.000Z"
}
}
}, {
"name" : "IPT Los Angeles, California",
"dateTime" : {
"path" : "/p:Action/p:plannedTime",
"timePeriod" : {
"start" : "2010-07-06T00:00:00.000Z",
"finish" : "2010-07-06T00:00:00.000Z"
}
}
}, {
"name" : "IPT Los Angeles, California",
"dateTime" : {
"path" : "/p:Action/p:plannedTime",
"timePeriod" : {
"start" : "2010-07-06T00:00:00.000Z",
"finish" : "2010-07-06T00:00:00.000Z"
}
}
}, {
"name" : "U/W Acapulco, Mexico",
"dateTime" : {
"path" : "/p:Action/p:plannedTime",
"timePeriod" : {
"start" : "2010-07-07T00:00:00.000Z",
"finish" : "2010-07-09T00:00:00.000Z"
}
}
}, {
"name" : "IPT Acapulco, Mexico",
"dateTime" : {
"path" : "/p:Action/p:plannedTime",
"timePeriod" : {
"start" : "2010-07-10T00:00:00.000Z",
"finish" : "2010-07-10T00:00:00.000Z"
}
}
}, {
"name" : "IPT Ixtapa, Mexico",
"dateTime" : {
"path" : "/p:Action/p:plannedTime",
"timePeriod" : {
"start" : "2010-07-11T00:00:00.000Z",
"finish" : "2010-07-11T00:00:00.000Z"
}
}
}, {
"name" : "IPT Puerto Vallarta, Mexico",
"dateTime" : {
"path" : "/p:Action/p:plannedTime",
"timePeriod" : {
"start" : "2010-07-12T00:00:00.000Z",
"finish" : "2010-07-12T00:00:00.000Z"
}
}
}, {
"name" : "IPT Mazatlan, Mexico",
"dateTime" : {
"path" : "/p:Action/p:plannedTime",
"timePeriod" : {
"start" : "2010-07-13T00:00:00.000Z",
"finish" : "2010-07-13T00:00:00.000Z"
}
}
}, {
"name" : "IPT Cabo San Lucas, Mexico",
"dateTime" : {
"path" : "/p:Action/p:plannedTime",
"timePeriod" : {
"start" : "2010-07-14T00:00:00.000Z",
"finish" : "2010-07-14T00:00:00.000Z"
}
}
}, {
"name" : "U/W Los Angeles, California",
"dateTime" : {
"path" : "/p:Action/p:plannedTime",
"timePeriod" : {
"start" : "2010-07-15T00:00:00.000Z",
"finish" : "2010-07-15T00:00:00.000Z"
}
}
}, {
"name" : "IPT Los Angeles, California",
"dateTime" : {
"path" : "/p:Action/p:plannedTime",
"timePeriod" : {
"start" : "2010-07-16T00:00:00.000Z",
"finish" : "2010-07-16T00:00:00.000Z"
}
}
}, {
"name" : "IPT Los Angeles, California",
"dateTime" : {
"path" : "/p:Action/p:plannedTime",
"timePeriod" : {
"start" : "2010-07-16T00:00:00.000Z",
"finish" : "2010-07-16T00:00:00.000Z"
}
}
}, {
"name" : "U/W Los Angeles, California",
"dateTime" : {
"path" : "/p:Action/p:plannedTime",
"timePeriod" : {
"start" : "2010-07-15T00:00:00.000Z",
"finish" : "2010-07-15T00:00:00.000Z"
}
}
}, {
"name" : "IPT Cabo San Lucas, Mexico",
"dateTime" : {
"path" : "/p:Action/p:plannedTime",
"timePeriod" : {
"start" : "2010-07-14T00:00:00.000Z",
"finish" : "2010-07-14T00:00:00.000Z"
}
}
}, {
"name" : "IPT Mazatlan, Mexico",
"dateTime" : {
"path" : "/p:Action/p:plannedTime",
"timePeriod" : {
"start" : "2010-07-13T00:00:00.000Z",
"finish" : "2010-07-13T00:00:00.000Z"
}
}
}, {
"name" : "IPT Puerto Vallarta, Mexico",
"dateTime" : {
"path" : "/p:Action/p:plannedTime",
"timePeriod" : {
"start" : "2010-07-12T00:00:00.000Z",
"finish" : "2010-07-12T00:00:00.000Z"
}
}
}, {
"name" : "IPT Ixtapa, Mexico",
"dateTime" : {
"path" : "/p:Action/p:plannedTime",
"timePeriod" : {
"start" : "2010-07-11T00:00:00.000Z",
"finish" : "2010-07-11T00:00:00.000Z"
}
}
}, {
"name" : "IPT Acapulco, Mexico",
"dateTime" : {
"path" : "/p:Action/p:plannedTime",
"timePeriod" : {
"start" : "2010-07-10T00:00:00.000Z",
"finish" : "2010-07-10T00:00:00.000Z"
}
}
}, {
"name" : "U/W Acapulco, Mexico",
"dateTime" : {
"path" : "/p:Action/p:plannedTime",
"timePeriod" : {
"start" : "2010-07-07T00:00:00.000Z",
"finish" : "2010-07-09T00:00:00.000Z"
}
}
}, {
"name" : "IPT Los Angeles, California",
"dateTime" : {
"path" : "/p:Action/p:plannedTime",
"timePeriod" : {
"start" : "2010-07-06T00:00:00.000Z",
"finish" : "2010-07-06T00:00:00.000Z"
}
}
}, {
"name" : "IPT Los Angeles, California",
"dateTime" : {
"path" : "/p:Action/p:plannedTime",
"timePeriod" : {
"start" : "2010-07-06T00:00:00.000Z",
"finish" : "2010-07-06T00:00:00.000Z"
}
}
}, {
"name" : "U/W Acapulco, Mexico",
"dateTime" : {
"path" : "/p:Action/p:plannedTime",
"timePeriod" : {
"start" : "2010-07-07T00:00:00.000Z",
"finish" : "2010-07-09T00:00:00.000Z"
}
}
}, {
"name" : "IPT Acapulco, Mexico",
"dateTime" : {
"path" : "/p:Action/p:plannedTime",
"timePeriod" : {
"start" : "2010-07-10T00:00:00.000Z",
"finish" : "2010-07-10T00:00:00.000Z"
}
}
}, {
"name" : "IPT Ixtapa, Mexico",
"dateTime" : {
"path" : "/p:Action/p:plannedTime",
"timePeriod" : {
"start" : "2010-07-11T00:00:00.000Z",
"finish" : "2010-07-11T00:00:00.000Z"
}
}
}, {
"name" : "IPT Puerto Vallarta, Mexico",
"dateTime" : {
"path" : "/p:Action/p:plannedTime",
"timePeriod" : {
"start" : "2010-07-12T00:00:00.000Z",
"finish" : "2010-07-12T00:00:00.000Z"
}
}
}, {
"name" : "IPT Mazatlan, Mexico",
"dateTime" : {
"path" : "/p:Action/p:plannedTime",
"timePeriod" : {
"start" : "2010-07-13T00:00:00.000Z",
"finish" : "2010-07-13T00:00:00.000Z"
}
}
}, {
"name" : "IPT Cabo San Lucas, Mexico",
"dateTime" : {
"path" : "/p:Action/p:plannedTime",
"timePeriod" : {
"start" : "2010-07-14T00:00:00.000Z",
"finish" : "2010-07-14T00:00:00.000Z"
}
}
}, {
"name" : "U/W Los Angeles, California",
"dateTime" : {
"path" : "/p:Action/p:plannedTime",
"timePeriod" : {
"start" : "2010-07-15T00:00:00.000Z",
"finish" : "2010-07-15T00:00:00.000Z"
}
}
}, {
"name" : "IPT Los Angeles, California",
"dateTime" : {
"path" : "/p:Action/p:plannedTime",
"timePeriod" : {
"start" : "2010-07-16T00:00:00.000Z",
"finish" : "2010-07-16T00:00:00.000Z"
}
}
}, {
"name" : "stockdale task 2d",
"dateTime" : {
"path" : "/p:Action/p:plannedTime",
"timePeriod" : {
"start" : "2011-08-01T20:00:00.000Z",
"finish" : "2011-09-11T08:00:00.000Z"
}
}
}, {
"name" : "stockdale task 2d",
"dateTime" : {
"path" : "/p:Action/p:plannedTime",
"timePeriod" : {
"start" : "2011-08-01T20:00:00.000Z",
"finish" : "2011-09-11T08:00:00.000Z"
}
}
}, {
"name" : "IPT Los Angeles, California",
"dateTime" : {
"path" : "/p:Action/p:plannedTime",
"timePeriod" : {
"start" : "2010-07-16T00:00:00.000Z",
"finish" : "2010-07-16T00:00:00.000Z"
}
}
}, {
"name" : "U/W Los Angeles, California",
"dateTime" : {
"path" : "/p:Action/p:plannedTime",
"timePeriod" : {
"start" : "2010-07-15T00:00:00.000Z",
"finish" : "2010-07-15T00:00:00.000Z"
}
}
}, {
"name" : "IPT Cabo San Lucas, Mexico",
"dateTime" : {
"path" : "/p:Action/p:plannedTime",
"timePeriod" : {
"start" : "2010-07-14T00:00:00.000Z",
"finish" : "2010-07-14T00:00:00.000Z"
}
}
}, {
"name" : "IPT Mazatlan, Mexico",
"dateTime" : {
"path" : "/p:Action/p:plannedTime",
"timePeriod" : {
"start" : "2010-07-13T00:00:00.000Z",
"finish" : "2010-07-13T00:00:00.000Z"
}
}
}, {
"name" : "IPT Puerto Vallarta, Mexico",
"dateTime" : {
"path" : "/p:Action/p:plannedTime",
"timePeriod" : {
"start" : "2010-07-12T00:00:00.000Z",
"finish" : "2010-07-12T00:00:00.000Z"
}
}
}, {
"name" : "IPT Ixtapa, Mexico",
"dateTime" : {
"path" : "/p:Action/p:plannedTime",
"timePeriod" : {
"start" : "2010-07-11T00:00:00.000Z",
"finish" : "2010-07-11T00:00:00.000Z"
}
}
}, {
"name" : "IPT Acapulco, Mexico",
"dateTime" : {
"path" : "/p:Action/p:plannedTime",
"timePeriod" : {
"start" : "2010-07-10T00:00:00.000Z",
"finish" : "2010-07-10T00:00:00.000Z"
}
}
}, {
"name" : "U/W Acapulco, Mexico",
"dateTime" : {
"path" : "/p:Action/p:plannedTime",
"timePeriod" : {
"start" : "2010-07-07T00:00:00.000Z",
"finish" : "2010-07-09T00:00:00.000Z"
}
}
}, {
"name" : "IPT Los Angeles, California",
"dateTime" : {
"path" : "/p:Action/p:plannedTime",
"timePeriod" : {
"start" : "2010-07-06T00:00:00.000Z",
"finish" : "2010-07-06T00:00:00.000Z"
}
}
}, {
"name" : "IPT Los Angeles, California",
"dateTime" : {
"path" : "/p:Action/p:plannedTime",
"timePeriod" : {
"start" : "2010-07-06T00:00:00.000Z",
"finish" : "2010-07-06T00:00:00.000Z"
}
}
}, {
"name" : "U/W Acapulco, Mexico",
"dateTime" : {
"path" : "/p:Action/p:plannedTime",
"timePeriod" : {
"start" : "2010-07-07T00:00:00.000Z",
"finish" : "2010-07-09T00:00:00.000Z"
}
}
}, {
"name" : "IPT Acapulco, Mexico",
"dateTime" : {
"path" : "/p:Action/p:plannedTime",
"timePeriod" : {
"start" : "2010-07-10T00:00:00.000Z",
"finish" : "2010-07-10T00:00:00.000Z"
}
}
}, {
"name" : "IPT Ixtapa, Mexico",
"dateTime" : {
"path" : "/p:Action/p:plannedTime",
"timePeriod" : {
"start" : "2010-07-11T00:00:00.000Z",
"finish" : "2010-07-11T00:00:00.000Z"
}
}
}, {
"name" : "IPT Puerto Vallarta, Mexico",
"dateTime" : {
"path" : "/p:Action/p:plannedTime",
"timePeriod" : {
"start" : "2010-07-12T00:00:00.000Z",
"finish" : "2010-07-12T00:00:00.000Z"
}
}
}, {
"name" : "IPT Mazatlan, Mexico",
"dateTime" : {
"path" : "/p:Action/p:plannedTime",
"timePeriod" : {
"start" : "2010-07-13T00:00:00.000Z",
"finish" : "2010-07-13T00:00:00.000Z"
}
}
}, {
"name" : "IPT Cabo San Lucas, Mexico",
"dateTime" : {
"path" : "/p:Action/p:plannedTime",
"timePeriod" : {
"start" : "2010-07-14T00:00:00.000Z",
"finish" : "2010-07-14T00:00:00.000Z"
}
}
}, {
"name" : "U/W Los Angeles, California",
"dateTime" : {
"path" : "/p:Action/p:plannedTime",
"timePeriod" : {
"start" : "2010-07-15T00:00:00.000Z",
"finish" : "2010-07-15T00:00:00.000Z"
}
}
}, {
"name" : "IPT Los Angeles, California",
"dateTime" : {
"path" : "/p:Action/p:plannedTime",
"timePeriod" : {
"start" : "2010-07-16T00:00:00.000Z",
"finish" : "2010-07-16T00:00:00.000Z"
}
}
}, {
"name" : "IPT Los Angeles, California",
"dateTime" : {
"path" : "/p:Action/p:plannedTime",
"timePeriod" : {
"start" : "2010-07-16T00:00:00.000Z",
"finish" : "2010-07-16T00:00:00.000Z"
}
}
}, {
"name" : "U/W Los Angeles, California",
"dateTime" : {
"path" : "/p:Action/p:plannedTime",
"timePeriod" : {
"start" : "2010-07-15T00:00:00.000Z",
"finish" : "2010-07-15T00:00:00.000Z"
}
}
}, {
"name" : "IPT Cabo San Lucas, Mexico",
"dateTime" : {
"path" : "/p:Action/p:plannedTime",
"timePeriod" : {
"start" : "2010-07-14T00:00:00.000Z",
"finish" : "2010-07-14T00:00:00.000Z"
}
}
}, {
"name" : "IPT Mazatlan, Mexico",
"dateTime" : {
"path" : "/p:Action/p:plannedTime",
"timePeriod" : {
"start" : "2010-07-13T00:00:00.000Z",
"finish" : "2010-07-13T00:00:00.000Z"
}
}
}, {
"name" : "IPT Puerto Vallarta, Mexico",
"dateTime" : {
"path" : "/p:Action/p:plannedTime",
"timePeriod" : {
"start" : "2010-07-12T00:00:00.000Z",
"finish" : "2010-07-12T00:00:00.000Z"
}
}
}, {
"name" : "IPT Ixtapa, Mexico",
"dateTime" : {
"path" : "/p:Action/p:plannedTime",
"timePeriod" : {
"start" : "2010-07-11T00:00:00.000Z",
"finish" : "2010-07-11T00:00:00.000Z"
}
}
}, {
"name" : "IPT Acapulco, Mexico",
"dateTime" : {
"path" : "/p:Action/p:plannedTime",
"timePeriod" : {
"start" : "2010-07-10T00:00:00.000Z",
"finish" : "2010-07-10T00:00:00.000Z"
}
}
}, {
"name" : "U/W Acapulco, Mexico",
"dateTime" : {
"path" : "/p:Action/p:plannedTime",
"timePeriod" : {
"start" : "2010-07-07T00:00:00.000Z",
"finish" : "2010-07-09T00:00:00.000Z"
}
}
}, {
"name" : "IPT Los Angeles, California",
"dateTime" : {
"path" : "/p:Action/p:plannedTime",
"timePeriod" : {
"start" : "2010-07-06T00:00:00.000Z",
"finish" : "2010-07-06T00:00:00.000Z"
}
}
}, {
"name" : "IPT Los Angeles, California",
"dateTime" : {
"path" : "/p:Action/p:plannedTime",
"timePeriod" : {
"start" : "2010-07-06T00:00:00.000Z",
"finish" : "2010-07-06T00:00:00.000Z"
}
}
}, {
"name" : "U/W Acapulco, Mexico",
"dateTime" : {
"path" : "/p:Action/p:plannedTime",
"timePeriod" : {
"start" : "2010-07-07T00:00:00.000Z",
"finish" : "2010-07-09T00:00:00.000Z"
}
}
}, {
"name" : "IPT Acapulco, Mexico",
"dateTime" : {
"path" : "/p:Action/p:plannedTime",
"timePeriod" : {
"start" : "2010-07-10T00:00:00.000Z",
"finish" : "2010-07-10T00:00:00.000Z"
}
}
}, {
"name" : "IPT Ixtapa, Mexico",
"dateTime" : {
"path" : "/p:Action/p:plannedTime",
"timePeriod" : {
"start" : "2010-07-11T00:00:00.000Z",
"finish" : "2010-07-11T00:00:00.000Z"
}
}
}, {
"name" : "IPT Puerto Vallarta, Mexico",
"dateTime" : {
"path" : "/p:Action/p:plannedTime",
"timePeriod" : {
"start" : "2010-07-12T00:00:00.000Z",
"finish" : "2010-07-12T00:00:00.000Z"
}
}
}, {
"name" : "IPT Mazatlan, Mexico",
"dateTime" : {
"path" : "/p:Action/p:plannedTime",
"timePeriod" : {
"start" : "2010-07-13T00:00:00.000Z",
"finish" : "2010-07-13T00:00:00.000Z"
}
}
}, {
"name" : "IPT Cabo San Lucas, Mexico",
"dateTime" : {
"path" : "/p:Action/p:plannedTime",
"timePeriod" : {
"start" : "2010-07-14T00:00:00.000Z",
"finish" : "2010-07-14T00:00:00.000Z"
}
}
}, {
"name" : "U/W Los Angeles, California",
"dateTime" : {
"path" : "/p:Action/p:plannedTime",
"timePeriod" : {
"start" : "2010-07-15T00:00:00.000Z",
"finish" : "2010-07-15T00:00:00.000Z"
}
}
}, {
"name" : "IPT Los Angeles, California",
"dateTime" : {
"path" : "/p:Action/p:plannedTime",
"timePeriod" : {
"start" : "2010-07-16T00:00:00.000Z",
"finish" : "2010-07-16T00:00:00.000Z"
}
}
} ]
} ]
} ]
}

##### to:
{
"name" : "Daily Ops Update",
"type" : "Undefined",
"subplanList" : [ {
"name" : "Ships Schedules",
"type" : "LineOfOperation",
"subplanList" : [ {
"name" : "SAPPHIRE PRINCESS",
"type" : "Undefined",
"actionList" : [ {
"name" : "IPT Los Angeles, California",
"dateTime" : {
"path" : "/p:Action/p:plannedTime",
"timePeriod" : {
"start" : "2012-08-16T00:00:00.000Z",
"finish" : "2012-08-16T23:59:59.999Z"
}
}
}, {
"name" : "U/W Acapulco, Mexico",
"dateTime" : {
"path" : "/p:Action/p:plannedTime",
"timePeriod" : {
"start" : "2012-08-17T00:00:00.000Z",
"finish" : "2012-08-19T23:59:59.999Z"
}
}
}, {
"name" : "IPT Acapulco, Mexico",
"dateTime" : {
"path" : "/p:Action/p:plannedTime",
"timePeriod" : {
"start" : "2012-08-20T00:00:00.000Z",
"finish" : "2012-08-20T23:59:59.999Z"
}
}
}, {
"name" : "IPT Ixtapa, Mexico",
"dateTime" : {
"path" : "/p:Action/p:plannedTime",
"timePeriod" : {
"start" : "2012-08-21T00:00:00.000Z",
"finish" : "2012-08-21T23:59:59.999Z"
}
}
}, {
"name" : "IPT Puerto Vallarta, Mexico",
"dateTime" : {
"path" : "/p:Action/p:plannedTime",
"timePeriod" : {
"start" : "2012-08-22T00:00:00.000Z",
"finish" : "2012-08-22T23:59:59.999Z"
}
}
}, {
"name" : "IPT Mazatlan, Mexico",
"dateTime" : {
"path" : "/p:Action/p:plannedTime",
"timePeriod" : {
"start" : "2012-08-23T00:00:00.000Z",
"finish" : "2012-08-23T23:59:59.999Z"
}
}
}, {
"name" : "IPT Cabo San Lucas, Mexico",
"dateTime" : {
"path" : "/p:Action/p:plannedTime",
"timePeriod" : {
"start" : "2012-08-24T00:00:00.000Z",
"finish" : "2012-08-24T23:59:59.999Z"
}
}
}, {
"name" : "U/W Los Angeles, California",
"dateTime" : {
"path" : "/p:Action/p:plannedTime",
"timePeriod" : {
"start" : "2012-08-25T00:00:00.000Z",
"finish" : "2012-08-25T23:59:59.999Z"
}
}
}, {
"name" : "IPT Los Angeles, California",
"dateTime" : {
"path" : "/p:Action/p:plannedTime",
"timePeriod" : {
"start" : "2012-08-26T00:00:00.000Z",
"finish" : "2012-09-02T23:59:59.999Z"
}
}
} ],
"dateTime" : {
"path" : "/p:Plan/p:timeFrame"
}
} ],
"dateTime" : {
"path" : "/p:Plan/p:timeFrame"
}
} ],
"dateTime" : {
"path" : "/p:Plan/p:timeFrame"
}
}