Skip to content

Commit

Permalink
SpringBeanProcessor: cope with non-public @bean methods
Browse files Browse the repository at this point in the history
A @Bean-annotated method on a Spring @configuration class does not
have to be public. Previously, when SpringBeanProcessor encountered
a non-public @bean method it would fail to determine the bean's type
and throw an IllegalStateException.

This commit updates SpringBeanProcessor to use
Class.getDeclaredMethods() when looking for the @bean method on a
@configuration class, thereby allowing it to find non-public methods.
  • Loading branch information
wilkinsona committed Sep 17, 2014
1 parent e1baae9 commit a29ea88
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ private static Class<?> getBeanClass(String name, BeanDefinition beanDef,
}
}

for (Method method : getBeanClass(factoryClassName).getMethods())
for (Method method : getBeanClass(factoryClassName).getDeclaredMethods())
{
if (method.getName().equals(factoryMethodName))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public ResteasyRegistration prototypeRegistration()
}

@Bean
public Counter singletonCounter()
Counter singletonCounter()
{
return new Counter();
}
Expand Down

1 comment on commit a29ea88

@mihxil
Copy link
Contributor

@mihxil mihxil commented on a29ea88 Dec 1, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commits breaks finding of methods which are declared in super classes.

I submitted a pull request to fix that again.

Please sign in to comment.