[GitHub] brooklyn-client pull request: Close config file object (deferred c...

2016-03-19 Thread lyubenblagoev
GitHub user lyubenblagoev opened a pull request:

https://github.com/apache/brooklyn-client/pull/9

Close config file object (deferred close)



You can merge this pull request into a Git repository by running:

$ git pull https://github.com/lyubenblagoev/brooklyn-client 
close_config_file_objects

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/brooklyn-client/pull/9.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #9


commit daf8fea098c4ff2e9ea2468ae7f9cf73c69a40dc
Author: Lyuben Blagoev 
Date:   2016-03-17T07:33:28Z

Close config file object (deferred close)




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] brooklyn-client pull request: Close config file object (deferred c...

2016-03-19 Thread lyubenblagoev
Github user lyubenblagoev commented on a diff in the pull request:

https://github.com/apache/brooklyn-client/pull/9#discussion_r56662228
  
--- Diff: io/config.go ---
@@ -64,6 +65,8 @@ func (config *Config) Read() {
if err != nil {
error_handler.ErrorExit(err)
}
+   defer fileToRead.Close()
--- End diff --

The same as above file; `os.OpenFile` returns file, nil or nil, err, but 
not both file object and error.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] brooklyn-client pull request: Close config file object (deferred c...

2016-03-19 Thread lyubenblagoev
Github user lyubenblagoev commented on a diff in the pull request:

https://github.com/apache/brooklyn-client/pull/9#discussion_r56662094
  
--- Diff: io/config.go ---
@@ -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()
--- End diff --

Nope. `os.OpenFile` will return the file object and nil as an error, or nil 
and the error in case of an error.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] brooklyn-client pull request: Close config file object (deferred c...

2016-03-19 Thread lyubenblagoev
Github user lyubenblagoev commented on the pull request:

https://github.com/apache/brooklyn-client/pull/9#issuecomment-198671695
  
@aledsage, I've completed and submitted ICLA by email, as described in the 
link provided by @rdowner.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] brooklyn-client pull request: Close config file object (deferred c...

2016-03-19 Thread geomacy
Github user geomacy commented on a diff in the pull request:

https://github.com/apache/brooklyn-client/pull/9#discussion_r56660301
  
--- Diff: io/config.go ---
@@ -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()
--- End diff --

Should this be inside the "if" statement above?   What does OpenFile return 
in the first arg if the second is an err?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] brooklyn-client pull request: Close config file object (deferred c...

2016-03-18 Thread aledsage
Github user aledsage commented on the pull request:

https://github.com/apache/brooklyn-client/pull/9#issuecomment-198583998
  
Thanks @lyubenblagoev - are you happy to submit a standard Contributor 
License Agreement, as described by @rdowner above? Can you let us know when 
you've done that and we'll very happily merge this!


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] brooklyn-client pull request: Close config file object (deferred c...

2016-03-18 Thread geomacy
Github user geomacy commented on a diff in the pull request:

https://github.com/apache/brooklyn-client/pull/9#discussion_r56660403
  
--- Diff: io/config.go ---
@@ -64,6 +65,8 @@ func (config *Config) Read() {
if err != nil {
error_handler.ErrorExit(err)
}
+   defer fileToRead.Close()
--- End diff --

same here of course


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---