You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2011/10/22 10:39:41 UTC
svn commit: r1187672 -
/camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyCsvFactory.java
Author: davsclaus
Date: Sat Oct 22 08:39:40 2011
New Revision: 1187672
URL: http://svn.apache.org/viewvc?rev=1187672&view=rev
Log:
CAMEL-4573: Fixed thread safety issue in bindy CSV marshaller.
Modified:
camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyCsvFactory.java
Modified: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyCsvFactory.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyCsvFactory.java?rev=1187672&r1=1187671&r2=1187672&view=diff
==============================================================================
--- camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyCsvFactory.java (original)
+++ camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyCsvFactory.java Sat Oct 22 08:39:40 2011
@@ -55,8 +55,6 @@ public class BindyCsvFactory extends Bin
private Map<Integer, Field> annotatedFields = new LinkedHashMap<Integer, Field>();
private Map<String, Integer> sections = new HashMap<String, Integer>();
- private Map<Integer, List<String>> results;
-
private int numberOptionalFields;
private int numberMandatoryFields;
private int totalFields;
@@ -226,7 +224,7 @@ public class BindyCsvFactory extends Bin
public String unbind(Map<String, Object> model) throws Exception {
StringBuilder buffer = new StringBuilder();
- results = new HashMap<Integer, List<String>>();
+ Map<Integer, List<String>> results = new HashMap<Integer, List<String>>();
// Check if separator exists
ObjectHelper.notNull(this.separator, "The separator has not been instantiated or property not defined in the @CsvRecord annotation");
@@ -247,7 +245,7 @@ public class BindyCsvFactory extends Bin
if (obj != null) {
// Generate Csv table
- generateCsvPositionMap(clazz, obj);
+ generateCsvPositionMap(clazz, obj, results);
}
}
@@ -360,7 +358,7 @@ public class BindyCsvFactory extends Bin
* If a relation @OneToMany is defined, than we iterate recursively through this function
* The result is placed in the Map<Integer, List> results
*/
- private void generateCsvPositionMap(Class clazz, Object obj) throws Exception {
+ private void generateCsvPositionMap(Class clazz, Object obj, Map<Integer, List<String>> results) throws Exception {
String result = "";
@@ -448,14 +446,14 @@ public class BindyCsvFactory extends Bin
Iterator it = list.iterator();
while (it.hasNext()) {
Object target = it.next();
- generateCsvPositionMap(target.getClass(), target);
+ generateCsvPositionMap(target.getClass(), target, results);
}
} else {
// Call this function to add empty value
// in the table
- generateCsvPositionMap(field.getClass(), null);
+ generateCsvPositionMap(field.getClass(), null, results);
}
}