search cancel

Resolving the "Comparison method violates its general contract!" error


Article ID: 42563


Updated On:


STARTER PACK-7 CA Rapid App Security CA API Gateway


The API Gateway uses WhirlyCache as a tool set to provide persistence and shared object caching in Java applications. A defect in this tool set may result in error messages, degradation or performance, or--in extreme circumstances--Gateway crashes. The API Gateway needs to be reconfigured in version 7.0 and earlier to accommodate for this defect. Version 7.1.0 and later are not impacted by this issue.

The following log and stack trace may occur:

SEVERE 118 com.whirlycott.cache.CacheDecorator: Unexpected error in tuning thread...
java.lang.IllegalArgumentException: Comparison method violates its general contract!
at java.util.TimSort.mergeHi(
at java.util.TimSort.mergeAt(
at java.util.TimSort.mergeForceCollapse(
at java.util.TimSort.sort(
at java.util.TimSort.sort(
at java.util.Arrays.sort(
at java.util.Collections.sort(
at com.whirlycott.cache.policy.LFUMaintenancePolicy.performMaintenance(Unknown Source)
at Source)

This stack trace may be accompanied by a degradation of performance or Gateway crashes. The key symptom of the issue is the aforementioned log and stack trace.


Component: APIGTW


  1. Log in to the API Gateway and access the privileged shell (root)
  2. Open the Gateway runtime definitions script in a text editor: vi /opt/SecureSpan/Gateway/runtime/etc/profile.d/
  3. Add the following directive at or after line 8: default_java_opts="$default_java_opts -Djava.util.Arrays.useLegacyMergeSort=true "
  4. Save the file and exit the editor
  5. Restart the Gateway appliance