Skip to content

Commit

Permalink
backport: Fix issue when trying to determine if a bean has been defin…
Browse files Browse the repository at this point in the history
…ed for transient fields. (#139)

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

* Update TestConfig.java

* Update SerializationDeserializationTest.java
  • Loading branch information
TatuLund authored Sep 24, 2024
1 parent 618bc01 commit 4805978
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
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

0 comments on commit 4805978

Please sign in to comment.