Merge branch '5.2.x'

This commit is contained in:
Juergen Hoeller 2020-07-20 07:21:36 +02:00
commit 88394bff66
3 changed files with 13 additions and 12 deletions

View File

@ -687,8 +687,8 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
public String[] getBeanNamesForAnnotation(Class<? extends Annotation> annotationType) { public String[] getBeanNamesForAnnotation(Class<? extends Annotation> annotationType) {
List<String> result = new ArrayList<>(); List<String> result = new ArrayList<>();
for (String beanName : this.beanDefinitionNames) { for (String beanName : this.beanDefinitionNames) {
BeanDefinition beanDefinition = this.beanDefinitionMap.get(beanName); BeanDefinition bd = this.beanDefinitionMap.get(beanName);
if (!beanDefinition.isAbstract() && findAnnotationOnBean(beanName, annotationType) != null) { if (bd != null && !bd.isAbstract() && findAnnotationOnBean(beanName, annotationType) != null) {
result.add(beanName); result.add(beanName);
} }
} }
@ -1090,8 +1090,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
for (String bdName : this.beanDefinitionNames) { for (String bdName : this.beanDefinitionNames) {
if (!beanName.equals(bdName)) { if (!beanName.equals(bdName)) {
BeanDefinition bd = this.beanDefinitionMap.get(bdName); BeanDefinition bd = this.beanDefinitionMap.get(bdName);
// Ensure bd is non-null due to potential concurrent modification // Ensure bd is non-null due to potential concurrent modification of beanDefinitionMap.
// of the beanDefinitionMap.
if (bd != null && beanName.equals(bd.getParentName())) { if (bd != null && beanName.equals(bd.getParentName())) {
resetBeanDefinition(bdName); resetBeanDefinition(bdName);
} }

View File

@ -162,7 +162,7 @@ public class UriComponentsBuilder implements UriBuilder, Cloneable {
this.port = other.port; this.port = other.port;
this.pathBuilder = other.pathBuilder.cloneBuilder(); this.pathBuilder = other.pathBuilder.cloneBuilder();
this.uriVariables.putAll(other.uriVariables); this.uriVariables.putAll(other.uriVariables);
this.queryParams.putAll(other.queryParams); this.queryParams.addAll(other.queryParams);
this.fragment = other.fragment; this.fragment = other.fragment;
this.encodeTemplate = other.encodeTemplate; this.encodeTemplate = other.encodeTemplate;
this.charset = other.charset; this.charset = other.charset;

View File

@ -924,30 +924,32 @@ class UriComponentsBuilderTests {
assertThat(components.toString()).isEqualTo(""); assertThat(components.toString()).isEqualTo("");
} }
@Test @Test // gh-25243
void testCloneAndMerge() { void testCloneAndMerge() {
UriComponentsBuilder builder1 = UriComponentsBuilder.newInstance(); UriComponentsBuilder builder1 = UriComponentsBuilder.newInstance();
builder1.scheme("http").host("e1.com").path("/p1").pathSegment("ps1").queryParam("q1").fragment("f1").encode(); builder1.scheme("http").host("e1.com").path("/p1").pathSegment("ps1").queryParam("q1", "x").fragment("f1").encode();
UriComponentsBuilder builder2 = (UriComponentsBuilder) builder1.clone(); UriComponentsBuilder builder2 = builder1.cloneBuilder();
builder2.scheme("https").host("e2.com").path("p2").pathSegment("{ps2}").queryParam("q2").fragment("f2"); builder2.scheme("https").host("e2.com").path("p2").pathSegment("{ps2}").queryParam("q2").fragment("f2");
builder1.queryParam("q1", "y"); // one more entry for an existing parameter
UriComponents result1 = builder1.build(); UriComponents result1 = builder1.build();
assertThat(result1.getScheme()).isEqualTo("http"); assertThat(result1.getScheme()).isEqualTo("http");
assertThat(result1.getHost()).isEqualTo("e1.com"); assertThat(result1.getHost()).isEqualTo("e1.com");
assertThat(result1.getPath()).isEqualTo("/p1/ps1"); assertThat(result1.getPath()).isEqualTo("/p1/ps1");
assertThat(result1.getQuery()).isEqualTo("q1"); assertThat(result1.getQuery()).isEqualTo("q1=x&q1=y");
assertThat(result1.getFragment()).isEqualTo("f1"); assertThat(result1.getFragment()).isEqualTo("f1");
UriComponents result2 = builder2.buildAndExpand("ps2;a"); UriComponents result2 = builder2.buildAndExpand("ps2;a");
assertThat(result2.getScheme()).isEqualTo("https"); assertThat(result2.getScheme()).isEqualTo("https");
assertThat(result2.getHost()).isEqualTo("e2.com"); assertThat(result2.getHost()).isEqualTo("e2.com");
assertThat(result2.getPath()).isEqualTo("/p1/ps1/p2/ps2%3Ba"); assertThat(result2.getPath()).isEqualTo("/p1/ps1/p2/ps2%3Ba");
assertThat(result2.getQuery()).isEqualTo("q1&q2"); assertThat(result2.getQuery()).isEqualTo("q1=x&q2");
assertThat(result2.getFragment()).isEqualTo("f2"); assertThat(result2.getFragment()).isEqualTo("f2");
} }
@Test // gh-24772 @Test // gh-24772
void testDeepClone() { void testDeepClone() {
HashMap<String, Object> vars = new HashMap<>(); HashMap<String, Object> vars = new HashMap<>();
vars.put("ps1", "foo"); vars.put("ps1", "foo");
@ -957,7 +959,7 @@ class UriComponentsBuilderTests {
builder1.scheme("http").host("e1.com").userInfo("user:pwd").path("/p1").pathSegment("{ps1}") builder1.scheme("http").host("e1.com").userInfo("user:pwd").path("/p1").pathSegment("{ps1}")
.pathSegment("{ps2}").queryParam("q1").fragment("f1").uriVariables(vars).encode(); .pathSegment("{ps2}").queryParam("q1").fragment("f1").uriVariables(vars).encode();
UriComponentsBuilder builder2 = (UriComponentsBuilder) builder1.clone(); UriComponentsBuilder builder2 = builder1.cloneBuilder();
UriComponents result1 = builder1.build(); UriComponents result1 = builder1.build();
assertThat(result1.getScheme()).isEqualTo("http"); assertThat(result1.getScheme()).isEqualTo("http");