[
https://issues.apache.org/jira/browse/MRUNIT-70?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13429948#comment-13429948
]
Tarun Adiwal commented on MRUNIT-70:
------------------------------------
Hi Jim,
I have just upgrade from mrunit-0.8.0 to mrunit 0.9.0. I have following code in
my reducer:
context.write( null, new Text( key.toString().trim() +"_" + value.toString() )
);
when I run my test the above code throws NullPointerException. The full
stacktrace is given below :
java.lang.NullPointerException
at org.apache.hadoop.mrunit.Serialization.copy(Serialization.java:52)
at org.apache.hadoop.mrunit.Serialization.copy(Serialization.java:81)
at
org.apache.hadoop.mrunit.mapreduce.mock.MockContextWrapper$4.answer(MockContextWrapper.java:78)
at
org.mockito.internal.stubbing.StubbedInvocationMatcher.answer(StubbedInvocationMatcher.java:31)
at org.mockito.internal.MockHandler.handle(MockHandler.java:97)
at
org.mockito.internal.creation.MethodInterceptorFilter.intercept(MethodInterceptorFilter.java:47)
at
org.apache.hadoop.mapreduce.Reducer$Context$$EnhancerByMockitoWithCGLIB$$fd46c1a7.write(<generated>)
As you said --
change copy(orig, copy, conf) to allow null for copy which means to create a
new object
But I think when I am passing null to the context.write() method it is not
creating a new object but giving NullPointerException at
org.apache.hadoop.mrunit.Serialization.copy(Serialization.java:52).
Can you please suggest.
Thanks,
Tarun
> copy(orig, conf) in Serialization shouldn't require objects to have a no-args
> constructor, and copy(orig, copy, conf) seems to violate contract for
> deserializer.deserialize()
> ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: MRUNIT-70
> URL: https://issues.apache.org/jira/browse/MRUNIT-70
> Project: MRUnit
> Issue Type: Bug
> Affects Versions: 0.8.0
> Reporter: Meloss Xeloss
> Assignee: Jim Donofrio
> Priority: Minor
> Fix For: 0.9.0
>
> Attachments: MRUNIT-70-1.patch
>
>
> The copy(orig, conf) method requires objects to have a no-args constructor,
> which is non-ideal, since it passes on to Deserializer.deserialize, which can
> create a new object if passed in null. Additionally, the contract for
> deserialize only _can_ fill in the object passed in, so the copy method will
> not perform as expected if it does not.
> http://hadoop.apache.org/common/docs/current/api/org/apache/hadoop/io/serializer/Deserializer.html#deserialize%28T%29
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira