xml.ui: Bug 495415: Safely absolute a hashcode
[deliverable/tracecompass.git] / tmf / org.eclipse.tracecompass.tmf.analysis.xml.ui / src / org / eclipse / tracecompass / internal / tmf / analysis / xml / ui / views / timegraph / XmlPresentationProvider.java
index d83a8b300a47242fdc09cfb2b30737ac5a64c99f..f848f1af17f1f33c98f33ace57775e7cb83fa220 100644 (file)
@@ -212,8 +212,8 @@ public class XmlPresentationProvider extends TimeGraphPresentationProvider {
      * display identically states with the same name.
      */
     private static RGB calcColor(String name) {
-        int hash = name.hashCode();
-        long base = COLOR_SEED[Math.abs(hash) % COLOR_SEED.length];
+        long hash = name.hashCode(); // hashcodes can be Integer.MIN_VALUE.
+        long base = COLOR_SEED[(int) (Math.abs(hash) % COLOR_SEED.length)];
         int x = (int) ((hash & COLOR_MASK) ^ base);
         final int r = (x >> 16) & 0xff;
         final int g = (x >> 8) & 0xff;
This page took 0.02458 seconds and 5 git commands to generate.