THRIFT-1618: synchronize access to hashtable in FieldMetaData
diff --git a/lib/java/src/org/apache/thrift/meta_data/FieldMetaData.java b/lib/java/src/org/apache/thrift/meta_data/FieldMetaData.java
index b634291..445f7e4 100644
--- a/lib/java/src/org/apache/thrift/meta_data/FieldMetaData.java
+++ b/lib/java/src/org/apache/thrift/meta_data/FieldMetaData.java
@@ -45,7 +45,7 @@
     this.valueMetaData = vMetaData;
   }
   
-  public static void addStructMetaDataMap(Class<? extends TBase> sClass, Map<? extends TFieldIdEnum, FieldMetaData> map){
+  public static synchronized void addStructMetaDataMap(Class<? extends TBase> sClass, Map<? extends TFieldIdEnum, FieldMetaData> map){
     structMap.put(sClass, map);
   }
 
@@ -55,7 +55,7 @@
    *
    * @param sClass The TBase class for which the metadata map is requested
    */
-  public static Map<? extends TFieldIdEnum, FieldMetaData> getStructMetaDataMap(Class<? extends TBase> sClass){
+  public static synchronized Map<? extends TFieldIdEnum, FieldMetaData> getStructMetaDataMap(Class<? extends TBase> sClass){
     if (!structMap.containsKey(sClass)){ // Load class if it hasn't been loaded
       try{
         sClass.newInstance();
diff --git a/lib/javame/src/org/apache/thrift/meta_data/FieldMetaData.java b/lib/javame/src/org/apache/thrift/meta_data/FieldMetaData.java
index 11a5a08..bce02c7 100644
--- a/lib/javame/src/org/apache/thrift/meta_data/FieldMetaData.java
+++ b/lib/javame/src/org/apache/thrift/meta_data/FieldMetaData.java
@@ -63,7 +63,7 @@
     this.valueMetaData = vMetaData;
   }
   
-  public static void addStructMetaDataMap(Class sClass, Hashtable map){
+  public static synchronized void addStructMetaDataMap(Class sClass, Hashtable map){
     structMap.put(sClass, map);
   }
 
@@ -73,7 +73,7 @@
    *
    * @param sClass The TBase class for which the metadata map is requested
    */
-  public static Hashtable getStructMetaDataMap(Class sClass){
+  public static synchronized Hashtable getStructMetaDataMap(Class sClass){
     if (!structMap.containsKey(sClass)){ // Load class if it hasn't been loaded
       try{
         sClass.newInstance();