[SCUFL2-81] BlockingControlLink compare method fails to handle null block or untilFinished Created: 2011-08-17  Updated: 2013-04-23  Resolved: 2012-07-09

Status: Resolved
Project: Scufl 2
Component/s: scufl parser
Affects Version/s: None
Fix Version/s: 0.11.0

Type: Bug Priority: Critical
Reporter: Christian Brenninkmeijer Assignee: Stian Soiland-Reyes
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Any - Noticed in Windows and Java 7



 Description   

BlockingControlLink allows both block and untilFinished to be null.

methond compareTo(Object o) calls copare(Object o) without first checking if they are null
This causes a null pointer exception.

Fix:
public int compareTo(Object o) {
if (!(o instanceof BlockingControlLink))

{ return o.getClass().getCanonicalName().compareTo(getClass().getCanonicalName()); }

BlockingControlLink o1 = this;
BlockingControlLink o2 = (BlockingControlLink) o;

if ( o1.getUntilFinished() == null){
if (o2.getUntilFinished() == null)

{ return 1; }
} else {
int untilFinished = o1.getUntilFinished().compareTo(o2.getUntilFinished());
if (untilFinished != 0) { return untilFinished; }
}

if (o1.getBlock() == null) {
if (o2.getBlock() == null){ return 0; } else { return 1; }

}
int block = o1.getBlock().compareTo(o2.getBlock());
return block;
}



 Comments   
Comment by Christian Brenninkmeijer [ 2011-08-17 ]

BUG in the FIX!
if (o2.getUntilFinished() == null)

{ return 1; }
should be
if (o2.getUntilFinished() != null){ return 1; }
Comment by Stian Soiland-Reyes [ 2012-07-09 ]

This was already fixed, but added a test case.

Comment by Jenkins Automated build [ 2012-07-09 ]

Integrated in scufl2 #3469
SCUFL2-81 Tests for control link null compare (Revision 53c1146647ed0e4bc7f8ad827859633b3a78da40)
SCUFL2-81 Use NullSafeComparator (Revision 6eaf81d59b2ba2edbf763895a3c8411176ab42cd)

Result = SUCCESS
stian : 53c1146647ed0e4bc7f8ad827859633b3a78da40
Files :

  • scufl2-api/src/test/java/uk/org/taverna/scufl2/api/core/ControlLinkCompareTest.java

stian : 6eaf81d59b2ba2edbf763895a3c8411176ab42cd
Files :

  • scufl2-api/src/main/java/uk/org/taverna/scufl2/api/core/BlockingControlLink.java
Comment by Jenkins Automated build [ 2012-07-13 ]

Integrated in scufl2 #3471
SCUFL2-81 Tests for control link null compare (Revision 53c1146647ed0e4bc7f8ad827859633b3a78da40)
SCUFL2-81 Use NullSafeComparator (Revision 6eaf81d59b2ba2edbf763895a3c8411176ab42cd)

Result = SUCCESS
stian : 53c1146647ed0e4bc7f8ad827859633b3a78da40
Files :

  • scufl2-api/src/test/java/uk/org/taverna/scufl2/api/core/ControlLinkCompareTest.java

stian : 6eaf81d59b2ba2edbf763895a3c8411176ab42cd
Files :

  • scufl2-api/src/main/java/uk/org/taverna/scufl2/api/core/BlockingControlLink.java
Comment by Jenkins Automated build [ 2012-10-05 ]

Integrated in scufl2 #3488
SCUFL2-81 Tests for control link null compare (Revision f3391ba89e0f7860fbd2ab2c92976f9db46512d0)
SCUFL2-81 Use NullSafeComparator (Revision 30552451b3a553922695bcf5daef2e1a007ab564)

Result = SUCCESS
stian@mygrid.org.uk : f3391ba89e0f7860fbd2ab2c92976f9db46512d0
Files :

  • scufl2-api/src/test/java/uk/org/taverna/scufl2/api/core/ControlLinkCompareTest.java

stian@mygrid.org.uk : 30552451b3a553922695bcf5daef2e1a007ab564
Files :

  • scufl2-api/src/main/java/uk/org/taverna/scufl2/api/core/BlockingControlLink.java
Generated at Wed Aug 21 20:04:16 BST 2019 using JIRA 6.1.2#6157-sha1:98c729218aad6de1537eb8e98889ee5562c90d96.