2

I am working on an assignment and I thought I figured out the issue, but I am getting the same results. Using the FindBugs application I was able to see a big with the following line of code:

out.writeObject(accountMap.get(i));

I received a bug that said:

Integer is incompatible with expected argument type String in...

So I corrected it by converting the int to a String with:

out.writeObject(accountMap.get(Integer.toString(i)));

With the same bug results. Am I misunderstanding something?

Chris Moretti
  • 585
  • 3
  • 13
  • 31

1 Answers1

6

I recreated your problem and Findbugs found the same error. So far so good.

Integer is incompatible with expected argument type String in ...(String[]) [Scariest(1), High confidence]

Then I applied your change (Integer.toString(i)) and discovered when running Findbugs again, the bug cleared (which differs from your observation).

I suspect you did not re-run findbugs?

I tested with Findbugs version: 3.0.1.20150306-5afe4d1

PS: Here is some history as to why there is a bug at all (relating to Map#get not using generics): Why is java.util.Map.get(...) not generic?

Community
  • 1
  • 1
Ian Mc
  • 5,656
  • 4
  • 18
  • 25
  • Got it working. For some reason, I had to restart eclipse. I was re-running the Find Bugs function, and although it was giving me the UI feedback as if it was running...it was simply redisplaying the same results. This applied to all of my bugs. Now I am able to actually verify my fixes are being implemented. Thanks! – Chris Moretti Feb 13 '16 at 04:42