9817 adding HTTP Status Exception check to Grobid Citation Fetcher#9929
Conversation
|
Yes please change all to Fetcher Exceptions. If all is correct they will be caught by the caller and displayed in a friendly way to the user |
Hi, I have tried to change these to Fetcher Exceptions, but I think I understand why these were originally left as runtime exceptions. The function parseUsingGrobid is passed into a Arrays.stream.map(this::parseUsingGrobid). When I change the runtime exceptions to Fetcher Exceptions I am getting an error on the line .map(this::parseUsingGrobid) saying that FetcherException is unhandled. I believe this is because we are giving .map() a reference to the function that it will call internally, since map can't catch / handle a FetcherException this is what is causing the problem. I found a post on stack overflow discussing a similar problem. I believe using runtime exceptions is a workaround for this problem as it leaves the exception unchecked. https://stackoverflow.com/questions/19757300/java-8-lambda-streams-filter-by-method-with-exception The Array.stream.map(this::parseUsingGrobid) is surrounded by a try catch that catches runtime exceptions and re-throws them as FetcherExceptions |
I see. Would you mind trying out faux-pas so that code at the fetcher is still clean? I think, it's
I have been there years ago and upvoted some of the answers ^^. Though, no faux-pas there... Let's see. |
|
I think for the moment we can keep the runtime exception. |
…xceptions in .map() via a ThrowingFunction
…ion() instead of intermediate variable ThrowingFunction
|
@koppor I have got faux-pas working and now this::parseUsingGrobid is wrapped inside a throwingFunction() which seems to fix the issue. |
|
Can you please resolve the merge conflict so we can see if the jlink works
mtheiley ***@***.***> schrieb am Mi., 24. Mai 2023, 15:43:
… @koppor <https://github.com/koppor> I have got faux-pas working and now
this::parseUsingGrobid is wrapped inside a throwingFunction() which seems
to fix the issue.
—
Reply to this email directly, view it on GitHub
<#9929 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACOFZGJT6Y5O2XEQPPVGLLXHYGBZANCNFSM6AAAAAAYIPD3HA>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
|
Jlink seems to work so from my point of view it's good! |
| .map(FauxPas.throwingFunction(this::parseUsingGrobid)) | ||
| .flatMap(Optional::stream) | ||
| .collect(Collectors.toList()); | ||
| } catch (RuntimeException e) { |
There was a problem hiding this comment.
Is this still necessary? I think, this block can be removed!
There was a problem hiding this comment.
@koppor I have removed the try/catch block checking for runtime exceptions since we are just using FetcherExceptions now
… we are only throwing FetcherExceptions within parseUsingGrobid now
Fixes #9817
Hi all, I am part of the university group that was assigned this issue.
I tried to re-create this issue with failing to connect to http://grobid.jabref.org:8070/, however currently it is up and running fine. So instead I tried to re-create the issue by connecting to https://httpstat.us/503 which always gives a 503 error code when attempting to connect.
It looks like JSoup throws an HttpStatusException when the status code is not 200 OK https://jsoup.org/apidocs/org/jsoup/HttpStatusException.html
I have tried adding an additional catch statement in the try catch within GrobitCitationFetcher.java and this seems to be working. When we don't get 200 OK it will display the error after 0 entries are passed. This should hopefully catch all status related errors now including the 503 status. I have attached a copy of the error code being displayed in the GUI.
I originally posted this solution on the issue 9817 I have made some changes based on recommendations made there. I was recommended to change the RuntimeExceptions to FetcherExceptions for my changes, however I was just basing my changes on the existing SocketTimeoutException below. Should both of these be changed to FetcherExceptions?
Other members of my team are currently looking into wire mock tool as suggested.
Please let us know what you think we are eager to hear your feedback.