Best solution for a Sonar issue related to "throws"

Viewed 4376

I am using SonarQube to improve coding quality but I got a bug here that I don't know the best solution.

I call a Spring's method with the following signature:

T read() throws Exception, UnexpectedInputException, ParseException, 
NonTransientResourceException;

As I just have to call this method and I have no intention to treat any error, I defined my method like this:

ItemTransacaoEnvioVO read() throws 
UnexpectedInputException, ParseException, NonTransientResourceException,  
Exception 

But I get this Sonar bug:

Remove the declaration of thrown exception 
'org.springframework.batch.item.ParseException' which is a subclass of 
'java.lang.Exception'
...
etc

Then I changed like Sonar wants:

ItemTransacaoEnvioVO read() throws Exception  

And I get this:

Define and throw a dedicated exception instead of using a generic one.  

Thinking in the best practices and coding quality what would be the best solution for this problem?

Java 8, Sonar

2 Answers
Related