avro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cutt...@apache.org
Subject svn commit: r1182146 - in /avro/trunk: ./ lang/java/avro/src/main/java/org/apache/avro/ lang/java/avro/src/main/java/org/apache/avro/generic/ lang/java/avro/src/main/java/org/apache/avro/io/ lang/java/avro/src/main/java/org/apache/avro/specific/ lang/j...
Date Tue, 11 Oct 2011 23:25:05 GMT
Author: cutting
Date: Tue Oct 11 23:25:04 2011
New Revision: 1182146

URL: http://svn.apache.org/viewvc?rev=1182146&view=rev
Log:
AVRO-803. Java: Optionally change string types in generated code to java.lang.String instead of java.lang.CharSequence.

Modified:
    avro/trunk/CHANGES.txt
    avro/trunk/lang/java/avro/src/main/java/org/apache/avro/Schema.java
    avro/trunk/lang/java/avro/src/main/java/org/apache/avro/generic/GenericData.java
    avro/trunk/lang/java/avro/src/main/java/org/apache/avro/generic/GenericDatumReader.java
    avro/trunk/lang/java/avro/src/main/java/org/apache/avro/io/BinaryDecoder.java
    avro/trunk/lang/java/avro/src/main/java/org/apache/avro/io/Decoder.java
    avro/trunk/lang/java/avro/src/main/java/org/apache/avro/io/JsonDecoder.java
    avro/trunk/lang/java/avro/src/main/java/org/apache/avro/io/ValidatingDecoder.java
    avro/trunk/lang/java/avro/src/main/java/org/apache/avro/specific/SpecificData.java
    avro/trunk/lang/java/compiler/src/main/java/org/apache/avro/compiler/specific/ProtocolTask.java
    avro/trunk/lang/java/compiler/src/main/java/org/apache/avro/compiler/specific/SchemaTask.java
    avro/trunk/lang/java/compiler/src/main/java/org/apache/avro/compiler/specific/SpecificCompiler.java
    avro/trunk/lang/java/ipc/pom.xml
    avro/trunk/lang/java/ipc/src/main/java/org/apache/avro/ipc/RPCContext.java
    avro/trunk/lang/java/ipc/src/main/java/org/apache/avro/ipc/Requestor.java
    avro/trunk/lang/java/ipc/src/main/java/org/apache/avro/ipc/Responder.java
    avro/trunk/lang/java/ipc/src/main/java/org/apache/avro/ipc/trace/TracePlugin.java
    avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/RPCMetaTestPlugin.java
    avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/TestCompare.java
    avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/TestNamespaceSpecific.java
    avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/TestProtocolSpecific.java
    avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/generic/TestDeepCopy.java
    avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/ipc/TestNettyServer.java
    avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/ipc/TestNettyServerWithCallbacks.java
    avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/ipc/TestRpcPluginOrdering.java
    avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/specific/TestSpecificData.java
    avro/trunk/lang/java/mapred/pom.xml
    avro/trunk/lang/java/mapred/src/main/java/org/apache/avro/mapred/tether/TetherMapRunner.java
    avro/trunk/lang/java/mapred/src/main/java/org/apache/avro/mapred/tether/TetherOutputService.java
    avro/trunk/lang/java/mapred/src/main/java/org/apache/avro/mapred/tether/TetherReducer.java
    avro/trunk/lang/java/mapred/src/test/java/org/apache/avro/mapred/tether/TetherTask.java
    avro/trunk/lang/java/mapred/src/test/java/org/apache/avro/mapred/tether/TetherTaskRunner.java
    avro/trunk/lang/java/maven-plugin/src/main/java/org/apache/avro/mojo/AbstractAvroMojo.java
    avro/trunk/lang/java/maven-plugin/src/main/java/org/apache/avro/mojo/ProtocolMojo.java
    avro/trunk/lang/java/maven-plugin/src/main/java/org/apache/avro/mojo/SchemaMojo.java
    avro/trunk/lang/java/protobuf/src/main/java/org/apache/avro/protobuf/ProtobufData.java
    avro/trunk/lang/java/protobuf/src/main/java/org/apache/avro/protobuf/ProtobufDatumReader.java
    avro/trunk/lang/java/thrift/src/main/java/org/apache/avro/thrift/ThriftData.java
    avro/trunk/lang/java/thrift/src/main/java/org/apache/avro/thrift/ThriftDatumReader.java

Modified: avro/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/avro/trunk/CHANGES.txt?rev=1182146&r1=1182145&r2=1182146&view=diff
==============================================================================
--- avro/trunk/CHANGES.txt (original)
+++ avro/trunk/CHANGES.txt Tue Oct 11 23:25:04 2011
@@ -35,6 +35,11 @@ Avro 1.6.0 (unreleased)
 
     AVRO-908. Add an option to build avrocpp as a static library. (Nebojsa Sabovic via thiru)
 
+    AVRO-803. Java: Optionally change string types in generated code
+    to java.lang.String instead of java.lang.CharSequence.  This is
+    achived by specifying <stringType>String</stringType> in
+    avro-maven-plugin's pom.xml configuration. (cutting)
+
   OPTIMIZATIONS
 
     AVRO-853: Java: Cache Schema hash codes. (cutting)

Modified: avro/trunk/lang/java/avro/src/main/java/org/apache/avro/Schema.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/avro/src/main/java/org/apache/avro/Schema.java?rev=1182146&r1=1182145&r2=1182146&view=diff
==============================================================================
--- avro/trunk/lang/java/avro/src/main/java/org/apache/avro/Schema.java (original)
+++ avro/trunk/lang/java/avro/src/main/java/org/apache/avro/Schema.java Tue Oct 11 23:25:04 2011
@@ -170,6 +170,11 @@ public abstract class Schema {
     hashCode = NO_HASHCODE;
   }
 
+  /** Return the defined properties as an unmodifieable Map. */
+  public Map<String,String> getProps() {
+    return Collections.unmodifiableMap(props);
+  }
+
   /** Create an anonymous record schema. */
   public static Schema createRecord(List<Field> fields) {
     Schema result = createRecord(null, null, null, false);
@@ -417,6 +422,10 @@ public abstract class Schema {
     public synchronized void addProp(String name, String value) {
       props.add(name, value);
     }
+    /** Return the defined properties as an unmodifieable Map. */
+    public Map<String,String> props() {
+      return Collections.unmodifiableMap(props);
+    }
     public void addAlias(String alias) {
       if (aliases == null)
         this.aliases = new LinkedHashSet<String>();

Modified: avro/trunk/lang/java/avro/src/main/java/org/apache/avro/generic/GenericData.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/avro/src/main/java/org/apache/avro/generic/GenericData.java?rev=1182146&r1=1182145&r2=1182146&view=diff
==============================================================================
--- avro/trunk/lang/java/avro/src/main/java/org/apache/avro/generic/GenericData.java (original)
+++ avro/trunk/lang/java/avro/src/main/java/org/apache/avro/generic/GenericData.java Tue Oct 11 23:25:04 2011
@@ -40,6 +40,21 @@ public class GenericData {
 
   private static final GenericData INSTANCE = new GenericData();
   
+  /** Used to specify the Java type for a string schema. */
+  public enum StringType { CharSequence, String, Utf8 };
+
+  protected static final String STRING_PROP = "avro.java.string";
+  protected static final String STRING_TYPE_STRING = "String";
+
+  /** Set the Java type to be used when reading this schema.  Meaningful only
+   * only string schemas and map schemas (for the keys). */
+  public static void setStringType(Schema s, StringType stringType) {
+    // Utf8 is the default and implements CharSequence, so we only need to add
+    // a property when the type is String
+    if (stringType == StringType.String)
+      s.addProp(GenericData.STRING_PROP, GenericData.STRING_TYPE_STRING);
+  }
+
   /** Return the singleton instance. */
   public static GenericData get() { return INSTANCE; }
 
@@ -721,6 +736,8 @@ public class GenericData {
     }
   }
 
+  private static final Schema STRINGS = Schema.create(Type.STRING);
+
   /**
    * Makes a deep copy of a value given its schema.
    * @param schema the schema of the value to deep copy.
@@ -768,7 +785,7 @@ public class GenericData {
         Map<CharSequence, Object> mapCopy = 
           new HashMap<CharSequence, Object>(mapValue.size());
         for (Map.Entry<CharSequence, Object> entry : mapValue.entrySet()) {
-          mapCopy.put(new Utf8(entry.getKey().toString()), 
+          mapCopy.put((CharSequence)(deepCopy(STRINGS, entry.getKey())),
               deepCopy(schema.getValueType(), entry.getValue()));
         }
         return mapCopy;

Modified: avro/trunk/lang/java/avro/src/main/java/org/apache/avro/generic/GenericDatumReader.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/avro/src/main/java/org/apache/avro/generic/GenericDatumReader.java?rev=1182146&r1=1182145&r2=1182146&view=diff
==============================================================================
--- avro/trunk/lang/java/avro/src/main/java/org/apache/avro/generic/GenericDatumReader.java (original)
+++ avro/trunk/lang/java/avro/src/main/java/org/apache/avro/generic/GenericDatumReader.java Tue Oct 11 23:25:04 2011
@@ -236,7 +236,7 @@ public class GenericDatumReader<D> imple
     if (l > 0) {
       do {
         for (int i = 0; i < l; i++) {
-          addToMap(map, readString(null, in), read(null, eValue, in));
+          addToMap(map, readString(null, expected, in), read(null, eValue, in));
         }
       } while ((l = in.mapNext()) > 0);
     }
@@ -286,8 +286,12 @@ public class GenericDatumReader<D> imple
    * #readString(Object,Decoder)}.*/
   protected Object readString(Object old, Schema expected,
                               Decoder in) throws IOException {
-    return readString(old, in);
-  }
+    if (data.STRING_TYPE_STRING.equals(expected.getProp(data.STRING_PROP)))
+      return in.readString();
+    else
+      return readString(old, in);
+  }                  
+
   /** Called to read strings.  Subclasses may override to use a different
    * string representation.  By default, this calls {@link
    * Decoder#readString(Utf8)}.*/

Modified: avro/trunk/lang/java/avro/src/main/java/org/apache/avro/io/BinaryDecoder.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/avro/src/main/java/org/apache/avro/io/BinaryDecoder.java?rev=1182146&r1=1182145&r2=1182146&view=diff
==============================================================================
--- avro/trunk/lang/java/avro/src/main/java/org/apache/avro/io/BinaryDecoder.java (original)
+++ avro/trunk/lang/java/avro/src/main/java/org/apache/avro/io/BinaryDecoder.java Tue Oct 11 23:25:04 2011
@@ -257,6 +257,13 @@ public class BinaryDecoder extends Decod
     return result;
   }
   
+  private final Utf8 scratchUtf8 = new Utf8();
+
+  @Override
+  public String readString() throws IOException {
+    return readString(scratchUtf8).toString();
+  }
+
   @Override
   public void skipString() throws IOException {
     doSkipBytes(readInt());

Modified: avro/trunk/lang/java/avro/src/main/java/org/apache/avro/io/Decoder.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/avro/src/main/java/org/apache/avro/io/Decoder.java?rev=1182146&r1=1182145&r2=1182146&view=diff
==============================================================================
--- avro/trunk/lang/java/avro/src/main/java/org/apache/avro/io/Decoder.java (original)
+++ avro/trunk/lang/java/avro/src/main/java/org/apache/avro/io/Decoder.java Tue Oct 11 23:25:04 2011
@@ -97,6 +97,13 @@ public abstract class Decoder {
   public abstract Utf8 readString(Utf8 old) throws IOException;
     
   /**
+   * Reads a char-string written by {@link Encoder#writeString}.
+   * @throws AvroTypeException If this is a stateful reader and
+   * char-string is not the type of the next value to be read
+   */
+  public abstract String readString() throws IOException;
+
+  /**
    * Discards a char-string written by {@link Encoder#writeString}.
    *  @throws AvroTypeException If this is a stateful reader and
    *          char-string is not the type of the next value to be read

Modified: avro/trunk/lang/java/avro/src/main/java/org/apache/avro/io/JsonDecoder.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/avro/src/main/java/org/apache/avro/io/JsonDecoder.java?rev=1182146&r1=1182145&r2=1182146&view=diff
==============================================================================
--- avro/trunk/lang/java/avro/src/main/java/org/apache/avro/io/JsonDecoder.java (original)
+++ avro/trunk/lang/java/avro/src/main/java/org/apache/avro/io/JsonDecoder.java Tue Oct 11 23:25:04 2011
@@ -211,6 +211,11 @@ public class JsonDecoder extends Parsing
     
   @Override
   public Utf8 readString(Utf8 old) throws IOException {
+    return new Utf8(readString());
+  }
+
+  @Override
+  public String readString() throws IOException {
     advance(Symbol.STRING);
     if (parser.topSymbol() == Symbol.MAP_KEY_MARKER) {
       parser.advance(Symbol.MAP_KEY_MARKER);
@@ -224,7 +229,7 @@ public class JsonDecoder extends Parsing
     }
     String result = in.getText();
     in.nextToken();
-    return new Utf8(result);
+    return result;
   }
 
   @Override

Modified: avro/trunk/lang/java/avro/src/main/java/org/apache/avro/io/ValidatingDecoder.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/avro/src/main/java/org/apache/avro/io/ValidatingDecoder.java?rev=1182146&r1=1182145&r2=1182146&view=diff
==============================================================================
--- avro/trunk/lang/java/avro/src/main/java/org/apache/avro/io/ValidatingDecoder.java (original)
+++ avro/trunk/lang/java/avro/src/main/java/org/apache/avro/io/ValidatingDecoder.java Tue Oct 11 23:25:04 2011
@@ -108,6 +108,12 @@ public class ValidatingDecoder extends P
   }
 
   @Override
+  public String readString() throws IOException {
+    parser.advance(Symbol.STRING);
+    return in.readString();
+  }
+
+  @Override
   public void skipString() throws IOException {
     parser.advance(Symbol.STRING);
     in.skipString();

Modified: avro/trunk/lang/java/avro/src/main/java/org/apache/avro/specific/SpecificData.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/avro/src/main/java/org/apache/avro/specific/SpecificData.java?rev=1182146&r1=1182145&r2=1182146&view=diff
==============================================================================
--- avro/trunk/lang/java/avro/src/main/java/org/apache/avro/specific/SpecificData.java (original)
+++ avro/trunk/lang/java/avro/src/main/java/org/apache/avro/specific/SpecificData.java Tue Oct 11 23:25:04 2011
@@ -99,7 +99,10 @@ public class SpecificData extends Generi
       if ((types.size() == 2) && types.contains(NULL_SCHEMA))
         return getClass(types.get(types.get(0).equals(NULL_SCHEMA) ? 1 : 0));
       return Object.class;
-    case STRING:  return CharSequence.class;
+    case STRING:
+      if (STRING_TYPE_STRING.equals(schema.getProp(STRING_PROP)))
+        return String.class;
+      return CharSequence.class;
     case BYTES:   return ByteBuffer.class;
     case INT:     return Integer.TYPE;
     case LONG:    return Long.TYPE;

Modified: avro/trunk/lang/java/compiler/src/main/java/org/apache/avro/compiler/specific/ProtocolTask.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/compiler/src/main/java/org/apache/avro/compiler/specific/ProtocolTask.java?rev=1182146&r1=1182145&r2=1182146&view=diff
==============================================================================
--- avro/trunk/lang/java/compiler/src/main/java/org/apache/avro/compiler/specific/ProtocolTask.java (original)
+++ avro/trunk/lang/java/compiler/src/main/java/org/apache/avro/compiler/specific/ProtocolTask.java Tue Oct 11 23:25:04 2011
@@ -22,6 +22,9 @@ import java.io.IOException;
 import java.util.ArrayList;
 
 import org.apache.avro.AvroRuntimeException;
+import org.apache.avro.Protocol;
+import org.apache.avro.generic.GenericData.StringType;
+
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.DirectoryScanner;
 import org.apache.tools.ant.Project;
@@ -32,6 +35,8 @@ import org.apache.tools.ant.types.FileSe
 public class ProtocolTask extends Task {
   private File src;
   private File dest = new File(".");
+  private StringType stringType = StringType.CharSequence;
+
   private final ArrayList<FileSet> filesets = new ArrayList<FileSet>();
   
   /** Set the schema file. */
@@ -40,6 +45,12 @@ public class ProtocolTask extends Task {
   /** Set the output directory */
   public void setDestdir(File dir) { this.dest = dir; }
   
+  /** Set the string type. */
+  public void setStringType(StringType type) { this.stringType = type; }
+  
+  /** Get the string type. */
+  public StringType getStringType() { return this.stringType; }
+  
   /** Add a fileset. */
   public void addFileset(FileSet set) { filesets.add(set); }
   
@@ -64,8 +75,11 @@ public class ProtocolTask extends Task {
     }
   }
   
-  protected void doCompile(File file, File dir) throws IOException {
-    SpecificCompiler.compileProtocol(file, dir);
+  protected void doCompile(File src, File dir) throws IOException {
+    Protocol protocol = Protocol.parse(src);
+    SpecificCompiler compiler = new SpecificCompiler(protocol);
+    compiler.setStringType(getStringType());
+    compiler.compileToDestination(src, dest);
   }
 
   private void compile(File file) {

Modified: avro/trunk/lang/java/compiler/src/main/java/org/apache/avro/compiler/specific/SchemaTask.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/compiler/src/main/java/org/apache/avro/compiler/specific/SchemaTask.java?rev=1182146&r1=1182145&r2=1182146&view=diff
==============================================================================
--- avro/trunk/lang/java/compiler/src/main/java/org/apache/avro/compiler/specific/SchemaTask.java (original)
+++ avro/trunk/lang/java/compiler/src/main/java/org/apache/avro/compiler/specific/SchemaTask.java Tue Oct 11 23:25:04 2011
@@ -20,11 +20,17 @@ package org.apache.avro.compiler.specifi
 import java.io.File;
 import java.io.IOException;
 
+import org.apache.avro.Schema;
+
 /** Ant task to generate Java interface and classes for a protocol. */
 public class SchemaTask extends ProtocolTask {
   @Override
   protected void doCompile(File src, File dest) throws IOException {
-    SpecificCompiler.compileSchema(src, dest);
+    Schema.Parser parser = new Schema.Parser();
+    Schema schema = parser.parse(src);
+    SpecificCompiler compiler = new SpecificCompiler(schema);
+    compiler.setStringType(getStringType());
+    compiler.compileToDestination(src, dest);
   }
 }
 

Modified: avro/trunk/lang/java/compiler/src/main/java/org/apache/avro/compiler/specific/SpecificCompiler.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/compiler/src/main/java/org/apache/avro/compiler/specific/SpecificCompiler.java?rev=1182146&r1=1182145&r2=1182146&view=diff
==============================================================================
--- avro/trunk/lang/java/compiler/src/main/java/org/apache/avro/compiler/specific/SpecificCompiler.java (original)
+++ avro/trunk/lang/java/compiler/src/main/java/org/apache/avro/compiler/specific/SpecificCompiler.java Tue Oct 11 23:25:04 2011
@@ -24,13 +24,19 @@ import java.io.StringWriter;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
+import java.util.LinkedHashMap;
 import java.util.HashSet;
+import java.util.LinkedHashSet;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
 
 import org.apache.avro.Protocol;
+import org.apache.avro.Protocol.Message;
 import org.apache.avro.Schema;
 import org.apache.avro.Schema.Field;
+import org.apache.avro.generic.GenericData;
+import org.apache.avro.generic.GenericData.StringType;
 import org.apache.velocity.Template;
 import org.apache.velocity.VelocityContext;
 import org.apache.velocity.app.VelocityEngine;
@@ -275,6 +281,7 @@ public class SpecificCompiler {
   }
 
   OutputFile compileInterface(Protocol protocol) {
+    protocol = addStringType(protocol);           // annotate protocol as needed
     VelocityContext context = new VelocityContext();
     context.put("protocol", protocol);
     context.put("this", this);
@@ -297,6 +304,7 @@ public class SpecificCompiler {
   }
 
   OutputFile compile(Schema schema) {
+    schema = addStringType(schema);               // annotate schema as needed
     String output = "";
     VelocityContext context = new VelocityContext();
     context.put("this", this);
@@ -325,10 +333,103 @@ public class SpecificCompiler {
     return outputFile;
   }
 
+  private StringType stringType = StringType.CharSequence;
+
+  /** Set the Java type to be emitted for string schemas. */
+  public void setStringType(StringType t) { this.stringType = t; }
+
+  // annotate map and string schemas with string type
+  private Protocol addStringType(Protocol p) {
+    if (stringType != StringType.String)
+      return p;
+
+    Protocol newP = new Protocol(p.getName(), p.getDoc(), p.getNamespace());
+    Map<Schema,Schema> types = new LinkedHashMap<Schema,Schema>();
+
+    // annotate types
+    Collection<Schema> namedTypes = new LinkedHashSet<Schema>();
+    for (Schema s : p.getTypes())
+      namedTypes.add(addStringType(s, types));
+    newP.setTypes(namedTypes);
+
+    // annotate messages
+    Map<String,Message> newM = newP.getMessages();
+    for (Message m : p.getMessages().values())
+      newM.put(m.getName(), m.isOneWay()
+               ? newP.createMessage(m.getName(), m.getDoc(),
+                                    addStringType(m.getRequest(), types))
+               : newP.createMessage(m.getName(), m.getDoc(),
+                                    addStringType(m.getRequest(), types),
+                                    addStringType(m.getResponse(), types),
+                                    addStringType(m.getErrors(), types)));
+    return newP;
+  }
+
+  private Schema addStringType(Schema s) {
+    if (stringType != StringType.String)
+      return s;
+    return addStringType(s, new LinkedHashMap<Schema,Schema>());
+  }
+
+  // annotate map and string schemas with string type
+  private Schema addStringType(Schema s, Map<Schema,Schema> seen) {
+    if (seen.containsKey(s)) return seen.get(s); // break loops
+    Schema result = s;
+    switch (s.getType()) {
+    case STRING:
+      result = Schema.create(Schema.Type.STRING);
+      GenericData.setStringType(result, stringType);
+      break;
+    case RECORD:
+      result =
+        Schema.createRecord(s.getFullName(), s.getDoc(), null, s.isError());
+      seen.put(s, result);
+      List<Field> newFields = new ArrayList<Field>();
+      for (Field f : s.getFields()) {
+        Schema fSchema = addStringType(f.schema(), seen);
+        Field newF =
+          new Field(f.name(), fSchema, f.doc(), f.defaultValue(), f.order());
+        for (Map.Entry<String,String> p : f.props().entrySet())
+          newF.addProp(p.getKey(), p.getValue()); // copy props
+        newFields.add(newF);
+      }
+      result.setFields(newFields);
+      break;
+    case ARRAY:
+      Schema e = addStringType(s.getElementType(), seen);
+      result = Schema.createArray(e);
+      break;
+    case MAP:
+      Schema v = addStringType(s.getValueType(), seen);
+      result = Schema.createMap(v);
+      GenericData.setStringType(result, stringType);
+      break;
+    case UNION:
+      List<Schema> types = new ArrayList<Schema>();
+      for (Schema branch : s.getTypes())
+        types.add(addStringType(branch, seen));
+      result = Schema.createUnion(types);
+      break;
+    }
+    for (Map.Entry<String,String> p : s.getProps().entrySet())
+      result.addProp(p.getKey(), p.getValue());   // copy props
+    seen.put(s, result);
+    return result;
+  }
+
+  private String getStringType() {
+    switch (stringType) {
+    case String:        return "java.lang.String";
+    case Utf8:          return "org.apache.avro.util.Utf8";
+    case CharSequence:  return "java.lang.CharSequence";
+    default: throw new RuntimeException("Unknown string type: "+stringType);
+   }
+  }
+ 
   private static final Schema NULL_SCHEMA = Schema.create(Schema.Type.NULL);
 
   /** Utility for template use.  Returns the java type for a Schema. */
-  public static String javaType(Schema schema) {
+  public String javaType(Schema schema) {
     switch (schema.getType()) {
     case RECORD:
     case ENUM:
@@ -337,14 +438,14 @@ public class SpecificCompiler {
     case ARRAY:
       return "java.util.List<" + javaType(schema.getElementType()) + ">";
     case MAP:
-      return "java.util.Map<java.lang.CharSequence,"
+      return "java.util.Map<"+getStringType()+","
           + javaType(schema.getValueType()) + ">";
     case UNION:
       List<Schema> types = schema.getTypes(); // elide unions with null
       if ((types.size() == 2) && types.contains(NULL_SCHEMA))
         return javaType(types.get(types.get(0).equals(NULL_SCHEMA) ? 1 : 0));
       return "java.lang.Object";
-    case STRING:  return "java.lang.CharSequence";
+    case STRING:  return getStringType();
     case BYTES:   return "java.nio.ByteBuffer";
     case INT:     return "java.lang.Integer";
     case LONG:    return "java.lang.Long";
@@ -357,7 +458,7 @@ public class SpecificCompiler {
   }
 
   /** Utility for template use.  Returns the unboxed java type for a Schema. */
-  public static String javaUnbox(Schema schema) {
+  public String javaUnbox(Schema schema) {
     switch (schema.getType()) {
     case INT:     return "int";
     case LONG:    return "long";

Modified: avro/trunk/lang/java/ipc/pom.xml
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/ipc/pom.xml?rev=1182146&r1=1182145&r2=1182146&view=diff
==============================================================================
--- avro/trunk/lang/java/ipc/pom.xml (original)
+++ avro/trunk/lang/java/ipc/pom.xml Tue Oct 11 23:25:04 2011
@@ -80,6 +80,7 @@
               <excludes>
                 <exclude>**/mapred/tether/**</exclude>
               </excludes>
+              <stringType>String</stringType>
               <sourceDirectory>${parent.project.basedir}/../../../../share/schemas/</sourceDirectory>
               <outputDirectory>${project.build.directory}/generated-sources/java</outputDirectory>
               <testSourceDirectory>${parent.project.basedir}/../../../../share/test/schemas/</testSourceDirectory>

Modified: avro/trunk/lang/java/ipc/src/main/java/org/apache/avro/ipc/RPCContext.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/ipc/src/main/java/org/apache/avro/ipc/RPCContext.java?rev=1182146&r1=1182145&r2=1182146&view=diff
==============================================================================
--- avro/trunk/lang/java/ipc/src/main/java/org/apache/avro/ipc/RPCContext.java (original)
+++ avro/trunk/lang/java/ipc/src/main/java/org/apache/avro/ipc/RPCContext.java Tue Oct 11 23:25:04 2011
@@ -38,7 +38,7 @@ public class RPCContext {
   private HandshakeRequest handshakeRequest;
   private HandshakeResponse handshakeResponse;
 
-  protected Map<CharSequence,ByteBuffer> requestCallMeta, responseCallMeta;
+  protected Map<String,ByteBuffer> requestCallMeta, responseCallMeta;
   
   protected Object response;
   protected Exception error;
@@ -72,13 +72,13 @@ public class RPCContext {
    * @return a map representing handshake state from
    * the client to the server
    */
-  public Map<CharSequence,ByteBuffer> requestHandshakeMeta() {
+  public Map<String,ByteBuffer> requestHandshakeMeta() {
     if (handshakeRequest.meta == null)
-      handshakeRequest.meta = new HashMap<CharSequence,ByteBuffer>();
+      handshakeRequest.meta = new HashMap<String,ByteBuffer>();
     return handshakeRequest.meta;
   }
   
-  void setRequestHandshakeMeta(Map<CharSequence,ByteBuffer> newmeta) {
+  void setRequestHandshakeMeta(Map<String,ByteBuffer> newmeta) {
     handshakeRequest.meta = newmeta;
   }
   
@@ -88,13 +88,13 @@ public class RPCContext {
    * @return a map representing handshake state from
    * the server to the client
    */
-  public Map<CharSequence,ByteBuffer> responseHandshakeMeta() {
+  public Map<String,ByteBuffer> responseHandshakeMeta() {
     if (handshakeResponse.meta == null)
-      handshakeResponse.meta = new HashMap<CharSequence,ByteBuffer>();
+      handshakeResponse.meta = new HashMap<String,ByteBuffer>();
     return handshakeResponse.meta;
   }
   
-  void setResponseHandshakeMeta(Map<CharSequence,ByteBuffer> newmeta) {
+  void setResponseHandshakeMeta(Map<String,ByteBuffer> newmeta) {
     handshakeResponse.meta = newmeta;
   }
   
@@ -104,14 +104,14 @@ public class RPCContext {
    * @return a map representing per-call state from
    * the client to the server
    */
-  public Map<CharSequence,ByteBuffer> requestCallMeta() {
+  public Map<String,ByteBuffer> requestCallMeta() {
     if (requestCallMeta == null) {
-      requestCallMeta = new HashMap<CharSequence,ByteBuffer>();
+      requestCallMeta = new HashMap<String,ByteBuffer>();
     }
     return requestCallMeta;
   }
   
-  void setRequestCallMeta(Map<CharSequence,ByteBuffer> newmeta) {
+  void setRequestCallMeta(Map<String,ByteBuffer> newmeta) {
     requestCallMeta = newmeta;
   }
   
@@ -121,14 +121,14 @@ public class RPCContext {
    * @return a map representing per-call state from
    * the server to the client
    */
-  public Map<CharSequence,ByteBuffer> responseCallMeta() {
+  public Map<String,ByteBuffer> responseCallMeta() {
     if (responseCallMeta == null) {
-      responseCallMeta = new HashMap<CharSequence,ByteBuffer>();
+      responseCallMeta = new HashMap<String,ByteBuffer>();
     }
     return responseCallMeta;
   }
   
-  void setResponseCallMeta(Map<CharSequence,ByteBuffer> newmeta) {
+  void setResponseCallMeta(Map<String,ByteBuffer> newmeta) {
     responseCallMeta = newmeta;
   }
   

Modified: avro/trunk/lang/java/ipc/src/main/java/org/apache/avro/ipc/Requestor.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/ipc/src/main/java/org/apache/avro/ipc/Requestor.java?rev=1182146&r1=1182145&r2=1182146&view=diff
==============================================================================
--- avro/trunk/lang/java/ipc/src/main/java/org/apache/avro/ipc/Requestor.java (original)
+++ avro/trunk/lang/java/ipc/src/main/java/org/apache/avro/ipc/Requestor.java Tue Oct 11 23:25:04 2011
@@ -45,7 +45,6 @@ import org.apache.avro.specific.Specific
 import org.apache.avro.specific.SpecificDatumWriter;
 import org.apache.avro.util.ByteBufferInputStream;
 import org.apache.avro.util.ByteBufferOutputStream;
-import org.apache.avro.util.Utf8;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -55,10 +54,10 @@ public abstract class Requestor {
 
   private static final Schema META =
     Schema.createMap(Schema.create(Schema.Type.BYTES));
-  private static final GenericDatumReader<Map<CharSequence,ByteBuffer>>
-    META_READER = new GenericDatumReader<Map<CharSequence,ByteBuffer>>(META);
-  private static final GenericDatumWriter<Map<CharSequence,ByteBuffer>>
-    META_WRITER = new GenericDatumWriter<Map<CharSequence,ByteBuffer>>(META);
+  private static final GenericDatumReader<Map<String,ByteBuffer>>
+    META_READER = new GenericDatumReader<Map<String,ByteBuffer>>(META);
+  private static final GenericDatumWriter<Map<String,ByteBuffer>>
+    META_WRITER = new GenericDatumWriter<Map<String,ByteBuffer>>(META);
 
   private final Protocol local;
   private volatile Protocol remote;
@@ -212,7 +211,7 @@ public abstract class Requestor {
     handshake.clientHash = localHash;
     handshake.serverHash = remoteHash;
     if (sendLocalText)
-      handshake.clientProtocol = new Utf8(local.toString());
+      handshake.clientProtocol = local.toString();
     
     RPCContext context = new RPCContext();
     context.setHandshakeRequest(handshake);

Modified: avro/trunk/lang/java/ipc/src/main/java/org/apache/avro/ipc/Responder.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/ipc/src/main/java/org/apache/avro/ipc/Responder.java?rev=1182146&r1=1182145&r2=1182146&view=diff
==============================================================================
--- avro/trunk/lang/java/ipc/src/main/java/org/apache/avro/ipc/Responder.java (original)
+++ avro/trunk/lang/java/ipc/src/main/java/org/apache/avro/ipc/Responder.java Tue Oct 11 23:25:04 2011
@@ -53,10 +53,10 @@ public abstract class Responder {
 
   private static final Schema META =
     Schema.createMap(Schema.create(Schema.Type.BYTES));
-  private static final GenericDatumReader<Map<CharSequence,ByteBuffer>>
-    META_READER = new GenericDatumReader<Map<CharSequence,ByteBuffer>>(META);
-  private static final GenericDatumWriter<Map<CharSequence,ByteBuffer>>
-    META_WRITER = new GenericDatumWriter<Map<CharSequence,ByteBuffer>>(META);
+  private static final GenericDatumReader<Map<String,ByteBuffer>>
+    META_READER = new GenericDatumReader<Map<String,ByteBuffer>>(META);
+  private static final GenericDatumWriter<Map<String,ByteBuffer>>
+    META_WRITER = new GenericDatumWriter<Map<String,ByteBuffer>>(META);
 
   private static final ThreadLocal<Protocol> REMOTE =
     new ThreadLocal<Protocol>();
@@ -220,7 +220,7 @@ public abstract class Responder {
         remote == null ? HandshakeMatch.NONE : HandshakeMatch.CLIENT;
     }
     if (response.match != HandshakeMatch.BOTH) {
-      response.serverProtocol = new Utf8(local.toString());
+      response.serverProtocol = local.toString();
       response.serverHash = localHash;
     }
     

Modified: avro/trunk/lang/java/ipc/src/main/java/org/apache/avro/ipc/trace/TracePlugin.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/ipc/src/main/java/org/apache/avro/ipc/trace/TracePlugin.java?rev=1182146&r1=1182145&r2=1182146&view=diff
==============================================================================
--- avro/trunk/lang/java/ipc/src/main/java/org/apache/avro/ipc/trace/TracePlugin.java (original)
+++ avro/trunk/lang/java/ipc/src/main/java/org/apache/avro/ipc/trace/TracePlugin.java Tue Oct 11 23:25:04 2011
@@ -35,7 +35,6 @@ import org.apache.avro.ipc.HttpServer;
 import org.apache.avro.ipc.RPCContext;
 import org.apache.avro.ipc.RPCPlugin;
 import org.apache.avro.ipc.specific.SpecificResponder;
-import org.apache.avro.util.Utf8;
 import org.mortbay.jetty.Server;
 import org.mortbay.jetty.bio.SocketConnector;
 import org.mortbay.jetty.servlet.Context;
@@ -71,9 +70,9 @@ public class TracePlugin extends RPCPlug
    * signals that tracing is in progress. The optional PARENT_SPAN_ID_KEY
    * signals that this message has a parent node in the RPC call tree. 
    */
-  private static final Utf8 TRACE_ID_KEY = new Utf8("traceID");
-  private static final Utf8 SPAN_ID_KEY = new Utf8("spanID");
-  private static final Utf8 PARENT_SPAN_ID_KEY = new Utf8("parentSpanID");
+  private static final String TRACE_ID_KEY = "traceID";
+  private static final String SPAN_ID_KEY = "spanID";
+  private static final String PARENT_SPAN_ID_KEY = "parentSpanID";
 
   class TraceResponder implements AvroTrace {
     private SpanStorage spanStorage;
@@ -112,7 +111,7 @@ public class TracePlugin extends RPCPlug
   
   // Client interface
   protected Server clientFacingServer;
-  private CharSequence hostname;
+  private String hostname;
   
   /**
    * Get a singleton TracePlugin. This is useful if you want to persist a plugin
@@ -250,7 +249,7 @@ public class TracePlugin extends RPCPlug
   
   @Override
   public void serverConnecting(RPCContext context) {
-    Map<CharSequence, ByteBuffer> meta = context.requestHandshakeMeta();
+    Map<String, ByteBuffer> meta = context.requestHandshakeMeta();
     // Are we being asked to propagate a trace?
     if (meta.containsKey(TRACE_ID_KEY) && enabled) {
       if (!(meta.containsKey(SPAN_ID_KEY))) {
@@ -288,8 +287,7 @@ public class TracePlugin extends RPCPlug
     if (this.childSpan.get() != null) {
       Span child = this.childSpan.get();
       Util.addEvent(child, SpanEvent.CLIENT_SEND);
-      child.messageName = new Utf8(
-          context.getMessage().getName());
+      child.messageName = context.getMessage().getName();
       child.requestPayloadSize = Util.getPayloadSize(
           context.getRequestPayload());
     }
@@ -300,8 +298,7 @@ public class TracePlugin extends RPCPlug
     if (this.currentSpan.get() != null) {
       Span current = this.currentSpan.get();
       Util.addEvent(current, SpanEvent.SERVER_RECV);
-      current.messageName = new Utf8(
-          context.getMessage().getName());
+      current.messageName = context.getMessage().getName();
       current.requestPayloadSize = Util.getPayloadSize(
           context.getRequestPayload());
     }

Modified: avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/RPCMetaTestPlugin.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/RPCMetaTestPlugin.java?rev=1182146&r1=1182145&r2=1182146&view=diff
==============================================================================
--- avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/RPCMetaTestPlugin.java (original)
+++ avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/RPCMetaTestPlugin.java Tue Oct 11 23:25:04 2011
@@ -24,7 +24,6 @@ import junit.framework.Assert;
 
 import org.apache.avro.ipc.RPCContext;
 import org.apache.avro.ipc.RPCPlugin;
-import org.apache.avro.util.Utf8;
 
 /**
  * An implementation of an RPC metadata plugin API designed for unit testing.
@@ -36,10 +35,10 @@ import org.apache.avro.util.Utf8;
  */
 public final class RPCMetaTestPlugin extends RPCPlugin {
   
-  protected final CharSequence key;
+  protected final String key;
   
   public RPCMetaTestPlugin(String keyname) {
-    key = new Utf8(keyname);
+    key = keyname;
   }
   
   @Override
@@ -73,7 +72,7 @@ public final class RPCMetaTestPlugin ext
   
   @Override
   public void clientFinishConnect(RPCContext context) {
-    Map<CharSequence,ByteBuffer> handshakeMeta = context.responseHandshakeMeta();
+    Map<String,ByteBuffer> handshakeMeta = context.responseHandshakeMeta();
     
     Assert.assertNull(context.getRequestPayload());
     Assert.assertNull(context.getResponsePayload());
@@ -107,7 +106,7 @@ public final class RPCMetaTestPlugin ext
   
   @Override
   public void serverReceiveRequest(RPCContext context) {
-    Map<CharSequence,ByteBuffer> meta = context.requestCallMeta();
+    Map<String,ByteBuffer> meta = context.requestCallMeta();
     
     Assert.assertNotNull(meta);    
     Assert.assertNotNull(context.getMessage());
@@ -172,7 +171,7 @@ public final class RPCMetaTestPlugin ext
     checkRPCMetaMap(context.responseCallMeta());
   }
   
-  protected void checkRPCMetaMap(Map<CharSequence,ByteBuffer> rpcMeta) {
+  protected void checkRPCMetaMap(Map<String,ByteBuffer> rpcMeta) {
     Assert.assertNotNull(rpcMeta);
     Assert.assertTrue("key not present in map", rpcMeta.containsKey(key));
     

Modified: avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/TestCompare.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/TestCompare.java?rev=1182146&r1=1182145&r2=1182146&view=diff
==============================================================================
--- avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/TestCompare.java (original)
+++ avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/TestCompare.java Tue Oct 11 23:25:04 2011
@@ -167,10 +167,10 @@ public class TestCompare {
   public void testSpecificRecord() throws Exception {
     TestRecord s1 = new TestRecord();
     TestRecord s2 = new TestRecord();
-    s1.setName(new Utf8("foo"));
+    s1.setName("foo");
     s1.setKind(Kind.BAZ);
     s1.setHash(new MD5(new byte[] {0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5}));
-    s2.setName(new Utf8("bar"));
+    s2.setName("bar");
     s2.setKind(Kind.BAR);
     s2.setHash(new MD5(new byte[] {0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,6}));
     Schema schema = SpecificData.get().getSchema(TestRecord.class);

Modified: avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/TestNamespaceSpecific.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/TestNamespaceSpecific.java?rev=1182146&r1=1182145&r2=1182146&view=diff
==============================================================================
--- avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/TestNamespaceSpecific.java (original)
+++ avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/TestNamespaceSpecific.java Tue Oct 11 23:25:04 2011
@@ -26,7 +26,6 @@ import org.apache.avro.test.namespace.Te
 import org.apache.avro.test.util.MD5;
 import org.apache.avro.test.errors.TestError;
 import org.apache.avro.test.namespace.TestRecord;
-import org.apache.avro.util.Utf8;
 import org.junit.AfterClass;
 import org.junit.Before;
 import org.junit.Test;
@@ -41,7 +40,7 @@ public class TestNamespaceSpecific {
   public static class TestImpl implements TestNamespace {
     public TestRecord echo(TestRecord record) { return record; }
     public Void error() throws AvroRemoteException {
-      throw TestError.newBuilder().setMessage$(new Utf8("an error")).build();
+      throw TestError.newBuilder().setMessage$("an error").build();
     }
   }
 

Modified: avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/TestProtocolSpecific.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/TestProtocolSpecific.java?rev=1182146&r1=1182145&r2=1182146&view=diff
==============================================================================
--- avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/TestProtocolSpecific.java (original)
+++ avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/TestProtocolSpecific.java Tue Oct 11 23:25:04 2011
@@ -36,7 +36,6 @@ import org.apache.avro.test.Kind;
 import org.apache.avro.test.MD5;
 import org.apache.avro.test.TestError;
 import org.apache.avro.test.TestRecord;
-import org.apache.avro.util.Utf8;
 import org.junit.After;
 import org.junit.Test;
 import org.junit.Before;
@@ -70,15 +69,13 @@ public class TestProtocolSpecific {
   private static boolean throwUndeclaredError;
 
   public static class TestImpl implements Simple {
-    public CharSequence hello(CharSequence greeting) {
-      return new Utf8("goodbye");
-    }
+    public String hello(String greeting) { return "goodbye"; }
     public int add(int arg1, int arg2) { return arg1 + arg2; }
     public TestRecord echo(TestRecord record) { return record; }
     public ByteBuffer echoBytes(ByteBuffer data) { return data; }
     public Void error() throws AvroRemoteException {
       if (throwUndeclaredError) throw new RuntimeException("foo");
-      throw TestError.newBuilder().setMessage$(new Utf8("an error")).build();
+      throw TestError.newBuilder().setMessage$("an error").build();
     }
     public void ack() { ackCount++; }
   }
@@ -124,8 +121,8 @@ public class TestProtocolSpecific {
 
   @Test
   public void testHello() throws IOException {
-    CharSequence response = proxy.hello(new Utf8("bob"));
-    assertEquals(new Utf8("goodbye"), response);
+    String response = proxy.hello("bob");
+    assertEquals("goodbye", response);
   }
 
   @Test
@@ -137,7 +134,7 @@ public class TestProtocolSpecific {
   @Test
   public void testEcho() throws IOException {
     TestRecord record = new TestRecord();
-    record.setName(new Utf8("foo"));
+    record.setName("foo");
     record.setKind(Kind.BAR);
     record.setHash(new MD5(new byte[]{0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5}));
     TestRecord echoed = proxy.echo(record);
@@ -202,7 +199,7 @@ public class TestProtocolSpecific {
   public void testOneWay() throws IOException {
     ackCount = 0;
     proxy.ack();
-    proxy.hello(new Utf8("foo"));                 // intermix normal req
+    proxy.hello("foo");                           // intermix normal req
     proxy.ack();
     try { Thread.sleep(100); } catch (InterruptedException e) {}
     assertEquals(2, ackCount);
@@ -247,9 +244,9 @@ public class TestProtocolSpecific {
       addRpcPlugins(r);
       GenericRecord params = new GenericData.Record(message.getRequest());
       params.put("extra", Boolean.TRUE);
-      params.put("greeting", new Utf8("bob"));
-      Utf8 response = (Utf8)r.request("hello", params);
-      assertEquals(new Utf8("goodbye"), response);
+      params.put("greeting", "bob");
+      String response = r.request("hello", params).toString();
+      assertEquals("goodbye", response);
     } finally {
       t.close();
       server.close();
@@ -271,7 +268,7 @@ public class TestProtocolSpecific {
   public class HandshakeMonitor extends RPCPlugin{
     
     private int handshakes;
-    private HashSet<CharSequence> seenProtocols = new HashSet<CharSequence>();
+    private HashSet<String> seenProtocols = new HashSet<String>();
     
     @Override
     public void serverConnecting(RPCContext context) {
@@ -282,7 +279,7 @@ public class TestProtocolSpecific {
       }
 
       // check that a given client protocol is only sent once
-      CharSequence clientProtocol =
+      String clientProtocol =
         context.getHandshakeRequest().clientProtocol;
       if (clientProtocol != null) {
         assertFalse(seenProtocols.contains(clientProtocol));

Modified: avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/generic/TestDeepCopy.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/generic/TestDeepCopy.java?rev=1182146&r1=1182145&r2=1182146&view=diff
==============================================================================
--- avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/generic/TestDeepCopy.java (original)
+++ avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/generic/TestDeepCopy.java Tue Oct 11 23:25:04 2011
@@ -35,7 +35,6 @@ import org.apache.avro.Node;
 import org.apache.avro.Schema.Field;
 import org.apache.avro.Schema.Type;
 import org.apache.avro.specific.SpecificData;
-import org.apache.avro.util.Utf8;
 import org.junit.Test;
 
 /** Unit test for performing a deep copy of an object with a schema */
@@ -56,21 +55,20 @@ public class TestDeepCopy {
     interopBuilder.setIntField(32);
     interopBuilder.setLongField(64L);
     
-    Map<java.lang.CharSequence,org.apache.avro.Foo> map = 
-      new HashMap<java.lang.CharSequence,org.apache.avro.Foo>(1);
-    map.put(new Utf8("foo"), 
-        Foo.newBuilder().setLabel(new Utf8("bar")).build());
+    Map<java.lang.String,org.apache.avro.Foo> map = 
+      new HashMap<java.lang.String,org.apache.avro.Foo>(1);
+    map.put("foo", Foo.newBuilder().setLabel("bar").build());
     interopBuilder.setMapField(map);
     
     interopBuilder.setNullField(null);
     
-    Node.Builder rootBuilder = Node.newBuilder().setLabel(new Utf8("/"));
-    Node.Builder homeBuilder = Node.newBuilder().setLabel(new Utf8("home"));
+    Node.Builder rootBuilder = Node.newBuilder().setLabel("/");
+    Node.Builder homeBuilder = Node.newBuilder().setLabel("home");
     homeBuilder.setChildren(new ArrayList<Node>(0));
     rootBuilder.setChildren(Arrays.asList(new Node[] { homeBuilder.build() }));
     interopBuilder.setRecordField(rootBuilder.build());
     
-    interopBuilder.setStringField(new Utf8("Hello"));
+    interopBuilder.setStringField("Hello");
     interopBuilder.setUnionField(true);
     
     Interop interop = interopBuilder.build();
@@ -90,8 +88,9 @@ public class TestDeepCopy {
       }
       
       // Original field and deep copy should be different instances:
-      if ((field.schema().getType() != Type.ENUM) && 
-          (field.schema().getType() != Type.NULL)) {
+      if ((field.schema().getType() != Type.ENUM)
+           && (field.schema().getType() != Type.NULL)
+           && (field.schema().getType() != Type.STRING)) {
         assertFalse("Field " + field.name() + " is same instance in deep copy",
             interop.get(field.pos()) == 
               GenericData.get().deepCopy(

Modified: avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/ipc/TestNettyServer.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/ipc/TestNettyServer.java?rev=1182146&r1=1182145&r2=1182146&view=diff
==============================================================================
--- avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/ipc/TestNettyServer.java (original)
+++ avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/ipc/TestNettyServer.java Tue Oct 11 23:25:04 2011
@@ -30,7 +30,6 @@ import org.apache.avro.ipc.specific.Spec
 import org.apache.avro.ipc.specific.SpecificResponder;
 import org.apache.avro.test.Mail;
 import org.apache.avro.test.Message;
-import org.apache.avro.util.Utf8;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -47,10 +46,10 @@ public class TestNettyServer {
     private CountDownLatch allMessages = new CountDownLatch(5);
     
     // in this simple example just return details of the message
-    public CharSequence send(Message message) {
-      return new Utf8("Sent message to [" + message.getTo().toString() + 
+    public String send(Message message) {
+      return "Sent message to ["+ message.getTo().toString() + 
           "] from [" + message.getFrom().toString() + "] with body [" + 
-          message.getBody().toString() + "]");
+          message.getBody().toString() + "]";
     }
     
     public void fireandforget(Message message) {
@@ -100,7 +99,7 @@ public class TestNettyServer {
       }
   }
 
-  private void verifyResponse(CharSequence result) {
+  private void verifyResponse(String result) {
     Assert.assertEquals(
         "Sent message to [wife] from [husband] with body [I love you!]",
         result.toString());
@@ -130,9 +129,9 @@ public class TestNettyServer {
 
   private Message createMessage() {
     Message msg = Message.newBuilder().
-      setTo(new Utf8("wife")).
-      setFrom(new Utf8("husband")).
-      setBody(new Utf8("I love you!")).
+      setTo("wife").
+      setFrom("husband").
+      setBody("I love you!").
       build();
     return msg;
   }

Modified: avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/ipc/TestNettyServerWithCallbacks.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/ipc/TestNettyServerWithCallbacks.java?rev=1182146&r1=1182145&r2=1182146&view=diff
==============================================================================
--- avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/ipc/TestNettyServerWithCallbacks.java (original)
+++ avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/ipc/TestNettyServerWithCallbacks.java Tue Oct 11 23:25:04 2011
@@ -38,7 +38,6 @@ import org.apache.avro.ipc.specific.Spec
 import org.apache.avro.test.Simple;
 import org.apache.avro.test.TestError;
 import org.apache.avro.test.TestRecord;
-import org.apache.avro.util.Utf8;
 import org.junit.AfterClass;
 import org.junit.Assert;
 import org.junit.BeforeClass;
@@ -85,19 +84,19 @@ public class TestNettyServerWithCallback
   @Test
   public void greeting() throws Exception {
     // Test synchronous RPC:
-    Assert.assertEquals(new Utf8("Hello, how are you?"), simpleClient.hello("how are you?"));
+    Assert.assertEquals("Hello, how are you?", simpleClient.hello("how are you?"));
     
     // Test asynchronous RPC (future):
-    CallFuture<CharSequence> future1 = new CallFuture<CharSequence>();
+    CallFuture<String> future1 = new CallFuture<String>();
     simpleClient.hello("World!", future1);
-    Assert.assertEquals(new Utf8("Hello, World!"), future1.get(2, TimeUnit.SECONDS));
+    Assert.assertEquals("Hello, World!", future1.get(2, TimeUnit.SECONDS));
     Assert.assertNull(future1.getError());
     
     // Test asynchronous RPC (callback):
-    final CallFuture<CharSequence> future2 = new CallFuture<CharSequence>();
-    simpleClient.hello("what's up?", new Callback<CharSequence>() {
+    final CallFuture<String> future2 = new CallFuture<String>();
+    simpleClient.hello("what's up?", new Callback<String>() {
       @Override
-      public void handleResult(CharSequence result) {
+      public void handleResult(String result) {
         future2.handleResult(result);
       }
       @Override
@@ -105,7 +104,7 @@ public class TestNettyServerWithCallback
         future2.handleError(error);
       }
     });
-    Assert.assertEquals(new Utf8("Hello, what's up?"), future2.get(2, TimeUnit.SECONDS));
+    Assert.assertEquals("Hello, what's up?", future2.get(2, TimeUnit.SECONDS));
     Assert.assertNull(future2.getError());
   }
   
@@ -391,7 +390,7 @@ public class TestNettyServerWithCallback
             startLatch.await(2, TimeUnit.SECONDS);
             while (runFlag.get()) {
               rpcCount.incrementAndGet();
-              Assert.assertEquals(new Utf8("Hello, World!"), simpleClient.hello("World!"));
+              Assert.assertEquals("Hello, World!", simpleClient.hello("World!"));
             }
           } catch (Exception e) {
             e.printStackTrace();
@@ -425,7 +424,7 @@ public class TestNettyServerWithCallback
     }
     
     @Override
-    public CharSequence hello(CharSequence greeting) throws AvroRemoteException {
+    public String hello(String greeting) throws AvroRemoteException {
       return "Hello, " + greeting;
     }
 
@@ -470,7 +469,7 @@ public class TestNettyServerWithCallback
     }
     
     @Override
-    public CharSequence hello(CharSequence greeting) throws AvroRemoteException {
+    public String hello(String greeting) throws AvroRemoteException {
       acquirePermit();
       try {
         return super.hello(greeting);

Modified: avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/ipc/TestRpcPluginOrdering.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/ipc/TestRpcPluginOrdering.java?rev=1182146&r1=1182145&r2=1182146&view=diff
==============================================================================
--- avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/ipc/TestRpcPluginOrdering.java (original)
+++ avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/ipc/TestRpcPluginOrdering.java Tue Oct 11 23:25:04 2011
@@ -30,7 +30,6 @@ import org.apache.avro.ipc.specific.Spec
 import org.apache.avro.ipc.specific.SpecificResponder;
 import org.apache.avro.test.Mail;
 import org.apache.avro.test.Message;
-import org.apache.avro.util.Utf8;
 import org.junit.Test;
 
 public class TestRpcPluginOrdering {
@@ -84,16 +83,16 @@ public class TestRpcPluginOrdering {
 
   private Message createTestMessage() {
     Message message = Message.newBuilder().
-      setTo(new Utf8("me@test.com")).
-      setFrom(new Utf8("you@test.com")).
-      setBody(new Utf8("plugin testing")).
+      setTo("me@test.com").
+      setFrom("you@test.com").
+      setBody("plugin testing").
       build();
     return message;
   }
   
   private static class TestMailImpl implements Mail{
-    public CharSequence send(Message message) throws AvroRemoteException {
-      return new Utf8("Received");
+    public String send(Message message) throws AvroRemoteException {
+      return "Received";
     }
     public void fireandforget(Message message) {
     }

Modified: avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/specific/TestSpecificData.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/specific/TestSpecificData.java?rev=1182146&r1=1182145&r2=1182146&view=diff
==============================================================================
--- avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/specific/TestSpecificData.java (original)
+++ avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/specific/TestSpecificData.java Tue Oct 11 23:25:04 2011
@@ -57,7 +57,7 @@ public class TestSpecificData {
 
     // create a generic instance of this record
     TestRecord nested = new TestRecord();
-    nested.setName(new Utf8("foo"));
+    nested.setName("foo");
     nested.setKind(Kind.BAR);
     nested.setHash(new MD5(new byte[]{0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5}));
     GenericData.Record record = new GenericData.Record(schema);

Modified: avro/trunk/lang/java/mapred/pom.xml
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/mapred/pom.xml?rev=1182146&r1=1182145&r2=1182146&view=diff
==============================================================================
--- avro/trunk/lang/java/mapred/pom.xml (original)
+++ avro/trunk/lang/java/mapred/pom.xml Tue Oct 11 23:25:04 2011
@@ -76,6 +76,7 @@
               <goal>protocol</goal>
             </goals>
             <configuration>  
+              <stringType>String</stringType>
               <includes>
                 <include>**/mapred/tether/*.avpr</include>
               </includes>

Modified: avro/trunk/lang/java/mapred/src/main/java/org/apache/avro/mapred/tether/TetherMapRunner.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/mapred/src/main/java/org/apache/avro/mapred/tether/TetherMapRunner.java?rev=1182146&r1=1182145&r2=1182146&view=diff
==============================================================================
--- avro/trunk/lang/java/mapred/src/main/java/org/apache/avro/mapred/tether/TetherMapRunner.java (original)
+++ avro/trunk/lang/java/mapred/src/main/java/org/apache/avro/mapred/tether/TetherMapRunner.java Tue Oct 11 23:25:04 2011
@@ -31,7 +31,6 @@ import org.apache.hadoop.mapred.Counters
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import org.apache.avro.util.Utf8;
 import org.apache.avro.mapred.AvroJob;
 
 class TetherMapRunner
@@ -57,8 +56,8 @@ class TetherMapRunner
       // configure it
       process.inputClient.configure
         (TaskType.MAP, 
-         new Utf8(job.get(AvroJob.INPUT_SCHEMA)),
-         new Utf8(AvroJob.getMapOutputSchema(job).toString()));
+         job.get(AvroJob.INPUT_SCHEMA),
+         AvroJob.getMapOutputSchema(job).toString());
          
       process.inputClient.partitions(job.getNumReduceTasks());
 

Modified: avro/trunk/lang/java/mapred/src/main/java/org/apache/avro/mapred/tether/TetherOutputService.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/mapred/src/main/java/org/apache/avro/mapred/tether/TetherOutputService.java?rev=1182146&r1=1182145&r2=1182146&view=diff
==============================================================================
--- avro/trunk/lang/java/mapred/src/main/java/org/apache/avro/mapred/tether/TetherOutputService.java (original)
+++ avro/trunk/lang/java/mapred/src/main/java/org/apache/avro/mapred/tether/TetherOutputService.java Tue Oct 11 23:25:04 2011
@@ -67,14 +67,14 @@ class TetherOutputService implements Out
     output(datum);
   }
 
-  public void status(CharSequence message) { reporter.setStatus(message.toString());  }
+  public void status(String message) { reporter.setStatus(message.toString());  }
 
 
-  public void count(CharSequence group, CharSequence name, long amount) {
+  public void count(String group, String name, long amount) {
     reporter.getCounter(group.toString(), name.toString()).increment(amount);
   }
 
-  public synchronized void fail(CharSequence message) {
+  public synchronized void fail(String message) {
     TetherMapRunner.LOG.warn("Failing: "+message);
     error = message.toString();
     notify();

Modified: avro/trunk/lang/java/mapred/src/main/java/org/apache/avro/mapred/tether/TetherReducer.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/mapred/src/main/java/org/apache/avro/mapred/tether/TetherReducer.java?rev=1182146&r1=1182145&r2=1182146&view=diff
==============================================================================
--- avro/trunk/lang/java/mapred/src/main/java/org/apache/avro/mapred/tether/TetherReducer.java (original)
+++ avro/trunk/lang/java/mapred/src/main/java/org/apache/avro/mapred/tether/TetherReducer.java Tue Oct 11 23:25:04 2011
@@ -27,7 +27,6 @@ import org.apache.hadoop.mapred.OutputCo
 import org.apache.hadoop.mapred.Reducer;
 import org.apache.hadoop.mapred.Reporter;
 
-import org.apache.avro.util.Utf8;
 import org.apache.avro.mapred.AvroJob;
 
 class TetherReducer
@@ -49,8 +48,8 @@ class TetherReducer
         process = new TetheredProcess(job, collector, reporter);
         process.inputClient.configure
           (TaskType.REDUCE,
-           new Utf8(AvroJob.getMapOutputSchema(job).toString()),
-           new Utf8(AvroJob.getOutputSchema(job).toString()));
+           AvroJob.getMapOutputSchema(job).toString(),
+           AvroJob.getOutputSchema(job).toString());
       }
       process.inputClient.input(datum.buffer(), datum.count());
     } catch (IOException e) {

Modified: avro/trunk/lang/java/mapred/src/test/java/org/apache/avro/mapred/tether/TetherTask.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/mapred/src/test/java/org/apache/avro/mapred/tether/TetherTask.java?rev=1182146&r1=1182145&r2=1182146&view=diff
==============================================================================
--- avro/trunk/lang/java/mapred/src/test/java/org/apache/avro/mapred/tether/TetherTask.java (original)
+++ avro/trunk/lang/java/mapred/src/test/java/org/apache/avro/mapred/tether/TetherTask.java Tue Oct 11 23:25:04 2011
@@ -27,7 +27,6 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import org.apache.avro.Schema;
-import org.apache.avro.util.Utf8;
 import org.apache.avro.ipc.Transceiver;
 import org.apache.avro.ipc.SaslSocketTransceiver;
 import org.apache.avro.ipc.specific.SpecificRequestor;
@@ -183,17 +182,17 @@ public abstract class TetherTask<IN,MID,
 
   /** Call to update task status. */
   public void status(String message) {
-    outputClient.status(new Utf8(message));
+    outputClient.status(message);
   }
 
   /** Call to increment a counter. */
   public void count(String group, String name, long amount) {
-    outputClient.count(new Utf8(group), new Utf8(name), amount);
+    outputClient.count(group, name, amount);
   }
 
   /** Call to fail the task. */
   public void fail(String message) {
-    outputClient.fail(new Utf8(message));
+    outputClient.fail(message);
     close();
   }
 

Modified: avro/trunk/lang/java/mapred/src/test/java/org/apache/avro/mapred/tether/TetherTaskRunner.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/mapred/src/test/java/org/apache/avro/mapred/tether/TetherTaskRunner.java?rev=1182146&r1=1182145&r2=1182146&view=diff
==============================================================================
--- avro/trunk/lang/java/mapred/src/test/java/org/apache/avro/mapred/tether/TetherTaskRunner.java (original)
+++ avro/trunk/lang/java/mapred/src/test/java/org/apache/avro/mapred/tether/TetherTaskRunner.java Tue Oct 11 23:25:04 2011
@@ -52,8 +52,8 @@ public class TetherTaskRunner implements
   }
 
   @Override public void configure(TaskType taskType,
-                                  CharSequence inSchema,
-                                  CharSequence outSchema) {
+                                  String inSchema,
+                                  String outSchema) {
     LOG.info("got configure");
     task.configure(taskType, inSchema, outSchema);
   }

Modified: avro/trunk/lang/java/maven-plugin/src/main/java/org/apache/avro/mojo/AbstractAvroMojo.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/maven-plugin/src/main/java/org/apache/avro/mojo/AbstractAvroMojo.java?rev=1182146&r1=1182145&r2=1182146&view=diff
==============================================================================
--- avro/trunk/lang/java/maven-plugin/src/main/java/org/apache/avro/mojo/AbstractAvroMojo.java (original)
+++ avro/trunk/lang/java/maven-plugin/src/main/java/org/apache/avro/mojo/AbstractAvroMojo.java Tue Oct 11 23:25:04 2011
@@ -21,6 +21,8 @@ package org.apache.avro.mojo;
 import java.io.File;
 import java.io.IOException;
 
+import org.apache.avro.generic.GenericData.StringType;
+
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.project.MavenProject;
@@ -73,6 +75,14 @@ public abstract class AbstractAvroMojo e
    */
   protected String[] testExcludes = new String[0];
 
+  /**  The Java type to use for Avro strings.  May be one of CharSequence,
+   * String or Utf8.  CharSequence by default.
+   *
+   * @parameter expression="${stringType}"
+   */
+  protected StringType stringType = StringType.CharSequence;
+
+
   /**
    * The current Maven project.
    * 

Modified: avro/trunk/lang/java/maven-plugin/src/main/java/org/apache/avro/mojo/ProtocolMojo.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/maven-plugin/src/main/java/org/apache/avro/mojo/ProtocolMojo.java?rev=1182146&r1=1182145&r2=1182146&view=diff
==============================================================================
--- avro/trunk/lang/java/maven-plugin/src/main/java/org/apache/avro/mojo/ProtocolMojo.java (original)
+++ avro/trunk/lang/java/maven-plugin/src/main/java/org/apache/avro/mojo/ProtocolMojo.java Tue Oct 11 23:25:04 2011
@@ -21,6 +21,7 @@ package org.apache.avro.mojo;
 import java.io.File;
 import java.io.IOException;
 
+import org.apache.avro.Protocol;
 import org.apache.avro.compiler.specific.SpecificCompiler;
 
 /**
@@ -50,8 +51,11 @@ public class ProtocolMojo extends Abstra
   
   @Override
   protected void doCompile(String filename, File sourceDirectory, File outputDirectory) throws IOException {
-    SpecificCompiler.compileProtocol(new File(sourceDirectory, filename),
-        outputDirectory);
+    File src = new File(sourceDirectory, filename);
+    Protocol protocol = Protocol.parse(src);
+    SpecificCompiler compiler = new SpecificCompiler(protocol);
+    compiler.setStringType(stringType);
+    compiler.compileToDestination(src, outputDirectory);
   }
 
   @Override

Modified: avro/trunk/lang/java/maven-plugin/src/main/java/org/apache/avro/mojo/SchemaMojo.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/maven-plugin/src/main/java/org/apache/avro/mojo/SchemaMojo.java?rev=1182146&r1=1182145&r2=1182146&view=diff
==============================================================================
--- avro/trunk/lang/java/maven-plugin/src/main/java/org/apache/avro/mojo/SchemaMojo.java (original)
+++ avro/trunk/lang/java/maven-plugin/src/main/java/org/apache/avro/mojo/SchemaMojo.java Tue Oct 11 23:25:04 2011
@@ -21,6 +21,7 @@ package org.apache.avro.mojo;
 import java.io.File;
 import java.io.IOException;
 
+import org.apache.avro.Schema;
 import org.apache.avro.compiler.specific.SpecificCompiler;
 
 /**
@@ -50,8 +51,12 @@ public class SchemaMojo extends Abstract
 
   @Override
   protected void doCompile(String filename, File sourceDirectory, File outputDirectory) throws IOException {
-    SpecificCompiler.compileSchema(new File(sourceDirectory, filename),
-        outputDirectory);
+    File src = new File(sourceDirectory, filename);
+    Schema.Parser parser = new Schema.Parser();
+    Schema schema = parser.parse(src);
+    SpecificCompiler compiler = new SpecificCompiler(schema);
+    compiler.setStringType(stringType);
+    compiler.compileToDestination(src, outputDirectory);
   }
 
   @Override

Modified: avro/trunk/lang/java/protobuf/src/main/java/org/apache/avro/protobuf/ProtobufData.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/protobuf/src/main/java/org/apache/avro/protobuf/ProtobufData.java?rev=1182146&r1=1182145&r2=1182146&view=diff
==============================================================================
--- avro/trunk/lang/java/protobuf/src/main/java/org/apache/avro/protobuf/ProtobufData.java (original)
+++ avro/trunk/lang/java/protobuf/src/main/java/org/apache/avro/protobuf/ProtobufData.java Tue Oct 11 23:25:04 2011
@@ -255,7 +255,9 @@ public class ProtobufData extends Generi
     case DOUBLE:
       return Schema.create(Schema.Type.DOUBLE);
     case STRING:
-      return Schema.create(Schema.Type.STRING);
+      Schema s = Schema.create(Schema.Type.STRING);
+      GenericData.setStringType(s, GenericData.StringType.String);
+      return s;
     case BYTES:
       return Schema.create(Schema.Type.BYTES);
     case INT32: case UINT32: case SINT32: case FIXED32: case SFIXED32:

Modified: avro/trunk/lang/java/protobuf/src/main/java/org/apache/avro/protobuf/ProtobufDatumReader.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/protobuf/src/main/java/org/apache/avro/protobuf/ProtobufDatumReader.java?rev=1182146&r1=1182145&r2=1182146&view=diff
==============================================================================
--- avro/trunk/lang/java/protobuf/src/main/java/org/apache/avro/protobuf/ProtobufDatumReader.java (original)
+++ avro/trunk/lang/java/protobuf/src/main/java/org/apache/avro/protobuf/ProtobufDatumReader.java Tue Oct 11 23:25:04 2011
@@ -78,10 +78,5 @@ public class ProtobufDatumReader<T> exte
     return ByteString.copyFrom(((ByteBuffer)super.readBytes(old, in)).array());
   }    
 
-  @Override
-  protected Object readString(Object old, Decoder in) throws IOException {
-    return super.readString(old, in).toString();
-  }    
-
 }
 

Modified: avro/trunk/lang/java/thrift/src/main/java/org/apache/avro/thrift/ThriftData.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/thrift/src/main/java/org/apache/avro/thrift/ThriftData.java?rev=1182146&r1=1182145&r2=1182146&view=diff
==============================================================================
--- avro/trunk/lang/java/thrift/src/main/java/org/apache/avro/thrift/ThriftData.java (original)
+++ avro/trunk/lang/java/thrift/src/main/java/org/apache/avro/thrift/ThriftData.java Tue Oct 11 23:25:04 2011
@@ -172,7 +172,9 @@ public class ThriftData extends GenericD
       MapMetaData mapMeta = (MapMetaData)f;
       if (mapMeta.keyMetaData.type != TType.STRING)
         throw new AvroRuntimeException("Map keys must be strings: "+f);
-      return Schema.createMap(getSchema(mapMeta.valueMetaData));
+      Schema map = Schema.createMap(getSchema(mapMeta.valueMetaData));
+      GenericData.setStringType(map, GenericData.StringType.String);
+      return map;
     case TType.SET:
       SetMetaData setMeta = (SetMetaData)f;
       Schema set = Schema.createArray(getSchema(setMeta.elemMetaData));
@@ -181,8 +183,9 @@ public class ThriftData extends GenericD
     case TType.STRING:
       if (f.isBinary())
         return Schema.create(Schema.Type.BYTES);
-      else
-        return Schema.create(Schema.Type.STRING);
+      Schema string = Schema.create(Schema.Type.STRING);
+      GenericData.setStringType(string, GenericData.StringType.String);
+      return string;
     case TType.STRUCT:
       StructMetaData structMeta = (StructMetaData)f;
       Schema record = getSchema(structMeta.structClass);

Modified: avro/trunk/lang/java/thrift/src/main/java/org/apache/avro/thrift/ThriftDatumReader.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/thrift/src/main/java/org/apache/avro/thrift/ThriftDatumReader.java?rev=1182146&r1=1182145&r2=1182146&view=diff
==============================================================================
--- avro/trunk/lang/java/thrift/src/main/java/org/apache/avro/thrift/ThriftDatumReader.java (original)
+++ avro/trunk/lang/java/thrift/src/main/java/org/apache/avro/thrift/ThriftDatumReader.java Tue Oct 11 23:25:04 2011
@@ -76,11 +76,6 @@ public class ThriftDatumReader<T> extend
   }
 
   @Override
-  protected Object readString(Object old, Decoder in) throws IOException {
-    return super.readString(old, in).toString();
-  }    
-
-  @Override
   protected Object newArray(Object old, int size, Schema schema) {
     if ("set".equals(schema.getProp(ThriftData.THRIFT_PROP))) {
       if (old instanceof Set) {



Mime
View raw message