You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by mg...@apache.org on 2017/06/19 20:00:56 UTC
[1/2] wicket git commit: Update Mockito to 2.8.47
Repository: wicket
Updated Branches:
refs/heads/master 13fa9f8ff -> e306c73ec
Update Mockito to 2.8.47
Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/adbdec40
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/adbdec40
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/adbdec40
Branch: refs/heads/master
Commit: adbdec408c437c0ba5e34efc6a5fffed4a1ce952
Parents: 13fa9f8
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
Authored: Mon Jun 19 13:30:34 2017 +0200
Committer: Martin Tzvetanov Grigorov <mg...@apache.org>
Committed: Mon Jun 19 21:19:14 2017 +0200
----------------------------------------------------------------------
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/wicket/blob/adbdec40/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 0ad53e8..a95eaaa 100644
--- a/pom.xml
+++ b/pom.xml
@@ -133,7 +133,7 @@
<servlet-api.version>3.1.0</servlet-api.version>
<maven.javadoc.version>2.10.4</maven.javadoc.version>
<maven.surefire.version>2.20</maven.surefire.version>
- <mockito.version>2.7.22</mockito.version>
+ <mockito.version>2.8.47</mockito.version>
<slf4j.version>1.7.25</slf4j.version>
<log4j.version>2.8.2</log4j.version>
<hamcrest.version>2.0.0.0</hamcrest.version>
[2/2] wicket git commit: WICKET-4324 [wicket-ioc]
LazyInitProxyFactory CGLIB proxies naming strategy may cause
java.lang.IllegalAccessError
Posted by mg...@apache.org.
WICKET-4324 [wicket-ioc] LazyInitProxyFactory CGLIB proxies naming strategy may cause java.lang.IllegalAccessError
Change the calculation of the 'prefix' in WicketNamingStrategy from 'WICKET_package.Class' to 'package.Wicket_Proxy_Class'
(cherry picked from commit 27b9a67d9e986d8998888e9984125ce2a2248498)
Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/e306c73e
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/e306c73e
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/e306c73e
Branch: refs/heads/master
Commit: e306c73eca6c8d9960b94416e01a1d6aeefe68c4
Parents: adbdec4
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
Authored: Mon Jun 19 21:59:05 2017 +0200
Committer: Martin Tzvetanov Grigorov <mg...@apache.org>
Committed: Mon Jun 19 22:00:47 2017 +0200
----------------------------------------------------------------------
.../wicket/proxy/LazyInitProxyFactory.java | 7 +-
.../wicket/proxy/LazyInitProxyFactoryTest.java | 67 ++++++++++++++++++++
.../proxy/PackagePrivateConcreteObject.java | 54 ++++++++++++++++
3 files changed, 127 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/wicket/blob/e306c73e/wicket-ioc/src/main/java/org/apache/wicket/proxy/LazyInitProxyFactory.java
----------------------------------------------------------------------
diff --git a/wicket-ioc/src/main/java/org/apache/wicket/proxy/LazyInitProxyFactory.java b/wicket-ioc/src/main/java/org/apache/wicket/proxy/LazyInitProxyFactory.java
index 06d3674..d3b1a4d 100644
--- a/wicket-ioc/src/main/java/org/apache/wicket/proxy/LazyInitProxyFactory.java
+++ b/wicket-ioc/src/main/java/org/apache/wicket/proxy/LazyInitProxyFactory.java
@@ -42,6 +42,7 @@ import org.apache.wicket.core.util.lang.WicketObjects;
import org.apache.wicket.model.IModel;
import org.apache.wicket.proxy.objenesis.ObjenesisProxyFactory;
import org.apache.wicket.util.io.IClusterable;
+import org.apache.wicket.util.string.Strings;
/**
* A factory class that creates lazy init proxies given a type and a {@link IProxyTargetLocator}
@@ -610,7 +611,11 @@ public class LazyInitProxyFactory
public String getClassName(final String prefix, final String source, final Object key,
final Predicate names)
{
- return super.getClassName("WICKET_" + prefix, source, key, names);
+ int lastIdxOfDot = prefix.lastIndexOf('.');
+ String packageName = prefix.substring(0, lastIdxOfDot);
+ String className = prefix.substring(lastIdxOfDot + 1);
+ String newPrefix = packageName + ".Wicket_Proxy_" + className;
+ return super.getClassName(newPrefix, source, key, names);
}
}
http://git-wip-us.apache.org/repos/asf/wicket/blob/e306c73e/wicket-ioc/src/test/java/org/apache/wicket/proxy/LazyInitProxyFactoryTest.java
----------------------------------------------------------------------
diff --git a/wicket-ioc/src/test/java/org/apache/wicket/proxy/LazyInitProxyFactoryTest.java b/wicket-ioc/src/test/java/org/apache/wicket/proxy/LazyInitProxyFactoryTest.java
index 897c628..60bab12 100644
--- a/wicket-ioc/src/test/java/org/apache/wicket/proxy/LazyInitProxyFactoryTest.java
+++ b/wicket-ioc/src/test/java/org/apache/wicket/proxy/LazyInitProxyFactoryTest.java
@@ -42,6 +42,8 @@ public class LazyInitProxyFactoryTest extends Assert
private static ConcreteObject concreteObject = new ConcreteObject("concrete");
+ private static final PackagePrivateConcreteObject PACKAGE_PRIVATE_CONCRETE_OBJECT = new PackagePrivateConcreteObject("package-private-concrete");
+
private static IProxyTargetLocator interfaceObjectLocator = new IProxyTargetLocator()
{
private static final long serialVersionUID = 1L;
@@ -64,6 +66,17 @@ public class LazyInitProxyFactoryTest extends Assert
}
};
+ private final static IProxyTargetLocator PACKAGE_PRIVATE_CONCRETE_OBJECT_LOCATOR = new IProxyTargetLocator()
+ {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Object locateProxyTarget()
+ {
+ return LazyInitProxyFactoryTest.PACKAGE_PRIVATE_CONCRETE_OBJECT;
+ }
+ };
+
private static IProxyTargetLocator stringObjectLocator = new IProxyTargetLocator()
{
private static final long serialVersionUID = 1L;
@@ -176,6 +189,60 @@ public class LazyInitProxyFactoryTest extends Assert
}
/**
+ * Tests lazy init proxy to represent package private concrete objects
+ *
+ * https://issues.apache.org/jira/browse/WICKET-4324
+ */
+ @Test
+ public void testPackagePrivateConcreteProxy()
+ {
+ PackagePrivateConcreteObject proxy = (PackagePrivateConcreteObject)LazyInitProxyFactory.createProxy(
+ PackagePrivateConcreteObject.class, PACKAGE_PRIVATE_CONCRETE_OBJECT_LOCATOR);
+
+ // test proxy implements ILazyInitProxy
+ assertThat(proxy, instanceOf(ILazyInitProxy.class));
+ assertTrue(((ILazyInitProxy)proxy).getObjectLocator() == PACKAGE_PRIVATE_CONCRETE_OBJECT_LOCATOR);
+
+ // test we do not have a jdk dynamic proxy
+ assertFalse(Proxy.isProxyClass(proxy.getClass()));
+
+ // test method invocation
+ assertEquals(proxy.getMessage(), "package-private-concrete");
+
+ // test serialization
+ PackagePrivateConcreteObject proxy2 = WicketObjects.cloneObject(proxy);
+ assertTrue(proxy != proxy2);
+ assertEquals(proxy2.getMessage(), "package-private-concrete");
+
+ // test equals/hashcode method interception
+ final IObjectMethodTester tester = new ObjectMethodTester();
+ assertTrue(tester.isValid());
+
+ // test only a single class is generated,
+ // otherwise permgen space will fill up with each proxy
+ assertSame(proxy.getClass(), LazyInitProxyFactory.createProxy(
+ PackagePrivateConcreteObject.class, PACKAGE_PRIVATE_CONCRETE_OBJECT_LOCATOR).getClass());
+
+ IProxyTargetLocator testerLocator = new IProxyTargetLocator()
+ {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Object locateProxyTarget()
+ {
+ return tester;
+ }
+ };
+
+ ObjectMethodTester testerProxy = (ObjectMethodTester)LazyInitProxyFactory.createProxy(
+ ObjectMethodTester.class, testerLocator);
+ testerProxy.equals(this);
+ testerProxy.hashCode();
+ testerProxy.toString();
+ assertTrue(tester.isValid());
+ }
+
+ /**
* Tests lazy init concrete replacement replacement
*/
@Test
http://git-wip-us.apache.org/repos/asf/wicket/blob/e306c73e/wicket-ioc/src/test/java/org/apache/wicket/proxy/PackagePrivateConcreteObject.java
----------------------------------------------------------------------
diff --git a/wicket-ioc/src/test/java/org/apache/wicket/proxy/PackagePrivateConcreteObject.java b/wicket-ioc/src/test/java/org/apache/wicket/proxy/PackagePrivateConcreteObject.java
new file mode 100644
index 0000000..3b31e63
--- /dev/null
+++ b/wicket-ioc/src/test/java/org/apache/wicket/proxy/PackagePrivateConcreteObject.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.proxy;
+
+/**
+ * Mock dependency that does not implement an interface.
+ * Its visibility is package private (to {@link LazyInitProxyFactoryTest}) to test a bug
+ * described at https://issues.apache.org/jira/browse/WICKET-4324
+ */
+class PackagePrivateConcreteObject
+{
+ private String message;
+
+ /**
+ * Empty default constructor. It is required by cglib to create a proxy.
+ */
+ public PackagePrivateConcreteObject()
+ {
+
+ }
+
+ /**
+ * Constructor
+ *
+ * @param message
+ */
+ public PackagePrivateConcreteObject(final String message)
+ {
+ this.message = message;
+ }
+
+ /**
+ * @return message
+ */
+ public String getMessage()
+ {
+ return message;
+ }
+
+}