Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ObjectName incompatible with String FindBug error

Tags:

java

findbugs

For my production code resembling the following:

public something xyz(String name) {
  return getSomething(abc.get(name));
}

Where the method "get" expects javax.management.ObjectName to be passed to it, I am getting the following high priority warning from the Findbugs tool:

Bug: String is incompatible with expected argument type javax.management.ObjectName
Pattern id: GC_UNRELATED_TYPES, type: GC, category: CORRECTNESS

However, according to javax API docs, I see that one can have ObjectName as a String, as shown on: http://download.oracle.com/javase/6/docs/api/javax/management/ObjectName.html

Is this a problem with Findbugs or am I missing something?

like image 951
Dhruv Avatar asked Apr 06 '26 02:04

Dhruv


1 Answers

public something xyz(String name) {
    return getSomething(abc.get(new ObjectName(name)));
}
like image 146
xthexder Avatar answered Apr 08 '26 15:04

xthexder