Author: jghoman
Date: Mon Apr  9 17:48:54 2012
New Revision: 1311355

URL: http://svn.apache.org/viewvc?rev=1311355&view=rev
Log:
GIRAPH-85: Simplify return expression in RPCCommunications::getRPCProxy. 
Contributed by Eli Reisman.

Modified:
    incubator/giraph/trunk/CHANGELOG
    
incubator/giraph/trunk/src/main/java/org/apache/giraph/comm/RPCCommunications.java

Modified: incubator/giraph/trunk/CHANGELOG
URL: 
http://svn.apache.org/viewvc/incubator/giraph/trunk/CHANGELOG?rev=1311355&r1=1311354&r2=1311355&view=diff
==============================================================================
--- incubator/giraph/trunk/CHANGELOG (original)
+++ incubator/giraph/trunk/CHANGELOG Mon Apr  9 17:48:54 2012
@@ -2,6 +2,9 @@ Giraph Change Log
 
 Release 0.2.0 - unreleased
 
+  GIRAPH-85: Simplify return expression in 
+  RPCCommunications::getRPCProxy (Eli Reisman via jghoman)
+
   GIRAPH-171: Total time in MasterThread.run() is calculated
   incorrectly (ekoontz via aching).
 

Modified: 
incubator/giraph/trunk/src/main/java/org/apache/giraph/comm/RPCCommunications.java
URL: 
http://svn.apache.org/viewvc/incubator/giraph/trunk/src/main/java/org/apache/giraph/comm/RPCCommunications.java?rev=1311355&r1=1311354&r2=1311355&view=diff
==============================================================================
--- 
incubator/giraph/trunk/src/main/java/org/apache/giraph/comm/RPCCommunications.java
 (original)
+++ 
incubator/giraph/trunk/src/main/java/org/apache/giraph/comm/RPCCommunications.java
 Mon Apr  9 17:48:54 2012
@@ -153,6 +153,7 @@ public class RPCCommunications<I extends
    * @param jt Job token.
    * @return Proxy of the RPC server.
    */
+  @SuppressWarnings("unchecked")
   protected CommunicationsInterface<I, V, E, M> getRPCProxy(
     final InetSocketAddress addr,
     String jobId,
@@ -164,18 +165,12 @@ public class RPCCommunications<I extends
     throws IOException, InterruptedException {
     final Configuration config = new Configuration(conf);
     /*if_not[HADOOP]
-        @SuppressWarnings("unchecked")
-        CommunicationsInterface<I, V, E, M> proxy =
-            (CommunicationsInterface<I, V, E, M>)RPC.getProxy(
+        return (CommunicationsInterface<I, V, E, M>)RPC.getProxy(
                  CommunicationsInterface.class, VERSION_ID, addr, config);
-        return proxy;
       else[HADOOP]*/
     if (jt == null) {
-      @SuppressWarnings("unchecked")
-      CommunicationsInterface<I, V, E, M> proxy =
-        (CommunicationsInterface<I, V, E, M>) RPC.getProxy(
+      return (CommunicationsInterface<I, V, E, M>) RPC.getProxy(
           CommunicationsInterface.class, VERSION_ID, addr, config);
-      return proxy;
     }
     jt.setService(new Text(addr.getAddress().getHostAddress() + ":" +
         addr.getPort()));
@@ -184,18 +179,17 @@ public class RPCCommunications<I extends
     UserGroupInformation owner =
         UserGroupInformation.createRemoteUser(jobId);
     owner.addToken(jt);
-    @SuppressWarnings("unchecked")
-    CommunicationsInterface<I, V, E, M> proxy =
+    return
       owner.doAs(new PrivilegedExceptionAction<
         CommunicationsInterface<I, V, E, M>>() {
         @Override
+        @SuppressWarnings("unchecked")
         public CommunicationsInterface<I, V, E, M> run() throws Exception {
           // All methods in CommunicationsInterface will be used for RPC
           return (CommunicationsInterface<I, V, E, M>) RPC.getProxy(
             CommunicationsInterface.class, VERSION_ID, addr, config);
         }
       });
-    return proxy;
     /*end[HADOOP]*/
   }
 }


Reply via email to