Skip to content

Commit aa48dec

Browse files
committed
Merge branch '5.3.x'
# Conflicts: # build.gradle # spring-jms/src/main/java/org/springframework/jms/connection/CachingConnectionFactory.java
2 parents c235ad0 + 57db73d commit aa48dec

File tree

18 files changed

+1102
-38
lines changed

18 files changed

+1102
-38
lines changed

build.gradle

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ configure(allprojects) { project ->
2727

2828
dependencyManagement {
2929
imports {
30-
mavenBom "com.fasterxml.jackson:jackson-bom:2.13.1"
30+
mavenBom "com.fasterxml.jackson:jackson-bom:2.13.3"
3131
mavenBom "io.netty:netty-bom:4.1.77.Final"
3232
mavenBom "io.projectreactor:reactor-bom:2022.0.0-M2"
3333
mavenBom "io.r2dbc:r2dbc-bom:Borca-SR1"
@@ -86,9 +86,9 @@ configure(allprojects) { project ->
8686
dependency "org.ogce:xpp3:1.1.6"
8787
dependency "org.yaml:snakeyaml:1.30"
8888

89-
dependency "com.h2database:h2:2.1.210"
90-
dependency "com.github.ben-manes.caffeine:caffeine:3.1.0"
91-
dependency "com.github.librepdf:openpdf:1.3.27"
89+
dependency "com.h2database:h2:2.1.212"
90+
dependency "com.github.ben-manes.caffeine:caffeine:3.1.1"
91+
dependency "com.github.librepdf:openpdf:1.3.28"
9292
dependency "com.rometools:rome:1.18.0"
9393
dependency "commons-io:commons-io:2.11.0"
9494
dependency "io.vavr:vavr:0.10.4"
@@ -117,14 +117,14 @@ configure(allprojects) { project ->
117117
dependency "org.webjars:webjars-locator-core:0.48"
118118
dependency "org.webjars:underscorejs:1.8.3"
119119

120-
dependencySet(group: 'org.apache.tomcat', version: '10.0.20') {
120+
dependencySet(group: 'org.apache.tomcat', version: '10.0.22') {
121121
entry 'tomcat-util'
122122
entry('tomcat-websocket') {
123123
exclude group: "org.apache.tomcat", name: "tomcat-servlet-api"
124124
exclude group: "org.apache.tomcat", name: "tomcat-websocket-api"
125125
}
126126
}
127-
dependencySet(group: 'org.apache.tomcat.embed', version: '10.0.20') {
127+
dependencySet(group: 'org.apache.tomcat.embed', version: '10.0.22') {
128128
entry 'tomcat-embed-core'
129129
entry 'tomcat-embed-websocket'
130130
}
@@ -177,18 +177,18 @@ configure(allprojects) { project ->
177177
exclude group: "org.hamcrest", name: "hamcrest-core"
178178
}
179179
}
180-
dependencySet(group: 'org.mockito', version: '4.5.1') {
180+
dependencySet(group: 'org.mockito', version: '4.6.1') {
181181
entry('mockito-core') {
182182
exclude group: "org.hamcrest", name: "hamcrest-core"
183183
}
184184
entry 'mockito-junit-jupiter'
185185
}
186186
dependency "io.mockk:mockk:1.12.1"
187187

188-
dependency("net.sourceforge.htmlunit:htmlunit:2.61.0") {
188+
dependency("net.sourceforge.htmlunit:htmlunit:2.62.0") {
189189
exclude group: "commons-logging", name: "commons-logging"
190190
}
191-
dependency("org.seleniumhq.selenium:htmlunit-driver:2.61.0") {
191+
dependency("org.seleniumhq.selenium:htmlunit-driver:2.62.0") {
192192
exclude group: "commons-logging", name: "commons-logging"
193193
}
194194
dependency("org.seleniumhq.selenium:selenium-java:3.141.59") {
@@ -299,7 +299,7 @@ configure([rootProject] + javaProjects) { project ->
299299
}
300300

301301
checkstyle {
302-
toolVersion = "10.1"
302+
toolVersion = "10.3"
303303
configDirectory.set(rootProject.file("src/checkstyle"))
304304
}
305305

spring-core/spring-core.gradle

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,7 @@ jar {
8686
dependsOn cglibRepackJar
8787
from(zipTree(cglibRepackJar.archivePath)) {
8888
include "org/springframework/cglib/**"
89-
exclude "org/springframework/cglib/beans/BeanMap.class"
90-
exclude "org/springframework/cglib/beans/BeanMap\$*.class"
89+
exclude "org/springframework/cglib/beans/**"
9190
exclude "org/springframework/cglib/core/AbstractClassGenerator*.class"
9291
exclude "org/springframework/cglib/core/AsmApi*.class"
9392
exclude "org/springframework/cglib/core/KeyFactory.class"
Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
/*
2+
* Copyright 2003,2004 The Apache Software Foundation
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.springframework.cglib.beans;
17+
18+
import java.beans.PropertyDescriptor;
19+
import java.lang.reflect.*;
20+
import java.security.ProtectionDomain;
21+
import org.springframework.cglib.core.*;
22+
import org.springframework.asm.ClassVisitor;
23+
import org.springframework.asm.Type;
24+
import java.util.*;
25+
26+
/**
27+
* @author Chris Nokleberg
28+
*/
29+
@SuppressWarnings({"rawtypes", "unchecked"})
30+
abstract public class BeanCopier
31+
{
32+
private static final BeanCopierKey KEY_FACTORY =
33+
(BeanCopierKey)KeyFactory.create(BeanCopierKey.class);
34+
private static final Type CONVERTER =
35+
TypeUtils.parseType("org.springframework.cglib.core.Converter");
36+
private static final Type BEAN_COPIER =
37+
TypeUtils.parseType("org.springframework.cglib.beans.BeanCopier");
38+
private static final Signature COPY =
39+
new Signature("copy", Type.VOID_TYPE, new Type[]{ Constants.TYPE_OBJECT, Constants.TYPE_OBJECT, CONVERTER });
40+
private static final Signature CONVERT =
41+
TypeUtils.parseSignature("Object convert(Object, Class, Object)");
42+
43+
interface BeanCopierKey {
44+
public Object newInstance(String source, String target, boolean useConverter);
45+
}
46+
47+
public static BeanCopier create(Class source, Class target, boolean useConverter) {
48+
Generator gen = new Generator();
49+
gen.setSource(source);
50+
gen.setTarget(target);
51+
gen.setUseConverter(useConverter);
52+
return gen.create();
53+
}
54+
55+
abstract public void copy(Object from, Object to, Converter converter);
56+
57+
public static class Generator extends AbstractClassGenerator {
58+
private static final Source SOURCE = new Source(BeanCopier.class.getName());
59+
private Class source;
60+
private Class target;
61+
private boolean useConverter;
62+
63+
public Generator() {
64+
super(SOURCE);
65+
}
66+
67+
public void setSource(Class source) {
68+
if(!Modifier.isPublic(source.getModifiers())){
69+
setNamePrefix(source.getName());
70+
}
71+
this.source = source;
72+
}
73+
74+
public void setTarget(Class target) {
75+
if(!Modifier.isPublic(target.getModifiers())){
76+
setNamePrefix(target.getName());
77+
}
78+
this.target = target;
79+
// SPRING PATCH BEGIN
80+
setContextClass(target);
81+
// SPRING PATCH END
82+
}
83+
84+
public void setUseConverter(boolean useConverter) {
85+
this.useConverter = useConverter;
86+
}
87+
88+
protected ClassLoader getDefaultClassLoader() {
89+
return source.getClassLoader();
90+
}
91+
92+
protected ProtectionDomain getProtectionDomain() {
93+
return ReflectUtils.getProtectionDomain(source);
94+
}
95+
96+
public BeanCopier create() {
97+
Object key = KEY_FACTORY.newInstance(source.getName(), target.getName(), useConverter);
98+
return (BeanCopier)super.create(key);
99+
}
100+
101+
public void generateClass(ClassVisitor v) {
102+
Type sourceType = Type.getType(source);
103+
Type targetType = Type.getType(target);
104+
ClassEmitter ce = new ClassEmitter(v);
105+
ce.begin_class(Constants.V1_8,
106+
Constants.ACC_PUBLIC,
107+
getClassName(),
108+
BEAN_COPIER,
109+
null,
110+
Constants.SOURCE_FILE);
111+
112+
EmitUtils.null_constructor(ce);
113+
CodeEmitter e = ce.begin_method(Constants.ACC_PUBLIC, COPY, null);
114+
PropertyDescriptor[] getters = ReflectUtils.getBeanGetters(source);
115+
PropertyDescriptor[] setters = ReflectUtils.getBeanSetters(target);
116+
117+
Map names = new HashMap();
118+
for (int i = 0; i < getters.length; i++) {
119+
names.put(getters[i].getName(), getters[i]);
120+
}
121+
Local targetLocal = e.make_local();
122+
Local sourceLocal = e.make_local();
123+
if (useConverter) {
124+
e.load_arg(1);
125+
e.checkcast(targetType);
126+
e.store_local(targetLocal);
127+
e.load_arg(0);
128+
e.checkcast(sourceType);
129+
e.store_local(sourceLocal);
130+
} else {
131+
e.load_arg(1);
132+
e.checkcast(targetType);
133+
e.load_arg(0);
134+
e.checkcast(sourceType);
135+
}
136+
for (int i = 0; i < setters.length; i++) {
137+
PropertyDescriptor setter = setters[i];
138+
PropertyDescriptor getter = (PropertyDescriptor)names.get(setter.getName());
139+
if (getter != null) {
140+
MethodInfo read = ReflectUtils.getMethodInfo(getter.getReadMethod());
141+
MethodInfo write = ReflectUtils.getMethodInfo(setter.getWriteMethod());
142+
if (useConverter) {
143+
Type setterType = write.getSignature().getArgumentTypes()[0];
144+
e.load_local(targetLocal);
145+
e.load_arg(2);
146+
e.load_local(sourceLocal);
147+
e.invoke(read);
148+
e.box(read.getSignature().getReturnType());
149+
EmitUtils.load_class(e, setterType);
150+
e.push(write.getSignature().getName());
151+
e.invoke_interface(CONVERTER, CONVERT);
152+
e.unbox_or_zero(setterType);
153+
e.invoke(write);
154+
} else if (compatible(getter, setter)) {
155+
e.dup2();
156+
e.invoke(read);
157+
e.invoke(write);
158+
}
159+
}
160+
}
161+
e.return_value();
162+
e.end_method();
163+
ce.end_class();
164+
}
165+
166+
private static boolean compatible(PropertyDescriptor getter, PropertyDescriptor setter) {
167+
// TODO: allow automatic widening conversions?
168+
return setter.getPropertyType().isAssignableFrom(getter.getPropertyType());
169+
}
170+
171+
protected Object firstInstance(Class type) {
172+
return ReflectUtils.newInstance(type);
173+
}
174+
175+
protected Object nextInstance(Object instance) {
176+
return instance;
177+
}
178+
}
179+
}

0 commit comments

Comments
 (0)