NullPointerException in disconnect method

Description

Sometimes when the disconnect method of ShardedSessionImpl is called a NullPointerException occurs

This happened when attaching the OpenSessionInViewFilter to a shardSessionFactory

Here is the fixed method (validate that the session is not null when calling disconnect:

public Connection disconnect() throws HibernateException {
for (Shard s : getShards()) {
Session sess = s.getSession();
if (sess != null) {
sess.disconnect();
}
}
// we do not allow application-supplied connections, so we can always return
// null
return null;
}

Environment

None
Fixed

Assignee

Max Ross

Reporter

Aviad Lichtenstadt

Labels

None

Feedback Requested

None

Feedback Requested By

None

backPortable

None

Suitable for new contributors

None

Pull Request

None

backportDecision

None

backportReEvaluate

None

Fix versions

Affects versions

Priority

Major
Configure