Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-53080

Service builder generated compareTo method breaks method general contract if order by field is boolean

    Details

      Description

      service builder generates crazy compareTo method if the first field in service.xml order-by node is boolean type. Generated code sample:

      @Override
      	public int compareTo(ExampleEntry exampleEntry) {
      		int value = 0;
      
      		if (getActive() == exampleEntry.getActive()) {
      			value = -1;
      		}
      		else if (getActive() != exampleEntry.getActive()) {
      			value = 1;
      		}
      		else {
      			value = 0;
      		}
      

      This is obvious bug, and it breaks in runtime in Java7, it throws an error with message "Comparison method violates its general contract..."

        Attachments

          Activity

            People

            • Assignee:
              brian.chan Brian Chan
              Reporter:
              igor.beslic Igor Beslic
              Participants of an Issue:
              Recent user:
              Esther Sanz
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Days since last comment:
                4 years, 34 weeks, 2 days ago

                Packages

                Version Package
                7.0.0 M4