diff --git a/README.md b/README.md index ad0d8af1..c0f59614 100644 --- a/README.md +++ b/README.md @@ -36,13 +36,13 @@ gauge run specs #### Install specific version * Installing specific version ``` -gauge install java --version 0.9.1 +gauge install java --version 0.9.2 ``` #### Offline installation * Download the plugin from [Releases](https://github.com/getgauge/gauge-java/releases) ``` -gauge install java --file gauge-java-0.9.1-windows.x86_64.zip +gauge install java --file gauge-java-0.9.2-windows.x86_64.zip ``` #### Build from source diff --git a/java.json b/java.json index c1dbbb1a..00ad0588 100644 --- a/java.json +++ b/java.json @@ -1,6 +1,6 @@ { "id": "java", - "version": "0.9.1", + "version": "0.9.2", "description": "Java support for gauge", "install": { "windows": [], diff --git a/pom.xml b/pom.xml index cfe99707..2076a8e8 100644 --- a/pom.xml +++ b/pom.xml @@ -303,7 +303,7 @@ yyyy-MM-dd - 0.9.1 + 0.9.2 UTF-8 UTF-8 diff --git a/src/main/java/com/thoughtworks/gauge/datastore/DataStore.java b/src/main/java/com/thoughtworks/gauge/datastore/DataStore.java index ab1fe8be..a6ef86f4 100644 --- a/src/main/java/com/thoughtworks/gauge/datastore/DataStore.java +++ b/src/main/java/com/thoughtworks/gauge/datastore/DataStore.java @@ -8,7 +8,14 @@ import java.util.HashMap; import java.util.Map; import java.util.Set; - +/** + * @deprecated DataStore is no longer valid. The usage together with DataStoreFactory API will throw an Exception in multithreaded execution. + *

Use specific data stores instead.

+ * @see com.thoughtworks.gauge.datastore.SuiteDataStore + * @see com.thoughtworks.gauge.datastore.SpecDataStore + * @see com.thoughtworks.gauge.datastore.ScenarioDataStore + */ +@Deprecated public class DataStore { private HashMap map = new HashMap<>(); diff --git a/src/main/java/com/thoughtworks/gauge/datastore/ScenarioDataStore.java b/src/main/java/com/thoughtworks/gauge/datastore/ScenarioDataStore.java index 90782692..7e438618 100644 --- a/src/main/java/com/thoughtworks/gauge/datastore/ScenarioDataStore.java +++ b/src/main/java/com/thoughtworks/gauge/datastore/ScenarioDataStore.java @@ -11,7 +11,12 @@ import java.util.concurrent.ConcurrentHashMap; public class ScenarioDataStore { - private static ThreadLocal> map = ThreadLocal.withInitial(ConcurrentHashMap::new); + private static final InheritableThreadLocal> MAP = new InheritableThreadLocal>() { + @Override + protected ConcurrentHashMap initialValue() { + return new ConcurrentHashMap<>(); + } + }; /** * @param key - Key of the data entry @@ -19,7 +24,7 @@ public class ScenarioDataStore { */ public static synchronized void put(Object key, Object value) { if (key != null && value != null) { - map.get().put(key, value); + MAP.get().put(key, value); } } @@ -29,7 +34,7 @@ public static synchronized void put(Object key, Object value) { */ public static synchronized Object remove(Object key) { if (key != null) { - return map.get().remove(key); + return MAP.get().remove(key); } return null; } @@ -40,7 +45,7 @@ public static synchronized Object remove(Object key) { */ public static synchronized Object get(Object key) { if (key != null) { - return map.get().get(key); + return MAP.get().get(key); } return null; } @@ -50,11 +55,11 @@ public static synchronized Object get(Object key) { * @return A set of keys stored in datastore */ public static synchronized Set items() { - return Collections.unmodifiableSet(map.get().keySet()); + return Collections.unmodifiableSet(MAP.get().keySet()); } static synchronized void clear() { - map.get().clear(); + MAP.get().clear(); } } diff --git a/src/main/java/com/thoughtworks/gauge/datastore/SpecDataStore.java b/src/main/java/com/thoughtworks/gauge/datastore/SpecDataStore.java index 233be980..261dcd1a 100644 --- a/src/main/java/com/thoughtworks/gauge/datastore/SpecDataStore.java +++ b/src/main/java/com/thoughtworks/gauge/datastore/SpecDataStore.java @@ -11,15 +11,19 @@ import java.util.concurrent.ConcurrentHashMap; public class SpecDataStore { - private static ThreadLocal> map = ThreadLocal.withInitial(ConcurrentHashMap::new); - + private static final InheritableThreadLocal> MAP = new InheritableThreadLocal>() { + @Override + protected ConcurrentHashMap initialValue() { + return new ConcurrentHashMap<>(); + } + }; /** * @param key - Key of the data entry * @param value - value of the Data entry */ public static synchronized void put(Object key, Object value) { if (key != null && value != null) { - map.get().put(key, value); + MAP.get().put(key, value); } } @@ -29,7 +33,7 @@ public static synchronized void put(Object key, Object value) { */ public static synchronized Object remove(Object key) { if (key != null) { - return map.get().remove(key); + return MAP.get().remove(key); } return null; } @@ -40,7 +44,7 @@ public static synchronized Object remove(Object key) { */ public static synchronized Object get(Object key) { if (key != null) { - return map.get().get(key); + return MAP.get().get(key); } return null; } @@ -50,10 +54,10 @@ public static synchronized Object get(Object key) { * @return A set of keys stored in datastore */ public static synchronized Set items() { - return Collections.unmodifiableSet(map.get().keySet()); + return Collections.unmodifiableSet(MAP.get().keySet()); } static synchronized void clear() { - map.get().clear(); + MAP.get().clear(); } } diff --git a/src/main/java/com/thoughtworks/gauge/datastore/SuiteDataStore.java b/src/main/java/com/thoughtworks/gauge/datastore/SuiteDataStore.java index eb7f75da..c2435ad1 100644 --- a/src/main/java/com/thoughtworks/gauge/datastore/SuiteDataStore.java +++ b/src/main/java/com/thoughtworks/gauge/datastore/SuiteDataStore.java @@ -11,7 +11,12 @@ import java.util.concurrent.ConcurrentHashMap; public class SuiteDataStore { - private static ThreadLocal> map = ThreadLocal.withInitial(ConcurrentHashMap::new); + private static final InheritableThreadLocal> MAP = new InheritableThreadLocal>() { + @Override + protected ConcurrentHashMap initialValue() { + return new ConcurrentHashMap<>(); + } + }; /** * @param key - Key of the data entry @@ -19,7 +24,7 @@ public class SuiteDataStore { */ public static synchronized void put(Object key, Object value) { if (key != null && value != null) { - map.get().put(key, value); + MAP.get().put(key, value); } } @@ -29,7 +34,7 @@ public static synchronized void put(Object key, Object value) { */ public static synchronized Object remove(Object key) { if (key != null) { - return map.get().remove(key); + return MAP.get().remove(key); } return null; } @@ -40,7 +45,7 @@ public static synchronized Object remove(Object key) { */ public static synchronized Object get(Object key) { if (key != null) { - return map.get().get(key); + return MAP.get().get(key); } return null; } @@ -50,10 +55,10 @@ public static synchronized Object get(Object key) { * @return A set of keys stored in datastore */ public static synchronized Set items() { - return Collections.unmodifiableSet(map.get().keySet()); + return Collections.unmodifiableSet(MAP.get().keySet()); } static synchronized void clear() { - map.get().clear(); + MAP.get().clear(); } }