Description
Describe the bug
I recently came across the java.lang.IllegalArgumentException
in Authorization Code flow with JdbcOAuth2AuthorizationService
. More info on the issue has been discussed in #397.
While investigating this issue, I could not identify the exact point that this error pops up and had to add debug points and struggle to identify the line that was failing.
Upon inspecting the code, I noticed in the findBy
method, a try block is used without a catch block.
private OAuth2Authorization findBy(String filter, List<SqlParameterValue> parameters) {
try (LobCreator lobCreator = getLobHandler().getLobCreator()) {
PreparedStatementSetter pss = new LobCreatorArgumentPreparedStatementSetter(lobCreator,
parameters.toArray());
List<OAuth2Authorization> result = getJdbcOperations().query(LOAD_AUTHORIZATION_SQL + filter, pss, getAuthorizationRowMapper());
return !result.isEmpty() ? result.get(0) : null;
}
}
It would be easy to identify the error if we can have a catch block and handle this error properly.
To Reproduce
Please refer to #397.
Expected behavior
Handle the errors in findBy
method with a catch block.
Sample
private OAuth2Authorization findBy(String filter, List<SqlParameterValue> parameters) {
try (LobCreator lobCreator = getLobHandler().getLobCreator()) {
PreparedStatementSetter pss = new LobCreatorArgumentPreparedStatementSetter(lobCreator,
parameters.toArray());
List<OAuth2Authorization> result = getJdbcOperations().query(LOAD_AUTHORIZATION_SQL + filter, pss, getAuthorizationRowMapper());
return !result.isEmpty() ? result.get(0) : null;
} catch (Exception e){
....handle the exception
}
}
Reports that include a sample will take priority over reports that do not.
At times, we may require a sample, so it is good to try and include a sample up front.