1

I have statement:

MongoClient client = new MongoClient(uri);

and there si warning:

[Java] Resource leak: 'client' is never closed

According to Do I need to explicitly close connection?, I don't need to close connection.

How can I suppress this warning? @SuppressWarnings("???")

Frido
  • 382
  • 5
  • 14

1 Answers1

4

Adding the @SuppressWarnings({ "resource" }) should remove the warning for a potential resource leak. Adding a list for other ones, it's for Eclipse but they should be fairly similar for reference.

What is the list of valid @SuppressWarnings warning names in Java?

mep
  • 431
  • 1
  • 4
  • 15
  • 3
    @SuppressWarnings is misspelled, but the wonderful nazi rules of stackoverflow don't allow me to edit it, because an edit needs to be at least 6 characters. Also, note that the braces are optional. – Erik Lievaart Feb 07 '19 at 22:58