Bug 1040350

Summary: NPE in setting NamingPolicy
Product: [Fedora] Fedora Reporter: Michael Simacek <msimacek>
Component: mockitoAssignee: Roman Kennke <rkennke>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: java-sig-commits, jerboaa, mizdebsk, msrb, omajid, rkennke
Target Milestone: ---Keywords: Patch
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: mockito-1.9.0-14.fc21 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-03-21 09:13:13 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1078979    
Attachments:
Description Flags
NPE workaround
none
Update to upstream version 1.9.5 none

Description Michael Simacek 2013-12-11 09:25:54 UTC
Created attachment 835194 [details]
NPE workaround

Description of problem:
Some tests using mockito throw NullPointerException (wrapped in RuntimeException) because mockito fails to set MockitoNamingPolicy in cglib. Current implementation tries to set it by modifing private field of MethodProxy via reflection, which fails, because current version of cglib sets it to null after using it.
It was already discussed in http://bugs.debian.org/707298. The suggested workaround is not setting it to null in cglib, but it seems to me that the value of NamingPolicy has already been used and changing it after the MethodProxy has been initialized doesn't really do anything.
In the current upstream version (1.9.5) the problem still persist.
I'm attaching a simple workaround, that just checks for null, which cannot break anything and fixes the tests that failed for me. But it seems like the proper solution would need a larger rewrite of parts of mockito that use internals of cglib.

Steps to reproduce:
1. try to build current version of httpcomponents-client with tests enabled

Comment 1 Michael Simacek 2013-12-11 09:27:56 UTC
Created attachment 835195 [details]
Update to upstream version 1.9.5

Comment 2 Michal Srb 2014-03-21 09:13:13 UTC
I've applied Michael's patch for NPE. It fixes the test failures in httpcomponents-core (#1078979).

We should probably create new bug for mockito update to 1.9.5.