From d7e09d57bab7b6dc1b750c2a5d6c45733d91b26c Mon Sep 17 00:00:00 2001 From: Atin Malaviya Date: Thu, 20 Nov 2014 19:16:07 -0500 Subject: [PATCH] Set empty Behavior setting into SessionKeysRelease and flag error for unrecognized values --- consul/session_endpoint.go | 5 +++-- consul/state_store.go | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/consul/session_endpoint.go b/consul/session_endpoint.go index f7e46636f..cfe60ea57 100644 --- a/consul/session_endpoint.go +++ b/consul/session_endpoint.go @@ -31,9 +31,10 @@ func (s *Session) Apply(args *structs.SessionRequest, reply *string) error { switch args.Session.Behavior { case structs.SessionKeysRelease, structs.SessionKeysDelete: // we like it, use it - - default: + case "": args.Session.Behavior = structs.SessionKeysRelease // force default behavior + default: + return fmt.Errorf("Invalid Behavior setting '%s'", args.Session.Behavior) } // If this is a create, we must generate the Session ID. This must diff --git a/consul/state_store.go b/consul/state_store.go index 2bd0396ef..0173cff69 100644 --- a/consul/state_store.go +++ b/consul/state_store.go @@ -1330,9 +1330,10 @@ func (s *StateStore) SessionCreate(index uint64, session *structs.Session) error switch session.Behavior { case structs.SessionKeysRelease, structs.SessionKeysDelete: // we like + case "": + session.Behavior = structs.SessionKeysRelease // force default behavior default: - // force SessionKeysRelease - session.Behavior = structs.SessionKeysRelease + return fmt.Errorf("Invalid Session Behavior setting '%s'", session.Behavior) } // Assign the create index