johnnadratowski / golang-neo4j-bolt-driver

Golang Bolt driver for Neo4j
MIT License
213 stars 72 forks source link

Use of nil reference when connection cannot be opened. #67

Closed kingbhanu closed 4 years ago

kingbhanu commented 4 years ago

Yes, the connections ideally should not be closed in case of error. I am updating the PR.

kingbhanu commented 4 years ago

Also should I return any error if connection is found nil or just return error as nil?

scott-wilson commented 4 years ago

Hmm. Hard to say. I'm not sure if anything depends on that, so probably run the checks before you push an error if the conn is nil. Otherwise, I see no issue with it.

collisonchris commented 4 years ago

Calling close on a nil connection seems like it should throw an error back but it doesn't look like it is coded that way today. Go won't panic on a function call of a nil struct pointer so it'd be up to the programmer to handle these situations as desired.

Though, I'm not sure what a caller would expect trying to call close on a nil connection object. Technically, it's closed if its nil, returning the error would more or less inform the caller the Conn is nil.

Think I'd be ok with keeping it the way it is currently.