You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by al...@apache.org on 2016/03/19 23:30:39 UTC

[1/2] brooklyn-client git commit: Close config file object (deferred close)

Repository: brooklyn-client
Updated Branches:
  refs/heads/master bf696e55b -> 285013a19


Close config file object (deferred close)


Project: http://git-wip-us.apache.org/repos/asf/brooklyn-client/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-client/commit/daf8fea0
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-client/tree/daf8fea0
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-client/diff/daf8fea0

Branch: refs/heads/master
Commit: daf8fea098c4ff2e9ea2468ae7f9cf73c69a40dc
Parents: bf696e5
Author: Lyuben Blagoev <lb...@gmail.com>
Authored: Thu Mar 17 09:33:28 2016 +0200
Committer: Lyuben Blagoev <lb...@gmail.com>
Committed: Thu Mar 17 09:33:28 2016 +0200

----------------------------------------------------------------------
 io/config.go | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/daf8fea0/io/config.go
----------------------------------------------------------------------
diff --git a/io/config.go b/io/config.go
index 4ba80ab..ea9ca01 100644
--- a/io/config.go
+++ b/io/config.go
@@ -20,9 +20,10 @@ package io
 
 import (
 	"encoding/json"
-	"github.com/apache/brooklyn-client/error_handler"
 	"os"
 	"path/filepath"
+
+	"github.com/apache/brooklyn-client/error_handler"
 )
 
 type Config struct {
@@ -48,12 +49,12 @@ func GetConfig() (config *Config) {
 }
 
 func (config *Config) Write() {
-
 	// Create file as read/write by user (but does not change perms of existing file)
 	fileToWrite, err := os.OpenFile(config.FilePath, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0600)
 	if err != nil {
 		error_handler.ErrorExit(err)
 	}
+	defer fileToWrite.Close()
 
 	enc := json.NewEncoder(fileToWrite)
 	enc.Encode(config.Map)
@@ -64,6 +65,8 @@ func (config *Config) Read() {
 	if err != nil {
 		error_handler.ErrorExit(err)
 	}
+	defer fileToRead.Close()
+
 	dec := json.NewDecoder(fileToRead)
 	dec.Decode(&config.Map)
 }


[2/2] brooklyn-client git commit: This closes #9

Posted by al...@apache.org.
This closes #9


Project: http://git-wip-us.apache.org/repos/asf/brooklyn-client/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-client/commit/285013a1
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-client/tree/285013a1
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-client/diff/285013a1

Branch: refs/heads/master
Commit: 285013a19abad7f4bcb224e77ce2a86fcb38ea52
Parents: bf696e5 daf8fea
Author: Aled Sage <al...@gmail.com>
Authored: Sat Mar 19 22:30:30 2016 +0000
Committer: Aled Sage <al...@gmail.com>
Committed: Sat Mar 19 22:30:30 2016 +0000

----------------------------------------------------------------------
 io/config.go | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
----------------------------------------------------------------------