Skip to content

Commit

Permalink
Merge pull request #19829 from geoand/#19750-rr
Browse files Browse the repository at this point in the history
Provide actionable error message when Provider in RESTEasy Reactive isn't a bean
  • Loading branch information
geoand authored Sep 1, 2021
2 parents a5f0124 + 12ca7eb commit 465a4d1
Showing 1 changed file with 22 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,28 @@ public String toString() {

@Override
public BeanInstance<T> createInstance() {
BeanContainer.Instance<T> instance = factory.create();
return new BeanInstance<T>() {
@Override
public T getInstance() {
return instance.get();
BeanContainer.Instance<T> instance;
try {
instance = factory.create();
return new BeanInstance<T>() {
@Override
public T getInstance() {
return instance.get();
}

@Override
public void close() {
instance.close();
}
};
} catch (Exception e) {
if (factory.getClass().getName().contains("DefaultInstanceFactory")) {
throw new IllegalArgumentException(
"Unable to create class '" + targetClassName
+ "'. To fix the problem, make sure this class is a CDI bean.",
e);
}

@Override
public void close() {
instance.close();
}
};
throw e;
}
}
}

0 comments on commit 465a4d1

Please sign in to comment.