From 5a7091680cca97886bb490b938a59dd22ccaae14 Mon Sep 17 00:00:00 2001 From: Stoyan Tzenkov Date: Wed, 23 Jan 2019 12:57:05 +0200 Subject: [PATCH 1/3] NY-6436: Error log fixed. Signed-off-by: Stoyan Tzenkov --- .../repositories/AccountRepositoryAdditionalImpl.java | 6 +++++- .../java/biz/nynja/account/services/AccountServiceImpl.java | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/biz/nynja/account/repositories/AccountRepositoryAdditionalImpl.java b/src/main/java/biz/nynja/account/repositories/AccountRepositoryAdditionalImpl.java index 1737eff..4077e46 100644 --- a/src/main/java/biz/nynja/account/repositories/AccountRepositoryAdditionalImpl.java +++ b/src/main/java/biz/nynja/account/repositories/AccountRepositoryAdditionalImpl.java @@ -945,9 +945,13 @@ public class AccountRepositoryAdditionalImpl implements AccountRepositoryAdditio ProfileByAuthenticationProvider profileByAuthProvider = profileByAuthenticationProviderRepository .findByAuthenticationProviderAndAuthenticationProviderType(loginOption.getValue(), loginOption.getType()); - if (profileByAuthProvider == null || !profileByAuthProvider.getSearchable().booleanValue()) { + if (profileByAuthProvider == null) { return Optional.empty(); } + if (!profileByAuthProvider.getSearchable().booleanValue()) { + throw new IncorrectAccountCountException("Authentication provider is not searchable for the profileId: " + + profileByAuthProvider.getProfileId()); + } List listAccountsByProfileId = accountByProfileIdRepository .findAllByProfileId(profileByAuthProvider.getProfileId()); diff --git a/src/main/java/biz/nynja/account/services/AccountServiceImpl.java b/src/main/java/biz/nynja/account/services/AccountServiceImpl.java index d33e624..cd5b80e 100644 --- a/src/main/java/biz/nynja/account/services/AccountServiceImpl.java +++ b/src/main/java/biz/nynja/account/services/AccountServiceImpl.java @@ -184,7 +184,8 @@ public class AccountServiceImpl extends AccountServiceGrpc.AccountServiceImplBas account = accountProvider.searchAccountByLoginOption(AuthenticationType.EMAIL, request.getEmail()); } catch (IncorrectAccountCountException e) { logAndBuildGrpcSearchResponse(responseObserver, SearchResponse.newBuilder(), - "Error while searching for e-mail: ", request.getEmail(), Cause.INTERNAL_SERVER_ERROR, ""); + "Error while searching for e-mail. {}.", e.getMessage(), Cause.INTERNAL_SERVER_ERROR, ""); + return; } if (!account.isPresent()) { -- GitLab From 91ed21ac3923f7de2882fa7888849525bffab93e Mon Sep 17 00:00:00 2001 From: Stoyan Tzenkov Date: Wed, 23 Jan 2019 16:36:05 +0200 Subject: [PATCH 2/3] NY-6436: InternalError used instead of IncorrectAccountCountException. Signed-off-by: Stoyan Tzenkov --- .../account/repositories/AccountRepositoryAdditionalImpl.java | 4 ++-- .../java/biz/nynja/account/services/AccountServiceImpl.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/biz/nynja/account/repositories/AccountRepositoryAdditionalImpl.java b/src/main/java/biz/nynja/account/repositories/AccountRepositoryAdditionalImpl.java index 4077e46..7f51e10 100644 --- a/src/main/java/biz/nynja/account/repositories/AccountRepositoryAdditionalImpl.java +++ b/src/main/java/biz/nynja/account/repositories/AccountRepositoryAdditionalImpl.java @@ -949,8 +949,8 @@ public class AccountRepositoryAdditionalImpl implements AccountRepositoryAdditio return Optional.empty(); } if (!profileByAuthProvider.getSearchable().booleanValue()) { - throw new IncorrectAccountCountException("Authentication provider is not searchable for the profileId: " - + profileByAuthProvider.getProfileId()); + logger.error("Record found in DB but is not searchable for the profileId: {}", profileByAuthProvider.getProfileId()); + throw new InternalError("Record found in DB but is not searchable"); } List listAccountsByProfileId = accountByProfileIdRepository diff --git a/src/main/java/biz/nynja/account/services/AccountServiceImpl.java b/src/main/java/biz/nynja/account/services/AccountServiceImpl.java index cd5b80e..71e8dde 100644 --- a/src/main/java/biz/nynja/account/services/AccountServiceImpl.java +++ b/src/main/java/biz/nynja/account/services/AccountServiceImpl.java @@ -182,9 +182,9 @@ public class AccountServiceImpl extends AccountServiceGrpc.AccountServiceImplBas Optional account = Optional.empty(); try { account = accountProvider.searchAccountByLoginOption(AuthenticationType.EMAIL, request.getEmail()); - } catch (IncorrectAccountCountException e) { + } catch (IncorrectAccountCountException | InternalError e) { logAndBuildGrpcSearchResponse(responseObserver, SearchResponse.newBuilder(), - "Error while searching for e-mail. {}.", e.getMessage(), Cause.INTERNAL_SERVER_ERROR, ""); + "Error while searching for e-mail. {}.", e.getMessage(), Cause.INTERNAL_SERVER_ERROR, "Error while searching for e-mail."); return; } -- GitLab From 9d174e46af915f58c2bd2b4c23098ef4dc1a378c Mon Sep 17 00:00:00 2001 From: Stoyan Tzenkov Date: Wed, 23 Jan 2019 18:03:02 +0200 Subject: [PATCH 3/3] NY-6436: Got rid of InternalError, logging at info level. Signed-off-by: Stoyan Tzenkov --- .../account/repositories/AccountRepositoryAdditionalImpl.java | 4 ++-- .../java/biz/nynja/account/services/AccountServiceImpl.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/biz/nynja/account/repositories/AccountRepositoryAdditionalImpl.java b/src/main/java/biz/nynja/account/repositories/AccountRepositoryAdditionalImpl.java index 7f51e10..6518636 100644 --- a/src/main/java/biz/nynja/account/repositories/AccountRepositoryAdditionalImpl.java +++ b/src/main/java/biz/nynja/account/repositories/AccountRepositoryAdditionalImpl.java @@ -949,8 +949,8 @@ public class AccountRepositoryAdditionalImpl implements AccountRepositoryAdditio return Optional.empty(); } if (!profileByAuthProvider.getSearchable().booleanValue()) { - logger.error("Record found in DB but is not searchable for the profileId: {}", profileByAuthProvider.getProfileId()); - throw new InternalError("Record found in DB but is not searchable"); + logger.info("Record found in DB but is not searchable for the profileId: {}", profileByAuthProvider.getProfileId()); + return Optional.empty(); } List listAccountsByProfileId = accountByProfileIdRepository diff --git a/src/main/java/biz/nynja/account/services/AccountServiceImpl.java b/src/main/java/biz/nynja/account/services/AccountServiceImpl.java index 71e8dde..8f06131 100644 --- a/src/main/java/biz/nynja/account/services/AccountServiceImpl.java +++ b/src/main/java/biz/nynja/account/services/AccountServiceImpl.java @@ -182,7 +182,7 @@ public class AccountServiceImpl extends AccountServiceGrpc.AccountServiceImplBas Optional account = Optional.empty(); try { account = accountProvider.searchAccountByLoginOption(AuthenticationType.EMAIL, request.getEmail()); - } catch (IncorrectAccountCountException | InternalError e) { + } catch (IncorrectAccountCountException e) { logAndBuildGrpcSearchResponse(responseObserver, SearchResponse.newBuilder(), "Error while searching for e-mail. {}.", e.getMessage(), Cause.INTERNAL_SERVER_ERROR, "Error while searching for e-mail."); return; -- GitLab