Skip to content

Commit 88394bf

Browse files
committed
Merge branch '5.2.x'
2 parents e4e54b3 + 65e6010 commit 88394bf

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -687,8 +687,8 @@ public <T> Map<String, T> getBeansOfType(
687687
public String[] getBeanNamesForAnnotation(Class<? extends Annotation> annotationType) {
688688
List<String> result = new ArrayList<>();
689689
for (String beanName : this.beanDefinitionNames) {
690-
BeanDefinition beanDefinition = this.beanDefinitionMap.get(beanName);
691-
if (!beanDefinition.isAbstract() && findAnnotationOnBean(beanName, annotationType) != null) {
690+
BeanDefinition bd = this.beanDefinitionMap.get(beanName);
691+
if (bd != null && !bd.isAbstract() && findAnnotationOnBean(beanName, annotationType) != null) {
692692
result.add(beanName);
693693
}
694694
}
@@ -1090,8 +1090,7 @@ protected void resetBeanDefinition(String beanName) {
10901090
for (String bdName : this.beanDefinitionNames) {
10911091
if (!beanName.equals(bdName)) {
10921092
BeanDefinition bd = this.beanDefinitionMap.get(bdName);
1093-
// Ensure bd is non-null due to potential concurrent modification
1094-
// of the beanDefinitionMap.
1093+
// Ensure bd is non-null due to potential concurrent modification of beanDefinitionMap.
10951094
if (bd != null && beanName.equals(bd.getParentName())) {
10961095
resetBeanDefinition(bdName);
10971096
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ protected UriComponentsBuilder(UriComponentsBuilder other) {
162162
this.port = other.port;
163163
this.pathBuilder = other.pathBuilder.cloneBuilder();
164164
this.uriVariables.putAll(other.uriVariables);
165-
this.queryParams.putAll(other.queryParams);
165+
this.queryParams.addAll(other.queryParams);
166166
this.fragment = other.fragment;
167167
this.encodeTemplate = other.encodeTemplate;
168168
this.charset = other.charset;

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -924,30 +924,32 @@ void parsesEmptyUri() {
924924
assertThat(components.toString()).isEqualTo("");
925925
}
926926

927-
@Test
927+
@Test // gh-25243
928928
void testCloneAndMerge() {
929929
UriComponentsBuilder builder1 = UriComponentsBuilder.newInstance();
930-
builder1.scheme("http").host("e1.com").path("/p1").pathSegment("ps1").queryParam("q1").fragment("f1").encode();
930+
builder1.scheme("http").host("e1.com").path("/p1").pathSegment("ps1").queryParam("q1", "x").fragment("f1").encode();
931931

932-
UriComponentsBuilder builder2 = (UriComponentsBuilder) builder1.clone();
932+
UriComponentsBuilder builder2 = builder1.cloneBuilder();
933933
builder2.scheme("https").host("e2.com").path("p2").pathSegment("{ps2}").queryParam("q2").fragment("f2");
934934

935+
builder1.queryParam("q1", "y"); // one more entry for an existing parameter
936+
935937
UriComponents result1 = builder1.build();
936938
assertThat(result1.getScheme()).isEqualTo("http");
937939
assertThat(result1.getHost()).isEqualTo("e1.com");
938940
assertThat(result1.getPath()).isEqualTo("/p1/ps1");
939-
assertThat(result1.getQuery()).isEqualTo("q1");
941+
assertThat(result1.getQuery()).isEqualTo("q1=x&q1=y");
940942
assertThat(result1.getFragment()).isEqualTo("f1");
941943

942944
UriComponents result2 = builder2.buildAndExpand("ps2;a");
943945
assertThat(result2.getScheme()).isEqualTo("https");
944946
assertThat(result2.getHost()).isEqualTo("e2.com");
945947
assertThat(result2.getPath()).isEqualTo("/p1/ps1/p2/ps2%3Ba");
946-
assertThat(result2.getQuery()).isEqualTo("q1&q2");
948+
assertThat(result2.getQuery()).isEqualTo("q1=x&q2");
947949
assertThat(result2.getFragment()).isEqualTo("f2");
948950
}
949951

950-
@Test // gh-24772
952+
@Test // gh-24772
951953
void testDeepClone() {
952954
HashMap<String, Object> vars = new HashMap<>();
953955
vars.put("ps1", "foo");
@@ -957,7 +959,7 @@ void testDeepClone() {
957959
builder1.scheme("http").host("e1.com").userInfo("user:pwd").path("/p1").pathSegment("{ps1}")
958960
.pathSegment("{ps2}").queryParam("q1").fragment("f1").uriVariables(vars).encode();
959961

960-
UriComponentsBuilder builder2 = (UriComponentsBuilder) builder1.clone();
962+
UriComponentsBuilder builder2 = builder1.cloneBuilder();
961963

962964
UriComponents result1 = builder1.build();
963965
assertThat(result1.getScheme()).isEqualTo("http");

0 commit comments

Comments
 (0)