avro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cutt...@apache.org
Subject svn commit: r1446338 - in /avro/trunk: ./ lang/java/avro/src/main/java/org/apache/avro/generic/ lang/java/avro/src/main/java/org/apache/avro/reflect/ lang/java/avro/src/main/java/org/apache/avro/specific/ lang/java/ipc/src/main/java/org/apache/avro/ipc...
Date Thu, 14 Feb 2013 21:29:26 GMT
Author: cutting
Date: Thu Feb 14 21:29:25 2013
New Revision: 1446338

URL: http://svn.apache.org/r1446338
Log:
AVRO-1247. Java: Fix Requestor and Responder implementations to use correct ClassLoader.

Modified:
    avro/trunk/CHANGES.txt
    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/generic/GenericDatumWriter.java
    avro/trunk/lang/java/avro/src/main/java/org/apache/avro/reflect/ReflectDatumWriter.java
    avro/trunk/lang/java/avro/src/main/java/org/apache/avro/specific/SpecificDatumWriter.java
    avro/trunk/lang/java/ipc/src/main/java/org/apache/avro/ipc/generic/GenericRequestor.java
    avro/trunk/lang/java/ipc/src/main/java/org/apache/avro/ipc/generic/GenericResponder.java
    avro/trunk/lang/java/ipc/src/main/java/org/apache/avro/ipc/reflect/ReflectRequestor.java
    avro/trunk/lang/java/ipc/src/main/java/org/apache/avro/ipc/reflect/ReflectResponder.java
    avro/trunk/lang/java/ipc/src/main/java/org/apache/avro/ipc/specific/SpecificRequestor.java
    avro/trunk/lang/java/ipc/src/main/java/org/apache/avro/ipc/specific/SpecificResponder.java
    avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/TestProtocolReflect.java
    avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/TestProtocolSpecific.java

Modified: avro/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/avro/trunk/CHANGES.txt?rev=1446338&r1=1446337&r2=1446338&view=diff
==============================================================================
--- avro/trunk/CHANGES.txt (original)
+++ avro/trunk/CHANGES.txt Thu Feb 14 21:29:25 2013
@@ -69,6 +69,9 @@ Trunk (not yet released)
     AVRO-1249. Java: Fix DataFileWriter#close() to not throw an
     exception when called twice.  (E. Sammer via cutting)
 
+    AVRO-1247. Java: Fix Requestor and Responder implementations to
+    use correct ClassLoader. (cutting)
+
 Avro 1.7.3 (6 December 2012)
 
   NEW FEATURES

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=1446338&r1=1446337&r2=1446338&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
Thu Feb 14 21:29:25 2013
@@ -56,7 +56,7 @@ public class GenericDatumReader<D> imple
     this(writer, reader, GenericData.get());
   }
 
-  protected GenericDatumReader(Schema writer, Schema reader, GenericData data) {
+  public GenericDatumReader(Schema writer, Schema reader, GenericData data) {
     this(data);
     this.actual = writer;
     this.expected = reader;

Modified: avro/trunk/lang/java/avro/src/main/java/org/apache/avro/generic/GenericDatumWriter.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/avro/src/main/java/org/apache/avro/generic/GenericDatumWriter.java?rev=1446338&r1=1446337&r2=1446338&view=diff
==============================================================================
--- avro/trunk/lang/java/avro/src/main/java/org/apache/avro/generic/GenericDatumWriter.java
(original)
+++ avro/trunk/lang/java/avro/src/main/java/org/apache/avro/generic/GenericDatumWriter.java
Thu Feb 14 21:29:25 2013
@@ -44,7 +44,7 @@ public class GenericDatumWriter<D> imple
     setSchema(root);
   }
 
-  protected GenericDatumWriter(Schema root, GenericData data) {
+  public GenericDatumWriter(Schema root, GenericData data) {
     this(data);
     setSchema(root);
   }

Modified: avro/trunk/lang/java/avro/src/main/java/org/apache/avro/reflect/ReflectDatumWriter.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/avro/src/main/java/org/apache/avro/reflect/ReflectDatumWriter.java?rev=1446338&r1=1446337&r2=1446338&view=diff
==============================================================================
--- avro/trunk/lang/java/avro/src/main/java/org/apache/avro/reflect/ReflectDatumWriter.java
(original)
+++ avro/trunk/lang/java/avro/src/main/java/org/apache/avro/reflect/ReflectDatumWriter.java
Thu Feb 14 21:29:25 2013
@@ -47,7 +47,7 @@ public class ReflectDatumWriter<T> exten
     this(root, ReflectData.get());
   }
 
-  protected ReflectDatumWriter(Schema root, ReflectData reflectData) {
+  public ReflectDatumWriter(Schema root, ReflectData reflectData) {
     super(root, reflectData);
   }
   

Modified: avro/trunk/lang/java/avro/src/main/java/org/apache/avro/specific/SpecificDatumWriter.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/avro/src/main/java/org/apache/avro/specific/SpecificDatumWriter.java?rev=1446338&r1=1446337&r2=1446338&view=diff
==============================================================================
--- avro/trunk/lang/java/avro/src/main/java/org/apache/avro/specific/SpecificDatumWriter.java
(original)
+++ avro/trunk/lang/java/avro/src/main/java/org/apache/avro/specific/SpecificDatumWriter.java
Thu Feb 14 21:29:25 2013
@@ -37,7 +37,7 @@ public class SpecificDatumWriter<T> exte
     super(schema, SpecificData.get());
   }
   
-  protected SpecificDatumWriter(Schema root, SpecificData specificData) {
+  public SpecificDatumWriter(Schema root, SpecificData specificData) {
     super(root, specificData);
   }
   

Modified: avro/trunk/lang/java/ipc/src/main/java/org/apache/avro/ipc/generic/GenericRequestor.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/ipc/src/main/java/org/apache/avro/ipc/generic/GenericRequestor.java?rev=1446338&r1=1446337&r2=1446338&view=diff
==============================================================================
--- avro/trunk/lang/java/ipc/src/main/java/org/apache/avro/ipc/generic/GenericRequestor.java
(original)
+++ avro/trunk/lang/java/ipc/src/main/java/org/apache/avro/ipc/generic/GenericRequestor.java
Thu Feb 14 21:29:25 2013
@@ -24,6 +24,7 @@ import org.apache.avro.AvroRemoteExcepti
 import org.apache.avro.Protocol;
 import org.apache.avro.Schema;
 import org.apache.avro.AvroRuntimeException;
+import org.apache.avro.generic.GenericData;
 import org.apache.avro.generic.GenericDatumReader;
 import org.apache.avro.generic.GenericDatumWriter;
 import org.apache.avro.io.Decoder;
@@ -34,11 +35,22 @@ import org.apache.avro.ipc.Transceiver;
 
 /** {@link Requestor} implementation for generic Java data. */
 public class GenericRequestor extends Requestor {
+  GenericData data;
+
   public GenericRequestor(Protocol protocol, Transceiver transceiver)
     throws IOException {
+    this(protocol, transceiver, GenericData.get());
+  }
+
+  public GenericRequestor(Protocol protocol, Transceiver transceiver,
+                          GenericData data)
+    throws IOException {
     super(protocol, transceiver);
+    this.data = data;
   }
 
+  public GenericData getGenericData() { return data; }
+
   @Override
   public Object request(String messageName, Object request)
     throws IOException {
@@ -70,19 +82,20 @@ public class GenericRequestor extends Re
   @Override
   public void writeRequest(Schema schema, Object request, Encoder out)
     throws IOException {
-    new GenericDatumWriter<Object>(schema).write(request, out);
+    new GenericDatumWriter<Object>(schema, data).write(request, out);
   }
 
   @Override
   public Object readResponse(Schema writer, Schema reader, Decoder in)
     throws IOException {
-    return new GenericDatumReader<Object>(writer, reader).read(null, in);
+    return new GenericDatumReader<Object>(writer, reader, data).read(null, in);
   }
 
   @Override
   public Exception readError(Schema writer, Schema reader, Decoder in)
     throws IOException {
-    Object error = new GenericDatumReader<Object>(writer, reader).read(null,in);
+    Object error = new GenericDatumReader<Object>(writer, reader, data)
+      .read(null,in);
     if (error instanceof CharSequence)
       return new AvroRuntimeException(error.toString()); // system error
     return new AvroRemoteException(error);

Modified: avro/trunk/lang/java/ipc/src/main/java/org/apache/avro/ipc/generic/GenericResponder.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/ipc/src/main/java/org/apache/avro/ipc/generic/GenericResponder.java?rev=1446338&r1=1446337&r2=1446338&view=diff
==============================================================================
--- avro/trunk/lang/java/ipc/src/main/java/org/apache/avro/ipc/generic/GenericResponder.java
(original)
+++ avro/trunk/lang/java/ipc/src/main/java/org/apache/avro/ipc/generic/GenericResponder.java
Thu Feb 14 21:29:25 2013
@@ -23,6 +23,7 @@ import java.io.IOException;
 import org.apache.avro.AvroRemoteException;
 import org.apache.avro.Protocol;
 import org.apache.avro.Schema;
+import org.apache.avro.generic.GenericData;
 import org.apache.avro.generic.GenericDatumReader;
 import org.apache.avro.generic.GenericDatumWriter;
 import org.apache.avro.io.Decoder;
@@ -33,17 +34,26 @@ import org.apache.avro.ipc.Responder;
 
 /** {@link Responder} implementation for generic Java data. */
 public abstract class GenericResponder extends Responder {
+  private GenericData data;
 
   public GenericResponder(Protocol local) {
+    this(local, GenericData.get());
+    
+  }
+
+  public GenericResponder(Protocol local, GenericData data) {
     super(local);
+    this.data = data;
   }
 
+  public GenericData getGenericData() { return data; }
+
   protected DatumWriter<Object> getDatumWriter(Schema schema) {
-    return new GenericDatumWriter<Object>(schema);
+    return new GenericDatumWriter<Object>(schema, data);
   }
 
   protected DatumReader<Object> getDatumReader(Schema actual, Schema expected) {
-    return new GenericDatumReader<Object>(actual, expected);
+    return new GenericDatumReader<Object>(actual, expected, data);
   }
 
   @Override

Modified: avro/trunk/lang/java/ipc/src/main/java/org/apache/avro/ipc/reflect/ReflectRequestor.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/ipc/src/main/java/org/apache/avro/ipc/reflect/ReflectRequestor.java?rev=1446338&r1=1446337&r2=1446338&view=diff
==============================================================================
--- avro/trunk/lang/java/ipc/src/main/java/org/apache/avro/ipc/reflect/ReflectRequestor.java
(original)
+++ avro/trunk/lang/java/ipc/src/main/java/org/apache/avro/ipc/reflect/ReflectRequestor.java
Thu Feb 14 21:29:25 2013
@@ -36,28 +36,43 @@ public class ReflectRequestor extends Sp
   
   public ReflectRequestor(Class<?> iface, Transceiver transceiver)
     throws IOException {
-    this(ReflectData.get().getProtocol(iface), transceiver);
+    this(iface, transceiver, new ReflectData(iface.getClassLoader()));
   }
 
   protected ReflectRequestor(Protocol protocol, Transceiver transceiver)
     throws IOException {
-    super(protocol, transceiver);
+    this(protocol, transceiver, ReflectData.get());
   }
     
+  public ReflectRequestor(Class<?> iface, Transceiver transceiver,
+                          ReflectData data)
+    throws IOException {
+    this(data.getProtocol(iface), transceiver, data);
+  }
+    
+  public ReflectRequestor(Protocol protocol, Transceiver transceiver,
+                          ReflectData data)
+    throws IOException {
+    super(protocol, transceiver, data);
+  }
+    
+  public ReflectData getReflectData() { return (ReflectData)getSpecificData(); }
+
   @Override
   protected DatumWriter<Object> getDatumWriter(Schema schema) {
-    return new ReflectDatumWriter<Object>(schema);
+    return new ReflectDatumWriter<Object>(schema, getReflectData());
   }
 
   @Override
   protected DatumReader<Object> getDatumReader(Schema writer, Schema reader) {
-    return new ReflectDatumReader<Object>(writer, reader);
+    return new ReflectDatumReader<Object>(writer, reader, getReflectData());
   }
 
   /** Create a proxy instance whose methods invoke RPCs. */
   public static <T> T getClient(Class<T> iface, Transceiver transciever) 
     throws IOException {
-    return getClient(iface, transciever, ReflectData.get());
+    return getClient(iface, transciever,
+                     new ReflectData(iface.getClassLoader()));
   }
 
   /** Create a proxy instance whose methods invoke RPCs. */
@@ -65,16 +80,17 @@ public class ReflectRequestor extends Sp
   public static <T> T getClient(Class<T> iface, Transceiver transciever,
                                 ReflectData reflectData) throws IOException {
     Protocol protocol = reflectData.getProtocol(iface);
-    return (T)Proxy.newProxyInstance(iface.getClassLoader(), 
-                                  new Class[] { iface },
-                                  new ReflectRequestor(protocol, transciever));
+    return (T)Proxy.newProxyInstance
+      (reflectData.getClassLoader(), 
+       new Class[] { iface },
+       new ReflectRequestor(protocol, transciever, reflectData));
   }
   
   /** Create a proxy instance whose methods invoke RPCs. */
   @SuppressWarnings("unchecked")
   public static <T> T getClient(Class<T> iface, ReflectRequestor rreq) 
     throws IOException {
-    return (T)Proxy.newProxyInstance(iface.getClassLoader(), 
+    return (T)Proxy.newProxyInstance(rreq.getReflectData().getClassLoader(), 
                                   new Class[] { iface }, rreq);
   }
 }

Modified: avro/trunk/lang/java/ipc/src/main/java/org/apache/avro/ipc/reflect/ReflectResponder.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/ipc/src/main/java/org/apache/avro/ipc/reflect/ReflectResponder.java?rev=1446338&r1=1446337&r2=1446338&view=diff
==============================================================================
--- avro/trunk/lang/java/ipc/src/main/java/org/apache/avro/ipc/reflect/ReflectResponder.java
(original)
+++ avro/trunk/lang/java/ipc/src/main/java/org/apache/avro/ipc/reflect/ReflectResponder.java
Thu Feb 14 21:29:25 2013
@@ -33,21 +33,31 @@ import org.apache.avro.reflect.ReflectDa
 /** {@link org.apache.avro.ipc.Responder} for existing interfaces.*/
 public class ReflectResponder extends SpecificResponder {
   public ReflectResponder(Class iface, Object impl) {
-    super(ReflectData.get().getProtocol(iface), impl, ReflectData.get());
+    this(iface, impl, new ReflectData(impl.getClass().getClassLoader()));
   }
   
   public ReflectResponder(Protocol protocol, Object impl) {
-    super(protocol, impl, ReflectData.get());
+    this(protocol, impl, new ReflectData(impl.getClass().getClassLoader()));
   }
 
+  public ReflectResponder(Class iface, Object impl, ReflectData data) {
+    this(data.getProtocol(iface), impl, data);
+  }
+
+  public ReflectResponder(Protocol protocol, Object impl, ReflectData data) {
+    super(protocol, impl, data);
+  }
+
+  public ReflectData getReflectData() { return (ReflectData)getSpecificData(); }
+
   @Override
   protected DatumWriter<Object> getDatumWriter(Schema schema) {
-    return new ReflectDatumWriter<Object>(schema);
+    return new ReflectDatumWriter<Object>(schema, getReflectData());
   }
 
   @Override
   protected DatumReader<Object> getDatumReader(Schema actual, Schema expected) {
-    return new ReflectDatumReader<Object>(actual, expected);
+    return new ReflectDatumReader<Object>(actual, expected, getReflectData());
   }
 
   @Override

Modified: avro/trunk/lang/java/ipc/src/main/java/org/apache/avro/ipc/specific/SpecificRequestor.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/ipc/src/main/java/org/apache/avro/ipc/specific/SpecificRequestor.java?rev=1446338&r1=1446337&r2=1446338&view=diff
==============================================================================
--- avro/trunk/lang/java/ipc/src/main/java/org/apache/avro/ipc/specific/SpecificRequestor.java
(original)
+++ avro/trunk/lang/java/ipc/src/main/java/org/apache/avro/ipc/specific/SpecificRequestor.java
Thu Feb 14 21:29:25 2013
@@ -42,17 +42,33 @@ import org.apache.avro.specific.Specific
 
 /** {@link org.apache.avro.ipc.Requestor Requestor} for generated interfaces. */
 public class SpecificRequestor extends Requestor implements InvocationHandler {
-  
+  SpecificData data;
+
   public SpecificRequestor(Class<?> iface, Transceiver transceiver)
     throws IOException {
-    this(SpecificData.get().getProtocol(iface), transceiver);
+    this(iface, transceiver, new SpecificData(iface.getClassLoader()));
   }
 
   protected SpecificRequestor(Protocol protocol, Transceiver transceiver)
     throws IOException {
+    this(protocol, transceiver, SpecificData.get());
+  }
+
+  public SpecificRequestor(Class<?> iface, Transceiver transceiver,
+                           SpecificData data)
+    throws IOException {
+    this(data.getProtocol(iface), transceiver, data);
+  }
+
+  public SpecificRequestor(Protocol protocol, Transceiver transceiver,
+                           SpecificData data)
+    throws IOException {
     super(protocol, transceiver);
+    this.data = data;
   }
 
+  public SpecificData getSpecificData() { return data; }
+
   @Override
   public Object invoke(Object proxy, Method method, Object[] args)
     throws Throwable {
@@ -90,7 +106,7 @@ public class SpecificRequestor extends R
   }
 
   protected DatumWriter<Object> getDatumWriter(Schema schema) {
-    return new SpecificDatumWriter<Object>(schema);
+    return new SpecificDatumWriter<Object>(schema, data);
   }
 
   @Deprecated                                     // for compatibility in 1.5
@@ -99,7 +115,7 @@ public class SpecificRequestor extends R
   }
 
   protected DatumReader<Object> getDatumReader(Schema writer, Schema reader) {
-    return new SpecificDatumReader<Object>(writer, reader);
+    return new SpecificDatumReader<Object>(writer, reader, data);
   }
 
   @Override
@@ -129,25 +145,27 @@ public class SpecificRequestor extends R
   /** Create a proxy instance whose methods invoke RPCs. */
   public static  <T> T getClient(Class<T> iface, Transceiver transciever)
     throws IOException {
-    return getClient(iface, transciever, SpecificData.get());
+    return getClient(iface, transciever,
+                     new SpecificData(iface.getClassLoader()));
   }
 
   /** Create a proxy instance whose methods invoke RPCs. */
   @SuppressWarnings("unchecked")
   public static  <T> T getClient(Class<T> iface, Transceiver transciever,
-                                 SpecificData specificData)
+                                 SpecificData data)
     throws IOException {
-    Protocol protocol = specificData.getProtocol(iface);
-    return (T)Proxy.newProxyInstance(iface.getClassLoader(),
-                                  new Class[] { iface },
-                                  new SpecificRequestor(protocol, transciever));
+    Protocol protocol = data.getProtocol(iface);
+    return (T)Proxy.newProxyInstance
+      (data.getClassLoader(),
+       new Class[] { iface },
+       new SpecificRequestor(protocol, transciever, data));
   }
 
   /** Create a proxy instance whose methods invoke RPCs. */
   @SuppressWarnings("unchecked")
   public static <T> T getClient(Class<T> iface, SpecificRequestor requestor)
     throws IOException {
-    return (T)Proxy.newProxyInstance(iface.getClassLoader(),
+    return (T)Proxy.newProxyInstance(requestor.data.getClassLoader(),
                                   new Class[] { iface }, requestor);
   }
 
@@ -158,4 +176,3 @@ public class SpecificRequestor extends R
   }
 
 }
-

Modified: avro/trunk/lang/java/ipc/src/main/java/org/apache/avro/ipc/specific/SpecificResponder.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/ipc/src/main/java/org/apache/avro/ipc/specific/SpecificResponder.java?rev=1446338&r1=1446337&r2=1446338&view=diff
==============================================================================
--- avro/trunk/lang/java/ipc/src/main/java/org/apache/avro/ipc/specific/SpecificResponder.java
(original)
+++ avro/trunk/lang/java/ipc/src/main/java/org/apache/avro/ipc/specific/SpecificResponder.java
Thu Feb 14 21:29:25 2013
@@ -38,31 +38,34 @@ import org.apache.avro.ipc.generic.Gener
 /** {@link org.apache.avro.ipc.Responder Responder} for generated interfaces.*/
 public class SpecificResponder extends GenericResponder {
   private Object impl;
-  private SpecificData data;
 
   public SpecificResponder(Class iface, Object impl) {
-    this(SpecificData.get().getProtocol(iface), impl);
+    this(iface, impl, new SpecificData(impl.getClass().getClassLoader()));
   }
     
   public SpecificResponder(Protocol protocol, Object impl) {
-    this(protocol, impl, SpecificData.get());
+    this(protocol, impl, new SpecificData(impl.getClass().getClassLoader()));
   }
 
-  protected SpecificResponder(Protocol protocol, Object impl,
-                              SpecificData data) {
-    super(protocol);
+  public SpecificResponder(Class iface, Object impl, SpecificData data) {
+    this(data.getProtocol(iface), impl, data);
+  }
+
+  public SpecificResponder(Protocol protocol, Object impl, SpecificData data) {
+    super(protocol, data);
     this.impl = impl;
-    this.data = data;
   }
 
+  public SpecificData getSpecificData() {return (SpecificData)getGenericData();}
+
   @Override
   protected DatumWriter<Object> getDatumWriter(Schema schema) {
-    return new SpecificDatumWriter<Object>(schema);
+    return new SpecificDatumWriter<Object>(schema, getSpecificData());
   }
 
   @Override
   protected DatumReader<Object> getDatumReader(Schema actual, Schema expected) {
-    return new SpecificDatumReader<Object>(actual, expected);
+    return new SpecificDatumReader<Object>(actual, expected, getSpecificData());
   }
 
   @Override
@@ -80,7 +83,7 @@ public class SpecificResponder extends G
     try {
       for (Schema.Field param: message.getRequest().getFields()) {
         params[i] = ((GenericRecord)request).get(param.name());
-        paramTypes[i] = data.getClass(param.schema());
+        paramTypes[i] = getSpecificData().getClass(param.schema());
         i++;
       }
       Method method = impl.getClass().getMethod(message.getName(), paramTypes);

Modified: avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/TestProtocolReflect.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/TestProtocolReflect.java?rev=1446338&r1=1446337&r2=1446338&view=diff
==============================================================================
--- avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/TestProtocolReflect.java (original)
+++ avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/TestProtocolReflect.java Thu Feb
14 21:29:25 2013
@@ -17,6 +17,7 @@
  */
 package org.apache.avro;
 
+import org.apache.avro.reflect.ReflectData;
 import org.apache.avro.ipc.Server;
 import org.apache.avro.ipc.Transceiver;
 import org.apache.avro.ipc.SocketServer;
@@ -81,6 +82,19 @@ public class TestProtocolReflect {
     proxy = ReflectRequestor.getClient(Simple.class, client);
   }
 
+  @Test public void testClassLoader() throws Exception {
+    ClassLoader loader = new ClassLoader() {};
+
+    ReflectResponder responder
+      = new ReflectResponder(Simple.class, new TestImpl(),
+                             new ReflectData(loader));
+    assertEquals(responder.getReflectData().getClassLoader(), loader);
+
+    ReflectRequestor requestor
+      = new ReflectRequestor(Simple.class, client, new ReflectData(loader));
+    assertEquals(requestor.getReflectData().getClassLoader(), loader);
+  }
+
   @Test
   public void testHello() throws IOException {
     String response = proxy.hello("bob");

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=1446338&r1=1446337&r2=1446338&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 Thu Feb
14 21:29:25 2013
@@ -17,6 +17,7 @@
  */
 package org.apache.avro;
 
+import org.apache.avro.specific.SpecificData;
 import org.apache.avro.ipc.HttpTransceiver;
 import org.apache.avro.ipc.RPCContext;
 import org.apache.avro.ipc.RPCPlugin;
@@ -115,6 +116,19 @@ public class TestProtocolSpecific {
     return new SocketTransceiver(new InetSocketAddress(server.getPort()));
   }
 
+  @Test public void testClassLoader() throws Exception {
+    ClassLoader loader = new ClassLoader() {};
+
+    SpecificResponder responder
+      = new SpecificResponder(Simple.class, new TestImpl(),
+                              new SpecificData(loader));
+    assertEquals(responder.getSpecificData().getClassLoader(), loader);
+
+    SpecificRequestor requestor
+      = new SpecificRequestor(Simple.class, client, new SpecificData(loader));
+    assertEquals(requestor.getSpecificData().getClassLoader(), loader);
+  }
+
   @Test public void testGetRemote() throws IOException {
     assertEquals(Simple.PROTOCOL, SpecificRequestor.getRemote(proxy));
   }



Mime
View raw message