How to explicitly comment empty methods?

Madhu Sudhan Reddy picture Madhu Sudhan Reddy · Sep 2, 2013 · Viewed 9.1k times · Source
public void destroy() {
}

I have written above empty method in my filter class which is required as per the interface. But when my code goes to PMD check it mentions

Uncommented Empty Method finds instances where a method does not contain statements, but there is no comment. By explicitly commenting empty methods it is easier to distinguish between intentional (commented) and unintentional empty methods.

I do not understand it. What really does it mean?

Answer

When you have a method with an empty body, it is possible that you started writing the method and then forgot to insert the body. If you intend for the method to be empty, you should make a note (in a comment) to explain that it's empty on purpose. In the case of Filter, since you have to implement the destroy() method, you should write a comment that says something like "nothing to clean up".