Note: This is a public test instance of Red Hat Bugzilla. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback at bugzilla.redhat.com.
Bug 1040350 - NPE in setting NamingPolicy
Summary: NPE in setting NamingPolicy
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: mockito
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Roman Kennke
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: 1078979
TreeView+ depends on / blocked
 
Reported: 2013-12-11 09:25 UTC by Michael Simacek
Modified: 2014-03-21 09:13 UTC (History)
6 users (show)

Fixed In Version: mockito-1.9.0-14.fc21
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2014-03-21 09:13:13 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
NPE workaround (3.36 KB, patch)
2013-12-11 09:25 UTC, Michael Simacek
no flags Details | Diff
Update to upstream version 1.9.5 (19.21 KB, patch)
2013-12-11 09:27 UTC, Michael Simacek
no flags Details | Diff


Links
System ID Private Priority Status Summary Last Updated
Debian BTS 707298 0 None None None Never

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.


Note You need to log in before you can comment on or make changes to this bug.