Workaround for NPE in setting NamingPolicy

Signed-off-by: Michael Simacek <msimacek@redhat.com>
This commit is contained in:
Michael Simacek 2013-12-11 09:37:01 +01:00 committed by Michal Srb
parent 6101e7da4e
commit 2c1e729ef7
2 changed files with 42 additions and 1 deletions

View File

@ -1,6 +1,6 @@
Name: mockito
Version: 1.9.0
Release: 13%{?dist}
Release: 14%{?dist}
Summary: A Java mocking framework
License: MIT
@ -12,6 +12,8 @@ Patch1: fix-cglib-refs.patch
Patch2: maven-cglib-dependency.patch
Patch3: fix-bnd-config.patch
Patch4: %{name}-matcher.patch
# Workaround for NPE in setting NamingPolicy in cglib
Patch5: setting-naming-policy.patch
BuildArch: noarch
BuildRequires: jpackage-utils
@ -53,8 +55,10 @@ This package contains the API documentation for %{name}.
sed -i 's/Bundle-Version= ${version}/Bundle-Version= %{version}/' conf/mockito-core.bnd
%patch3
%patch4 -p1
%patch5 -p1
%build
build-jar-repository lib/compile objenesis
ant jar javadoc
# Convert to OSGi bundle
pushd target
@ -88,6 +92,9 @@ cp -rp target/javadoc/* $RPM_BUILD_ROOT%{_javadocdir}/%{name}
%doc NOTICE
%changelog
* Wed Dec 11 2013 Michael Simacek <msimacek@redhat.com> - 1.9.0-14
- Workaround for NPE in setting NamingPolicy
* Sat Aug 03 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.9.0-13
- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild

View File

@ -0,0 +1,34 @@
From 04e36a01e93c3b79caa9f7e9e8573fe2a0d65d1a Mon Sep 17 00:00:00 2001
From: Michael Simacek <msimacek@redhat.com>
Date: Thu, 5 Dec 2013 16:53:36 +0100
Subject: [PATCH] Setting naming policy
Signed-off-by: Michael Simacek <msimacek@redhat.com>
---
src/org/mockito/internal/creation/cglib/CGLIBHacker.java | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/org/mockito/internal/creation/cglib/CGLIBHacker.java b/src/org/mockito/internal/creation/cglib/CGLIBHacker.java
index 172f744..de53ab1 100644
--- a/src/org/mockito/internal/creation/cglib/CGLIBHacker.java
+++ b/src/org/mockito/internal/creation/cglib/CGLIBHacker.java
@@ -20,6 +20,9 @@ public class CGLIBHacker implements Serializable {
Field createInfoField = reflectOnCreateInfo(methodProxy);
createInfoField.setAccessible(true);
Object createInfo = createInfoField.get(methodProxy);
+ if (createInfo == null) {
+ return;
+ }
Field namingPolicyField = createInfo.getClass().getDeclaredField("namingPolicy");
namingPolicyField.setAccessible(true);
if (namingPolicyField.get(createInfo) == null) {
@@ -43,4 +46,4 @@ public class CGLIBHacker implements Serializable {
}
return cglibMethodProxyClass.getDeclaredField("createInfo");
}
-}
\ No newline at end of file
+}
--
1.8.3.1