-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AER-2539 error handling in service (#45)
* Add retry functionality in BingSearchService There's a max requests per second Bing supports with non-enterprise keys (and probably also with enterprise keys, but it should be higher in that case). If we hit that, wait a second before trying again. 1 second is pretty long, but as we're using the async process anyway, I think it's OK to do this(?) * Better error handling in AsyncSearchTaskDelegator As it was, a NullpointerException in a search service would cause the delegator to also throw an exception, and a task would never be set to completed. This would cause the client to wait forever (well, wait, it would keep on sending a where-are-my-results-request every 250ms) and the user would never get an indication that something failed. The `doOnError` method does not keep the error from flowing down, it just does its action and then the subscriber will still have to handle the original exception. And as we didn't define an error handler there, another exception would pop up. Instead of silently ignoring the error and just returning results from all other services, which would also be an option, I went with returning a pretty generic 'Failure during search' result that a user will receive. This hopefully should trigger the user to warn us about it, so we can investigate what is going wrong. For good measure did the same for the synchronous version.
- Loading branch information
1 parent
5f961d9
commit 3dcef09
Showing
10 changed files
with
151 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
search-service-bing-geocoder/src/main/java/nl/aerius/search/tasks/BingServiceException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright the State of the Netherlands | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
*/ | ||
package nl.aerius.search.tasks; | ||
|
||
public class BingServiceException extends RuntimeException { | ||
|
||
public BingServiceException(final String message) { | ||
super(message); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
search-service-mocks/src/main/java/nl/aerius/search/tasks/MockRuntimeExceptionTask.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright the State of the Netherlands | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
*/ | ||
package nl.aerius.search.tasks; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.stereotype.Component; | ||
|
||
import io.reactivex.rxjava3.core.Single; | ||
|
||
import nl.aerius.search.domain.SearchCapability; | ||
import nl.aerius.search.domain.SearchTaskResult; | ||
|
||
@Component | ||
@ImplementsCapability(SearchCapability.MOCK_RUNTIME_EXCEPTION) | ||
public class MockRuntimeExceptionTask implements SearchTaskService { | ||
private static final Logger LOG = LoggerFactory.getLogger(MockRuntimeExceptionTask.class); | ||
|
||
@Override | ||
public Single<SearchTaskResult> retrieveSearchResults(final String query) { | ||
LOG.debug("Mocking runtim exception for query [{}]", query); | ||
throw new NullPointerException("Some mocked nullpointer"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters