This is an automated email from the ASF dual-hosted git repository.

rob pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-trafficcontrol.git


The following commit(s) were added to refs/heads/master by this push:
     new 04797ed  Add missing Close() deferral after DB queries
04797ed is described below

commit 04797ed4dbe4bb26c7dc55fe71bce33ad64a8f4b
Author: Rawlin Peters <rawlin_pet...@comcast.com>
AuthorDate: Wed Jun 6 08:03:06 2018 -0600

    Add missing Close() deferral after DB queries
    
    The 1.1/profiles/trimmed and 1.1/phys_locations/trimmed endpoints were
    missing a deferred Close() after initializing a Query().
---
 traffic_ops/traffic_ops_golang/physlocation/trimmed.go | 1 +
 traffic_ops/traffic_ops_golang/profile/trimmed.go      | 3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/traffic_ops/traffic_ops_golang/physlocation/trimmed.go 
b/traffic_ops/traffic_ops_golang/physlocation/trimmed.go
index 15f293e..99f0b5b 100644
--- a/traffic_ops/traffic_ops_golang/physlocation/trimmed.go
+++ b/traffic_ops/traffic_ops_golang/physlocation/trimmed.go
@@ -39,6 +39,7 @@ func getTrimmed(db *sql.DB) ([]tc.PhysLocationTrimmed, error) 
{
        if err != nil {
                return nil, errors.New("querying trimmed physical locations: " 
+ err.Error())
        }
+       defer rows.Close()
        ps := []tc.PhysLocationTrimmed{}
        for rows.Next() {
                name := ""
diff --git a/traffic_ops/traffic_ops_golang/profile/trimmed.go 
b/traffic_ops/traffic_ops_golang/profile/trimmed.go
index 114dcbe..adb2e89 100644
--- a/traffic_ops/traffic_ops_golang/profile/trimmed.go
+++ b/traffic_ops/traffic_ops_golang/profile/trimmed.go
@@ -20,8 +20,8 @@ package profile
  */
 
 import (
-       "errors"
        "database/sql"
+       "errors"
        "net/http"
 
        "github.com/apache/incubator-trafficcontrol/lib/go-tc"
@@ -39,6 +39,7 @@ func getTrimmedProfiles(db *sql.DB) ([]tc.ProfileTrimmed, 
error) {
        if err != nil {
                return nil, errors.New("querying trimmed profiles: " + 
err.Error())
        }
+       defer rows.Close()
        profiles := []tc.ProfileTrimmed{}
        for rows.Next() {
                name := ""

-- 
To stop receiving notification emails like this one, please contact
r...@apache.org.

Reply via email to