search cancel

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

book

Article ID: 42563

calendar_today

Updated On:

Products

STARTER PACK-7 CA Rapid App Security CA API Gateway

Issue/Introduction

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(TimSort.java:868)
at java.util.TimSort.mergeAt(TimSort.java:485)
at java.util.TimSort.mergeForceCollapse(TimSort.java:426)
at java.util.TimSort.sort(TimSort.java:223)
at java.util.TimSort.sort(TimSort.java:173)
at java.util.Arrays.sort(Arrays.java:659)
at java.util.Collections.sort(Collections.java:217)
at com.whirlycott.cache.policy.LFUMaintenancePolicy.performMaintenance(Unknown Source)
at com.whirlycott.cache.CacheDecorator.run(Unknown Source)
at java.lang.Thread.run(Thread.java:722)

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.

Environment

Release:
Component: APIGTW

Resolution


  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/ssgruntimedefs.sh
  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