Skip to content

Commit 92afab2

Browse files
committed
Eating BrokenPipeExceptions from CDR views and errors related to jsp streams already having closed. Reducing logging when the attempt to get FOXML for the full record page times out. Deleted extra ErrorController.
1 parent e6ce828 commit 92afab2

File tree

3 files changed

+31
-70
lines changed

3 files changed

+31
-70
lines changed

access-common/src/main/java/edu/unc/lib/dl/ui/controller/ErrorController.java

+22-13
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
*/
1616
package edu.unc.lib.dl.ui.controller;
1717

18+
import java.net.SocketException;
19+
1820
import javax.servlet.http.HttpServletRequest;
1921
import javax.servlet.http.HttpServletResponse;
2022

@@ -29,30 +31,37 @@
2931
* @author bbpennel
3032
*/
3133
@Controller
32-
public class ErrorController {
34+
public class ErrorController {
3335
private static final Logger LOG = LoggerFactory.getLogger(ErrorController.class);
34-
36+
3537
@RequestMapping("/403")
36-
public String handle403(Model model, HttpServletRequest request, HttpServletResponse response) {
38+
public String handle403(Model model, HttpServletRequest request, HttpServletResponse response) {
3739
response.setStatus(HttpServletResponse.SC_FORBIDDEN);
3840
model.addAttribute("pageSubtitle", "Error");
39-
return "error/403";
40-
}
41-
41+
return "error/403";
42+
}
43+
4244
@RequestMapping("/404")
43-
public String handle404(Model model, HttpServletResponse response) {
45+
public String handle404(Model model, HttpServletResponse response) {
4446
LOG.debug("Page not found, forwarding to 404 page");
4547
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
4648
model.addAttribute("pageSubtitle", "Page not found");
47-
return "error/404";
48-
}
49+
return "error/404";
50+
}
4951

5052
@RequestMapping("/exception")
51-
public String handleException(Model model, HttpServletRequest request, HttpServletResponse response) {
53+
public String handleException(Model model, HttpServletRequest request, HttpServletResponse response) {
5254
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
5355
Throwable throwable = (Throwable) request.getAttribute("javax.servlet.error.exception");
54-
LOG.error("An uncaught exception occurred at " + request.getAttribute("javax.servlet.forward.request_uri"), throwable);
56+
57+
if (throwable.getCause() instanceof SocketException || throwable instanceof IllegalStateException) {
58+
LOG.debug("Connection aborted for {}", request.getAttribute("javax.servlet.forward.request_uri"), throwable);
59+
} else {
60+
LOG.error("An uncaught exception occurred at " + request.getAttribute("javax.servlet.forward.request_uri"),
61+
throwable);
62+
}
63+
5564
model.addAttribute("pageSubtitle", "Error");
56-
return "error/exception";
57-
}
65+
return "error/exception";
66+
}
5867
}

access/src/main/java/edu/unc/lib/dl/ui/controller/ErrorController.java

-57
This file was deleted.

access/src/main/java/edu/unc/lib/dl/ui/controller/FullRecordController.java

+9
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import java.util.ArrayList;
1919
import java.util.Date;
2020
import java.util.List;
21+
import java.util.concurrent.TimeoutException;
2122

2223
import javax.servlet.http.HttpServletRequest;
2324

@@ -41,6 +42,7 @@
4142
import edu.unc.lib.dl.fedora.FedoraDataService;
4243
import edu.unc.lib.dl.fedora.FedoraException;
4344
import edu.unc.lib.dl.fedora.NotFoundException;
45+
import edu.unc.lib.dl.fedora.ServiceException;
4446
import edu.unc.lib.dl.search.solr.model.BriefObjectMetadataBean;
4547
import edu.unc.lib.dl.search.solr.model.SearchResultResponse;
4648
import edu.unc.lib.dl.search.solr.model.SimpleIdRequest;
@@ -129,6 +131,13 @@ public String getFullRecord(String pid, Model model, HttpServletRequest request)
129131
LOG.error("Failed to render full record view for " + idRequest.getId(), e);
130132
} catch (RenderViewException e) {
131133
LOG.error("Failed to render full record view for " + idRequest.getId(), e);
134+
} catch (ServiceException e) {
135+
if (e.getCause() instanceof TimeoutException) {
136+
LOG.warn("Maximum retrieval time exceeded while retrieving FOXML for full record of {}",
137+
idRequest.getId());
138+
} else {
139+
LOG.error("Failed to retrieve FOXML for object {}" , idRequest.getId(), e);
140+
}
132141
}
133142
}
134143

0 commit comments

Comments
 (0)