Browse Source

Merge branch '5.2.x'

pull/25428/head
Juergen Hoeller 4 years ago
parent
commit
88394bff66
  1. 7
      spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java
  2. 2
      spring-web/src/main/java/org/springframework/web/util/UriComponentsBuilder.java
  3. 16
      spring-web/src/test/java/org/springframework/web/util/UriComponentsBuilderTests.java

7
spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java

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

2
spring-web/src/main/java/org/springframework/web/util/UriComponentsBuilder.java

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

16
spring-web/src/test/java/org/springframework/web/util/UriComponentsBuilderTests.java

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

Loading…
Cancel
Save