diff options
Diffstat (limited to 'vid-ext-services-simulator/src')
4 files changed, 13 insertions, 2 deletions
diff --git a/vid-ext-services-simulator/src/main/java/org/onap/simulator/controller/SimulatorController.java b/vid-ext-services-simulator/src/main/java/org/onap/simulator/controller/SimulatorController.java index b6cc6759f..296d9fcbf 100644 --- a/vid-ext-services-simulator/src/main/java/org/onap/simulator/controller/SimulatorController.java +++ b/vid-ext-services-simulator/src/main/java/org/onap/simulator/controller/SimulatorController.java @@ -29,6 +29,7 @@ import java.util.List; import java.util.Map; import java.util.Properties; import java.util.Scanner; +import java.util.function.Supplier; import java.util.stream.Collectors; import java.util.stream.Stream; import javax.annotation.PostConstruct; @@ -253,7 +254,7 @@ public class SimulatorController { String userName = reqUri.substring(reqUri.lastIndexOf('/') + 1); TypedQuery<User> userQuery = entityManager.createQuery("select u from fn_user u where u.loginId = :userName", User.class); userQuery.setParameter("userName", userName); - User user = userQuery.getSingleResult(); + User user = doWithSingleRetry(userQuery::getSingleResult); Gson g = new Gson(); String jsonString = g.toJson(user); @@ -269,7 +270,7 @@ public class SimulatorController { return new ResponseEntity<>("Centralized Role Access is disabled", HttpStatus.SERVICE_UNAVAILABLE); } TypedQuery<Function> userQuery = entityManager.createQuery("select f from fn_function f", Function.class); - List<Function> functions = userQuery.getResultList(); + List<Function> functions = doWithSingleRetry(userQuery::getResultList); Gson g = new Gson(); String jsonString = g.toJson(functions); @@ -341,6 +342,16 @@ public class SimulatorController { return responseEntity; } + private <T> T doWithSingleRetry(Supplier<T> supplier) { + try { + return supplier.get(); + } catch (Exception e) { + logger.error("exception was thrown; will retry the same action one more time", e); + // here exceptions will be thrown + return supplier.get(); + } + } + private void register(SimulatorRequestResponseExpectation expectationModel) throws VidSimulatorException{ //Setting request according to what is passed HttpRequest request = HttpRequest.request(); diff --git a/vid-ext-services-simulator/src/main/resources/download_files/csar15782222_instantiationTypeMacroWithCR.zip b/vid-ext-services-simulator/src/main/resources/download_files/csar15782222_instantiationTypeMacroWithCR.zip Binary files differdeleted file mode 100644 index a189f206b..000000000 --- a/vid-ext-services-simulator/src/main/resources/download_files/csar15782222_instantiationTypeMacroWithCR.zip +++ /dev/null diff --git a/vid-ext-services-simulator/src/main/resources/download_files/csar15782222_instantiationTypeMacro_invariantUUIDAlacarte_withoutNetworks.zip b/vid-ext-services-simulator/src/main/resources/download_files/csar15782222_instantiationTypeMacro_invariantUUIDAlacarte_withoutNetworks.zip Binary files differindex 1f073b472..b3ba46098 100644 --- a/vid-ext-services-simulator/src/main/resources/download_files/csar15782222_instantiationTypeMacro_invariantUUIDAlacarte_withoutNetworks.zip +++ b/vid-ext-services-simulator/src/main/resources/download_files/csar15782222_instantiationTypeMacro_invariantUUIDAlacarte_withoutNetworks.zip diff --git a/vid-ext-services-simulator/src/main/resources/download_files/serviceCreationTest04743c62-ab58-41a0-bc53-1052ef1c094a.zip b/vid-ext-services-simulator/src/main/resources/download_files/serviceCreationTest04743c62-ab58-41a0-bc53-1052ef1c094a.zip Binary files differnew file mode 100644 index 000000000..c93a1cd88 --- /dev/null +++ b/vid-ext-services-simulator/src/main/resources/download_files/serviceCreationTest04743c62-ab58-41a0-bc53-1052ef1c094a.zip |