Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
bgColor#CCCCFF
public class ShortSet {
  public static void main(String[] args) {
    HashSet<Short> s = new HashSet<Short>();
      for(short i=0; i<100;i++) {
        s.add(i);
        s.remove((short)(i-1));  //cast to short 
      }
    System.out.println(s.size());
  }
}

Risk Assessment

TODONumeric promotion and autoboxing while removing elements from a Collection, can make operations on the Collection fail silently.

Recommendation

Severity

Likelihood

Remediation Cost

Priority

Level

EXP05- J

low

probable

high low

P2 P6

L3 L2

Related Vulnerabilities

Search for vulnerabilities resulting from the violation of this rule on the CERT website.

...