[ 
https://issues.apache.org/jira/browse/YARN-2051?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14080780#comment-14080780
 ] 

Junping Du commented on YARN-2051:
----------------------------------

Again, good work, [~decster]!
Some comments below, most of them are trivial:

{code}
+    System.out.printf("Validate %s %s\n", recordClass.getName(),
+        protoClass.getName());
{code}
Please replace this and other places that try to print to console with LOG.

{code}
+        ret = Sets.newHashSet(genTypeValue(params[0]));        
{code}
Please remove unnecessary space in the end of this line.

{code}
throw new IllegalArgumentException("type not support: " + type);
{code}
May be "type: " + type + " is not supported" is more readable?

{code}
+  private static Object genByNewInstance(Class clazz) throws Exception {
{code}
generateNewInstance() sounds like a better name?

{code}
ret = newInstance.invoke(null, args);
{code}
The code here has risk of NPE if newInstance method is not found previously (it 
is possible, as newInstance() method is not forced to have, although most class 
obey this rule). Better to add some exception handling here.

{code}
+      } else if (clazz.equals(ByteBuffer.class)) {
+        // return new ByteBuffer every time
+        // to prevent potential side effects
+        return ByteBuffer.allocate(4);
+      }
{code}
What's reasonable value we generate here for ByteBuffer? Just empty. Isn't it?


> Fix code bug and add more unit tests for PBImpls
> ------------------------------------------------
>
>                 Key: YARN-2051
>                 URL: https://issues.apache.org/jira/browse/YARN-2051
>             Project: Hadoop YARN
>          Issue Type: Test
>            Reporter: Junping Du
>            Assignee: Binglin Chang
>            Priority: Critical
>         Attachments: YARN-2051.v1.patch
>
>
> From YARN-2016, we can see some bug could exist in PB implementation of 
> protocol. The bad news is most of these PBImpl don't have any unit test to 
> verify the info is not lost or changed after serialization/deserialization. 
> We should add more tests for it.



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to