Skip to content

Commit

Permalink
Improve session handling while fetching vehicle blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
vesavlad committed Mar 18, 2024
1 parent e6be215 commit 97b675c
Showing 1 changed file with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -398,14 +398,12 @@ public Collection<IpcVehicle> getVehiclesForBlocks() {
@Override
public Collection<IpcVehicleToBlockConfig> getVehicleToBlockConfig(String blockId) {
List<IpcVehicleToBlockConfig> result = new ArrayList<>();
Session session = HibernateUtils.getSession();
try {
try (Session session = HibernateUtils.getSession()){
for (VehicleToBlockConfig vTBC : VehicleToBlockConfig.getVehicleToBlockConfigsByBlockId(session, blockId)) {
result.add(new IpcVehicleToBlockConfig(vTBC));
}
session.close();
} catch (Exception ex) {
session.close();
logger.error("Something happened while fetching the VehicleToBlockConfig.", ex);
}
return result;
}
Expand Down

0 comments on commit 97b675c

Please sign in to comment.