Skip to content

Commit d9791f4

Browse files
KarineValencaeabili0
authored andcommitted
added condition to set errorMessage to empty string if error-message init-param has not been defined
1 parent 46b64dd commit d9791f4

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/main/java/br/com/labbs/monitor/filter/MetricsCollectorFilter.java

+4
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ public void init(FilterConfig filterConfig) {
110110
String version = getApplicationVersionFromPropertiesFile();
111111
// Allow users to capture error messages
112112
errorMessageParam = filterConfig.getInitParameter(ERROR_MESSAGE_PARAM);
113+
113114
MonitorMetrics.INSTANCE.init(exportJvmMetrics, version, buckets);
114115
}
115116

@@ -210,6 +211,9 @@ private boolean isErrorStatus(int status) {
210211
* @return string with the error message or empty string if error message not found.
211212
*/
212213
private String getErrorMessage(HttpServletRequest httpRequest) {
214+
if (errorMessageParam == null) {
215+
return "";
216+
}
213217
String errorMessage = (String) httpRequest.getAttribute(errorMessageParam);
214218
if (errorMessage == null) {
215219
return "";

0 commit comments

Comments
 (0)