From 8367fc43d5a1489d4683197fad0ae363f6ee24a0 Mon Sep 17 00:00:00 2001
From: Areek Zillur <areek.zillur@elasticsearch.com>
Date: Fri, 17 Oct 2014 10:58:24 -0400
Subject: [PATCH] minor fix

Original commit: elastic/x-pack-elasticsearch@9552d8fbb186b1a9d3ce7aeac2d9b86d214833ed
---
 .../elasticsearch/license/plugin/core/LicensesService.java    | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/main/java/org/elasticsearch/license/plugin/core/LicensesService.java b/src/main/java/org/elasticsearch/license/plugin/core/LicensesService.java
index 6b269eedf9c..6ea462b4918 100644
--- a/src/main/java/org/elasticsearch/license/plugin/core/LicensesService.java
+++ b/src/main/java/org/elasticsearch/license/plugin/core/LicensesService.java
@@ -453,12 +453,16 @@ public class LicensesService extends AbstractLifecycleComponent<LicensesService>
         private void enableFeatureIfNeeded() {
             if (toggle.compareAndSet(false, true) || initialState.compareAndSet(true, false)) {
                 listener.onEnabled();
+                // needed as toggle may not be set
+                toggle.set(true);
             }
         }
 
         private void disableFeatureIfNeeded() {
             if (toggle.compareAndSet(true, false) || initialState.compareAndSet(true, false)) {
                 listener.onDisabled();
+                // needed as toggle may not be set
+                toggle.set(false);
             }
         }
     }