#224 FindUnrelatedTypesInGenericContainer raises false alarm

closed-fixed
Keith Lea
detectors (11)
5
2013-11-21
2010-02-15
Michael Tamm
No

Hi,

I found out, that the FindUnrelatedTypesInGenericContainer raises a false alarm
if the invoked method takes null as an argument.

Here is an example class which provokes this:
________________________________________________

import java.util.*;

public class MemorySavingStringSet {

private final Set<byte\[\]> \_set = new HashSet<byte\[\]>\(\);

public void add\(String s\) \{
    \_set.add\(s == null ? null : s.getBytes\(\)\);
\}

public boolean contains\(String s\) \{
    return \(s == null ? containsNull\(\) : \_set.contains\(s.getBytes\(\)\)\);
\}

public boolean containsNull\(\) \{
    // This should not raise an alarm ...
    return \_set.contains\(null\);
\}

}
________________________________________________

I have attached a patch to fix this.

Regards, Michael

Discussion

  • Michael Tamm
    Michael Tamm
    2010-02-15

    • labels: --> detectors
     
  • Keith Lea
    Keith Lea
    2010-03-17

    Patch applied, thanks!

     
  • Keith Lea
    Keith Lea
    2010-03-17

    • assigned_to: nobody --> kano
    • status: open --> closed-fixed