avro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cutt...@apache.org
Subject svn commit: r1170003 - in /avro/trunk/lang/java: pom.xml protobuf/src/main/java/org/apache/avro/protobuf/ProtobufData.java protobuf/src/test/java/org/apache/avro/protobuf/TestProtobuf.java
Date Tue, 13 Sep 2011 01:30:43 GMT
Author: cutting
Date: Tue Sep 13 01:30:43 2011
New Revision: 1170003

URL: http://svn.apache.org/viewvc?rev=1170003&view=rev
Log:
AVRO-805.  Fix to work with either protobuf 2.3 or 2.4.

Modified:
    avro/trunk/lang/java/pom.xml
    avro/trunk/lang/java/protobuf/src/main/java/org/apache/avro/protobuf/ProtobufData.java
    avro/trunk/lang/java/protobuf/src/test/java/org/apache/avro/protobuf/TestProtobuf.java

Modified: avro/trunk/lang/java/pom.xml
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/pom.xml?rev=1170003&r1=1170002&r2=1170003&view=diff
==============================================================================
--- avro/trunk/lang/java/pom.xml (original)
+++ avro/trunk/lang/java/pom.xml Tue Sep 13 01:30:43 2011
@@ -46,7 +46,7 @@
     <netty-version>3.2.4.Final</netty-version> 
     <jopt-simple-version>3.2</jopt-simple-version>
     <snappy-version>1.0.3.2</snappy-version>
-    <protobuf-version>2.4.1</protobuf-version>
+    <protobuf-version>2.3.0</protobuf-version>
   </properties>
 
   <build>

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=1170003&r1=1170002&r2=1170003&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 Sep 13 01:30:43 2011
@@ -33,8 +33,8 @@ import org.apache.avro.generic.GenericDa
 import org.apache.avro.specific.SpecificData;
 
 import com.google.protobuf.ByteString;
+import com.google.protobuf.Message;
 import com.google.protobuf.Message.Builder;
-import com.google.protobuf.MessageOrBuilder;
 import com.google.protobuf.ProtocolMessageEnum;
 import com.google.protobuf.Descriptors.Descriptor;
 import com.google.protobuf.Descriptors.FieldDescriptor;
@@ -79,23 +79,23 @@ public class ProtobufData extends Generi
 
   @Override
   public Object getField(Object record, String name, int position) {
-    MessageOrBuilder b = (MessageOrBuilder)record;
-    FieldDescriptor f = getFieldDescriptor(b.getDescriptorForType(), position);
+    Message m = (Message)record;
+    FieldDescriptor f = getFieldDescriptor(m.getDescriptorForType(), position);
     switch (f.getType()) {
     case ENUM:
       Schema s = getSchema(f);
       try {
         Class c = Class.forName(SpecificData.getClassName(s));
-        EnumValueDescriptor symbol = (EnumValueDescriptor)b.getField(f);
+        EnumValueDescriptor symbol = (EnumValueDescriptor)m.getField(f);
         return Enum.valueOf(c, symbol.getName());
       } catch (Exception e) {
         throw new RuntimeException(e);
       }
     case MESSAGE:
-      if (!b.hasField(f))
+      if (!m.hasField(f))
         return null;
     default:
-      return b.getField(f);
+      return m.getField(f);
     }
   }    
 
@@ -116,7 +116,7 @@ public class ProtobufData extends Generi
 
   @Override
   protected boolean isRecord(Object datum) {
-    return datum instanceof MessageOrBuilder;
+    return datum instanceof Message;
   }
 
   @Override
@@ -146,7 +146,7 @@ public class ProtobufData extends Generi
 
   @Override
   protected Schema getRecordSchema(Object record) {
-    return getSchema(((MessageOrBuilder)record).getDescriptorForType());
+    return getSchema(((Message)record).getDescriptorForType());
   }
 
   private final Map<Class,Schema> schemaCache

Modified: avro/trunk/lang/java/protobuf/src/test/java/org/apache/avro/protobuf/TestProtobuf.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/protobuf/src/test/java/org/apache/avro/protobuf/TestProtobuf.java?rev=1170003&r1=1170002&r2=1170003&view=diff
==============================================================================
--- avro/trunk/lang/java/protobuf/src/test/java/org/apache/avro/protobuf/TestProtobuf.java
(original)
+++ avro/trunk/lang/java/protobuf/src/test/java/org/apache/avro/protobuf/TestProtobuf.java
Tue Sep 13 01:30:43 2011
@@ -55,6 +55,8 @@ public class TestProtobuf {
     builder.setEnum(A.X);
     builder.addIntArray(27);
     Foo fooInner = builder.build();
+
+    builder = Foo.newBuilder(fooInner);
     builder.setFoo(fooInner);
     Foo foo = builder.build();
 



Mime
View raw message