Skip to content

Commit 08f2757

Browse files
committed
/error/404: do logging to database in separate thread.
Now 404 page should be displayed a bit faster. No functional changes.
1 parent 96c9c40 commit 08f2757

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

src/main/java/ru/mystamps/web/controller/ErrorController.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,7 @@ public void notFound(
5656
currentUser = userDetails.getUser();
5757
}
5858

59-
try {
60-
siteService.logAboutAbsentPage(page, currentUser, ip, referer, agent);
61-
} catch (Exception ex) { // NOPMD
62-
// intentionally ignored:
63-
// database error should not break showing of 404 page
64-
LOG.warn("Cannot log 404 error", ex);
65-
}
59+
siteService.logAboutAbsentPage(page, currentUser, ip, referer, agent);
6660
}
6761

6862
@RequestMapping(Url.INTERNAL_ERROR_PAGE)

src/main/java/ru/mystamps/web/service/SiteServiceImpl.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.apache.commons.lang3.StringUtils;
2323
import org.apache.commons.lang3.Validate;
2424

25+
import org.springframework.scheduling.annotation.Async;
2526
import org.springframework.transaction.annotation.Transactional;
2627

2728
import lombok.RequiredArgsConstructor;
@@ -43,6 +44,7 @@ public class SiteServiceImpl implements SiteService {
4344

4445
@Override
4546
@SuppressWarnings("PMD.UseObjectForClearerAPI")
47+
@Async
4648
@Transactional
4749
public void logAboutAbsentPage(
4850
String page,

0 commit comments

Comments
 (0)