Polishing

This commit is contained in:
Juergen Hoeller 2024-01-24 22:30:33 +01:00
parent c5a75219ce
commit c6121da151
3 changed files with 17 additions and 20 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2023 the original author or authors. * Copyright 2002-2024 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -32,8 +32,13 @@ import org.springframework.lang.Nullable;
*/ */
abstract class CoroutinesUtils { abstract class CoroutinesUtils {
static Object asFlow(Object publisher) { static Object asFlow(@Nullable Object publisher) {
return ReactiveFlowKt.asFlow((Publisher<?>) publisher); if (publisher instanceof Publisher<?> rsPublisher) {
return ReactiveFlowKt.asFlow(rsPublisher);
}
else {
throw new IllegalArgumentException("Not a Reactive Streams Publisher: " + publisher);
}
} }
@Nullable @Nullable

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2023 the original author or authors. * Copyright 2002-2024 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -55,8 +55,7 @@ class ScopedProxyTests {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(MAP_CONTEXT); new XmlBeanDefinitionReader(bf).loadBeanDefinitions(MAP_CONTEXT);
Object baseMap = bf.getBean("singletonMap"); Object baseMap = bf.getBean("singletonMap");
boolean condition = baseMap instanceof Map; assertThat(baseMap instanceof Map).isTrue();
assertThat(condition).isTrue();
} }
@Test @Test
@ -64,10 +63,8 @@ class ScopedProxyTests {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(MAP_CONTEXT); new XmlBeanDefinitionReader(bf).loadBeanDefinitions(MAP_CONTEXT);
Object simpleMap = bf.getBean("simpleMap"); Object simpleMap = bf.getBean("simpleMap");
boolean condition1 = simpleMap instanceof Map; assertThat(simpleMap instanceof Map).isTrue();
assertThat(condition1).isTrue(); assertThat(simpleMap instanceof HashMap).isTrue();
boolean condition = simpleMap instanceof HashMap;
assertThat(condition).isTrue();
} }
@Test @Test
@ -97,8 +94,7 @@ class ScopedProxyTests {
ITestBean bean = (ITestBean) bf.getBean("testBean"); ITestBean bean = (ITestBean) bf.getBean("testBean");
assertThat(bean).isNotNull(); assertThat(bean).isNotNull();
assertThat(AopUtils.isJdkDynamicProxy(bean)).isTrue(); assertThat(AopUtils.isJdkDynamicProxy(bean)).isTrue();
boolean condition1 = bean instanceof ScopedObject; assertThat(bean instanceof ScopedObject).isTrue();
assertThat(condition1).isTrue();
ScopedObject scoped = (ScopedObject) bean; ScopedObject scoped = (ScopedObject) bean;
assertThat(scoped.getTargetObject().getClass()).isEqualTo(TestBean.class); assertThat(scoped.getTargetObject().getClass()).isEqualTo(TestBean.class);
bean.setAge(101); bean.setAge(101);
@ -110,8 +106,7 @@ class ScopedProxyTests {
assertThat(deserialized).isNotNull(); assertThat(deserialized).isNotNull();
assertThat(AopUtils.isJdkDynamicProxy(deserialized)).isTrue(); assertThat(AopUtils.isJdkDynamicProxy(deserialized)).isTrue();
assertThat(bean.getAge()).isEqualTo(101); assertThat(bean.getAge()).isEqualTo(101);
boolean condition = deserialized instanceof ScopedObject; assertThat(deserialized instanceof ScopedObject).isTrue();
assertThat(condition).isTrue();
ScopedObject scopedDeserialized = (ScopedObject) deserialized; ScopedObject scopedDeserialized = (ScopedObject) deserialized;
assertThat(scopedDeserialized.getTargetObject().getClass()).isEqualTo(TestBean.class); assertThat(scopedDeserialized.getTargetObject().getClass()).isEqualTo(TestBean.class);
@ -128,8 +123,7 @@ class ScopedProxyTests {
TestBean tb = (TestBean) bf.getBean("testBean"); TestBean tb = (TestBean) bf.getBean("testBean");
assertThat(AopUtils.isCglibProxy(tb.getFriends())).isTrue(); assertThat(AopUtils.isCglibProxy(tb.getFriends())).isTrue();
boolean condition1 = tb.getFriends() instanceof ScopedObject; assertThat(tb.getFriends() instanceof ScopedObject).isTrue();
assertThat(condition1).isTrue();
ScopedObject scoped = (ScopedObject) tb.getFriends(); ScopedObject scoped = (ScopedObject) tb.getFriends();
assertThat(scoped.getTargetObject().getClass()).isEqualTo(ArrayList.class); assertThat(scoped.getTargetObject().getClass()).isEqualTo(ArrayList.class);
tb.getFriends().add("myFriend"); tb.getFriends().add("myFriend");
@ -141,8 +135,7 @@ class ScopedProxyTests {
assertThat(deserialized).isNotNull(); assertThat(deserialized).isNotNull();
assertThat(AopUtils.isCglibProxy(deserialized)).isTrue(); assertThat(AopUtils.isCglibProxy(deserialized)).isTrue();
assertThat(deserialized).contains("myFriend"); assertThat(deserialized).contains("myFriend");
boolean condition = deserialized instanceof ScopedObject; assertThat(deserialized instanceof ScopedObject).isTrue();
assertThat(condition).isTrue();
ScopedObject scopedDeserialized = (ScopedObject) deserialized; ScopedObject scopedDeserialized = (ScopedObject) deserialized;
assertThat(scopedDeserialized.getTargetObject().getClass()).isEqualTo(ArrayList.class); assertThat(scopedDeserialized.getTargetObject().getClass()).isEqualTo(ArrayList.class);

View File

@ -375,9 +375,8 @@ class SimpleAliasRegistryTests {
@Override @Override
public String resolveStringValue(String str) { public String resolveStringValue(String str) {
return (this.placeholders.getOrDefault(str, str)); return this.placeholders.getOrDefault(str, str);
} }
} }
} }