You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by jh...@apache.org on 2017/08/11 01:50:38 UTC
[41/50] calcite-avatica-go git commit: Return an ErrBadConn from the
http client if the connection does not exist on the Avatica server
Return an ErrBadConn from the http client if the connection does not exist on the Avatica server
Project: http://git-wip-us.apache.org/repos/asf/calcite-avatica-go/repo
Commit: http://git-wip-us.apache.org/repos/asf/calcite-avatica-go/commit/7c64be85
Tree: http://git-wip-us.apache.org/repos/asf/calcite-avatica-go/tree/7c64be85
Diff: http://git-wip-us.apache.org/repos/asf/calcite-avatica-go/diff/7c64be85
Branch: refs/heads/master
Commit: 7c64be85992435eefe3e3eebed4245a661d5b487
Parents: 38a538f
Author: Francis Chuang <fr...@boostport.com>
Authored: Tue Jul 18 15:38:46 2017 +1000
Committer: Julian Hyde <jh...@apache.org>
Committed: Thu Aug 10 18:47:12 2017 -0700
----------------------------------------------------------------------
http_client.go | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/calcite-avatica-go/blob/7c64be85/http_client.go
----------------------------------------------------------------------
diff --git a/http_client.go b/http_client.go
index 418ab5c..0d43934 100644
--- a/http_client.go
+++ b/http_client.go
@@ -2,10 +2,11 @@ package avatica
import (
"bytes"
+ "database/sql/driver"
+ "fmt"
"io/ioutil"
"net/http"
-
- "fmt"
+ "regexp"
avaticaMessage "github.com/Boostport/avatica/message"
"github.com/golang/protobuf/proto"
@@ -19,6 +20,10 @@ import (
"golang.org/x/net/context/ctxhttp"
)
+var (
+ badConnRe = regexp.MustCompile(`org\.apache\.calcite\.avatica\.NoSuchConnectionException`)
+)
+
type httpClientAuthConfig struct {
authenticationType authentication
@@ -176,6 +181,13 @@ func (c *httpClient) post(ctx context.Context, message proto.Message) (proto.Mes
}
if v, ok := inner.(*avaticaMessage.ErrorResponse); ok {
+
+ for _, exception := range v.Exceptions {
+ if badConnRe.MatchString(exception) {
+ return nil, driver.ErrBadConn
+ }
+ }
+
return nil, errorResponseToResponseError(v)
}