avro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cutt...@apache.org
Subject svn commit: r1190624 - in /avro/trunk: CHANGES.txt lang/java/avro/src/main/java/org/apache/avro/specific/SpecificData.java
Date Fri, 28 Oct 2011 22:14:21 GMT
Author: cutting
Date: Fri Oct 28 22:14:21 2011
New Revision: 1190624

URL: http://svn.apache.org/viewvc?rev=1190624&view=rev
Log:
AVRO-941. Java: Make generated specific classes to work in some cases after Maven shade plugin
is used on them.

Modified:
    avro/trunk/CHANGES.txt
    avro/trunk/lang/java/avro/src/main/java/org/apache/avro/specific/SpecificData.java

Modified: avro/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/avro/trunk/CHANGES.txt?rev=1190624&r1=1190623&r2=1190624&view=diff
==============================================================================
--- avro/trunk/CHANGES.txt (original)
+++ avro/trunk/CHANGES.txt Fri Oct 28 22:14:21 2011
@@ -166,6 +166,9 @@ Avro 1.6.0 (27 October 2011)
 
     AVRO-935. Java: Update dependency versions for 1.6.0. (scottcarey)
 
+    AVRO-941. Java: Make generated specific classes to work in some
+    cases after Maven shade plugin is used on them.  (cutting)
+
   BUG FIXES
 
     AVRO-824. Java: Fix usage message of BinaryFragmentToJsonTool.

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=1190624&r1=1190623&r2=1190624&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 Fri
Oct 28 22:14:21 2011
@@ -183,6 +183,12 @@ public class SpecificData extends Generi
       if (schema == null)
         try {
           schema = (Schema)(c.getDeclaredField("SCHEMA$").get(null));
+
+          if (!fullName.equals(getClassName(schema)))
+            // HACK: schema mismatches class. maven shade plugin? try replacing.
+            schema = Schema.parse
+              (schema.toString().replace(schema.getNamespace(),
+                                         c.getPackage().getName()));
         } catch (NoSuchFieldException e) {
           throw new AvroRuntimeException(e);
         } catch (IllegalAccessException e) {
@@ -197,8 +203,13 @@ public class SpecificData extends Generi
   /** Return the protocol for a Java interface. */
   public Protocol getProtocol(Class iface) {
     try {
-      return (Protocol)(iface.getDeclaredField("PROTOCOL").get(null));
-    } catch (NoSuchFieldException e) {
+      Protocol p = (Protocol)(iface.getDeclaredField("PROTOCOL").get(null));
+      if (!p.getNamespace().equals(iface.getPackage().getName()))
+        // HACK: protocol mismatches iface. maven shade plugin? try replacing.
+        p = Protocol.parse(p.toString().replace(p.getNamespace(),
+                                                iface.getPackage().getName()));
+      return p;
+   } catch (NoSuchFieldException e) {
       throw new AvroRuntimeException(e);
     } catch (IllegalAccessException e) {
       throw new AvroRuntimeException(e);



Mime
View raw message