Skip to content

Commit 7afc68f

Browse files
Peter Wilhelmsson2hdddg
authored andcommitted
Do not defer in loop
Defers will potentially grow too much.
1 parent 2845b48 commit 7afc68f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

neo4j/internal/router/readtable.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,18 @@ func readTable(ctx context.Context, pool Pool, database string, routers []string
4545
err = wrapInReadRoutingTableError(router, err)
4646
continue
4747
}
48-
defer pool.Return(conn)
4948

5049
discovery, ok := conn.(db.ClusterDiscovery)
5150
if !ok {
5251
err = &db.RoutingNotSupportedError{Server: conn.ServerName()}
5352
err = wrapInReadRoutingTableError(router, err)
53+
pool.Return(conn)
5454
continue
5555
}
5656

5757
var table *db.RoutingTable
5858
table, err = discovery.GetRoutingTable(database, routerContext)
59+
pool.Return(conn)
5960
if err == nil {
6061
return table, nil
6162
}

0 commit comments

Comments
 (0)