Opened 12 years ago

Closed 12 years ago

#1313 closed defect (fixed)

jdbc: org.postgis.Point.equals() is not reflexive

Reported by: slava Owned by: pramsey
Priority: high Milestone: PostGIS 2.0.0
Component: java Version: 1.5.X
Keywords: Cc:

Description

The following test fails:

> cat test.java
import org.postgis.Point;

class test
{
    public static void main(String[] args)
		{
			Point p = new Point(1, 2, Double.NaN);
			assert p.equals(p) : "Equals must be reflexive";
			System.out.println("Ok");
		}
}

> javac -classpath postgis-2.0.0SVN.jar test.java && java -classpath postgis-2.0.0SVN.jar:. -ea test
Exception in thread "main" java.lang.AssertionError: Equals must be reflexive
	at test.main(test.java:8)

There is a bug in Point.equals definition: it does not work as expected if the point contains NaN data field, violating on of the basic equals rule: reflexivity.

The practical implication of the bug is for example eclipse databingins going into infinite loop firing notification for such a point ending in StackOverflowError.

Change History (3)

comment:1 by strk, 12 years ago

Component: postgisJava bindings
Owner: changed from pramsey to delawen

comment:2 by pramsey, 12 years ago

Owner: changed from delawen to pramsey

Trunk at r9211

1.5 branch at r9212

comment:3 by pramsey, 12 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.