Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

backport: Fix issue when trying to determine if a bean has been defined for transient fields. #139

Merged
merged 3 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ private TransientDescriptor detectBean(Object target, Field field) {

private boolean matchesPrototype(String beanName, Object beanDefinition,
Class<?> fieldValueType) {
return appCtx.isPrototype(beanName)
return appCtx.containsBeanDefinition(beanName)
&& appCtx.isPrototype(beanName)
&& beanDefinition.getClass() == fieldValueType;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ void processConstructorInjectedComponent(
.readWithTransients();
Assertions.assertThat(result).isNotSameAs(target)
.isExactlyInstanceOf(TestConfig.CtorInjectionTarget.class)
.hasNoNullFieldsOrProperties()
.asInstanceOf(InstanceOfAssertFactories
.type(TestConfig.CtorInjectionTarget.class))
.extracting(obj -> obj.defaultImpl, obj -> obj.alternative)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public void execute() {
static class CtorInjectionTarget implements Serializable {
transient TestService defaultImpl;
transient TestService alternative;
transient Object nonBeanTransient = new Object();

public CtorInjectionTarget(TestService defaultImpl,
@Qualifier("ALTERNATIVE") TestService alternative) {
Expand Down Expand Up @@ -91,6 +92,7 @@ static class PrototypeTarget implements Serializable {
@Autowired
@Qualifier("EXTENSION")
transient PrototypeComponent extPrototypeScoped;
transient Object nonBeanTransient = new Object();
}

interface PrototypeService {
Expand Down Expand Up @@ -119,6 +121,7 @@ static class PrototypeServiceTarget implements Serializable {
@Autowired
@Qualifier("B")
transient PrototypeService prototypeServiceB;
transient Object nonBeanTransient = new Object();
}

@Component
Expand Down