-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Fail build with HAL resource without serializer #11246 #11248
Fail build with HAL resource without serializer #11246 #11248
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added some comments inline. Feel free to ping me if something is unclear.
return false; | ||
} | ||
|
||
private boolean hasJsonProcessor() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should rely on the Capabilities
here. The ones existing don't really cover your use case (I checked, even if their names sound appealing, they are not covering your needs) so you will need to add RESTEASY_JACKSON
and RESTEASY_JSONB
and produce them from the respective processors together with the others.
private void verifyHalResources(IndexView index, List<RestDataResourceBuildItem> resourceBuildItems) { | ||
if (!hasJsonProcessor() && hasHalResource(index, resourceBuildItems)) { | ||
logger.warn("Cannot generate HAL endpoints without a serializer. " | ||
+ "Make sure you have either Jsonb or Jackson RESTEasy extension enabled."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+ "Make sure you have either Jsonb or Jackson RESTEasy extension enabled."); | |
+ "Make sure you have either RESTEasy JSON-B or Jackson extension enabled."); |
if (!hasJsonProcessor() && hasHalResource(index, resourceBuildItems)) { | ||
logger.warn("Cannot generate HAL endpoints without a serializer. " | ||
+ "Make sure you have either Jsonb or Jackson RESTEasy extension enabled."); | ||
throw new RestDataBuildException("Cannot generate HAL endpoints without a serializer"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Either you log a warning or you throw an exception. In this case, I would just throw an exception with the proper message.
Also I don't think you need a specific exception for this. An IllegalStateException
would be perfectly adequate IMHO.
7a90402
to
8e132c2
Compare
Thanks for the tip on capabilities, @gsmet. It makes a much more sense and keeps the code much cleaner. I changed the commit to use |
Nope. That's why I was extremely clear in my comment. The |
OK I'll add the new capabilities then. |
@gsmet I've just noticed that there are two other capabilities: |
@gytis as I mentioned it twice now, I did the digging and you need new capabilities. |
8e132c2
to
19ba0d4
Compare
Sorry for asking multiple times. I just wanted to avoid adding unnecessary code. |
Is there something else missing in this PR? |
19ba0d4
to
fc66a0d
Compare
fc66a0d
to
b71a894
Compare
b71a894
to
76ce627
Compare
76ce627
to
6669cd4
Compare
6669cd4
to
bda2e56
Compare
#11246