Skip to content

Commit c6121da

Browse files
committed
Polishing
1 parent c5a7521 commit c6121da

File tree

3 files changed

+17
-20
lines changed

3 files changed

+17
-20
lines changed

spring-aop/src/main/java/org/springframework/aop/framework/CoroutinesUtils.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2023 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -32,8 +32,13 @@
3232
*/
3333
abstract class CoroutinesUtils {
3434

35-
static Object asFlow(Object publisher) {
36-
return ReactiveFlowKt.asFlow((Publisher<?>) publisher);
35+
static Object asFlow(@Nullable Object publisher) {
36+
if (publisher instanceof Publisher<?> rsPublisher) {
37+
return ReactiveFlowKt.asFlow(rsPublisher);
38+
}
39+
else {
40+
throw new IllegalArgumentException("Not a Reactive Streams Publisher: " + publisher);
41+
}
3742
}
3843

3944
@Nullable

spring-context/src/test/java/org/springframework/aop/scope/ScopedProxyTests.java

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2023 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -55,19 +55,16 @@ void testProxyAssignable() {
5555
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
5656
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(MAP_CONTEXT);
5757
Object baseMap = bf.getBean("singletonMap");
58-
boolean condition = baseMap instanceof Map;
59-
assertThat(condition).isTrue();
58+
assertThat(baseMap instanceof Map).isTrue();
6059
}
6160

6261
@Test
6362
void testSimpleProxy() {
6463
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
6564
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(MAP_CONTEXT);
6665
Object simpleMap = bf.getBean("simpleMap");
67-
boolean condition1 = simpleMap instanceof Map;
68-
assertThat(condition1).isTrue();
69-
boolean condition = simpleMap instanceof HashMap;
70-
assertThat(condition).isTrue();
66+
assertThat(simpleMap instanceof Map).isTrue();
67+
assertThat(simpleMap instanceof HashMap).isTrue();
7168
}
7269

7370
@Test
@@ -97,8 +94,7 @@ void testJdkScopedProxy() throws Exception {
9794
ITestBean bean = (ITestBean) bf.getBean("testBean");
9895
assertThat(bean).isNotNull();
9996
assertThat(AopUtils.isJdkDynamicProxy(bean)).isTrue();
100-
boolean condition1 = bean instanceof ScopedObject;
101-
assertThat(condition1).isTrue();
97+
assertThat(bean instanceof ScopedObject).isTrue();
10298
ScopedObject scoped = (ScopedObject) bean;
10399
assertThat(scoped.getTargetObject().getClass()).isEqualTo(TestBean.class);
104100
bean.setAge(101);
@@ -110,8 +106,7 @@ void testJdkScopedProxy() throws Exception {
110106
assertThat(deserialized).isNotNull();
111107
assertThat(AopUtils.isJdkDynamicProxy(deserialized)).isTrue();
112108
assertThat(bean.getAge()).isEqualTo(101);
113-
boolean condition = deserialized instanceof ScopedObject;
114-
assertThat(condition).isTrue();
109+
assertThat(deserialized instanceof ScopedObject).isTrue();
115110
ScopedObject scopedDeserialized = (ScopedObject) deserialized;
116111
assertThat(scopedDeserialized.getTargetObject().getClass()).isEqualTo(TestBean.class);
117112

@@ -128,8 +123,7 @@ void testCglibScopedProxy() throws Exception {
128123

129124
TestBean tb = (TestBean) bf.getBean("testBean");
130125
assertThat(AopUtils.isCglibProxy(tb.getFriends())).isTrue();
131-
boolean condition1 = tb.getFriends() instanceof ScopedObject;
132-
assertThat(condition1).isTrue();
126+
assertThat(tb.getFriends() instanceof ScopedObject).isTrue();
133127
ScopedObject scoped = (ScopedObject) tb.getFriends();
134128
assertThat(scoped.getTargetObject().getClass()).isEqualTo(ArrayList.class);
135129
tb.getFriends().add("myFriend");
@@ -141,8 +135,7 @@ void testCglibScopedProxy() throws Exception {
141135
assertThat(deserialized).isNotNull();
142136
assertThat(AopUtils.isCglibProxy(deserialized)).isTrue();
143137
assertThat(deserialized).contains("myFriend");
144-
boolean condition = deserialized instanceof ScopedObject;
145-
assertThat(condition).isTrue();
138+
assertThat(deserialized instanceof ScopedObject).isTrue();
146139
ScopedObject scopedDeserialized = (ScopedObject) deserialized;
147140
assertThat(scopedDeserialized.getTargetObject().getClass()).isEqualTo(ArrayList.class);
148141

spring-core/src/test/java/org/springframework/core/SimpleAliasRegistryTests.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,9 +375,8 @@ private static class StubStringValueResolver implements StringValueResolver {
375375

376376
@Override
377377
public String resolveStringValue(String str) {
378-
return (this.placeholders.getOrDefault(str, str));
378+
return this.placeholders.getOrDefault(str, str);
379379
}
380-
381380
}
382381

383382
}

0 commit comments

Comments
 (0)