S2095 report on method return Connection


(ori marko) #1

Methods returning Connection object, still gets a S2095 warning

For example

public Connection getConnection() throws SQLException {
	Connection result = dataSource.getConnection();
	return result;

I want to return a Connection I can use, so I can’t close it in those methods.

Should there be a warning in such cases where connection should be left open?

Similar methods can be found in HikariConnectionProvider