Skip to content

Commit 55f747a

Browse files
fix(ExceptionResolver): use portalemailaddress for mail.from field
1 parent 3f5850a commit 55f747a

File tree

4 files changed

+10
-17
lines changed

4 files changed

+10
-17
lines changed

src/main/java/org/wise/portal/spring/impl/WISESimpleMappingExceptionResolver.java

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,11 @@ public ModelAndView resolveException(HttpServletRequest request, HttpServletResp
7474
String portalName = appProperties.getProperty("wise.name");
7575
String[] recipients = appProperties.getProperty(HANDLE_EXCEPTION_PROPERTY_KEY).split(",");
7676
String subject = HANDLE_EXCEPTION_MAIL_SUBJECT + ": (" + portalName + ")";
77-
String fromEmail = appProperties.getProperty("mail.from");
77+
String fromEmail = appProperties.getProperty("portalemailaddress");
7878
String message = getHandleExceptionMessage(request, exception);
7979

80-
ExceptionEmailSender emailSender =
81-
new ExceptionEmailSender(recipients,subject,fromEmail,message);
80+
ExceptionEmailSender emailSender = new ExceptionEmailSender(recipients, subject, fromEmail,
81+
message);
8282
Thread thread = new Thread(emailSender);
8383
thread.start();
8484
}
@@ -91,8 +91,8 @@ class ExceptionEmailSender implements Runnable {
9191
String fromEmail;
9292
String message;
9393

94-
public ExceptionEmailSender(String[] recipients, String subject,
95-
String fromEmail, String message) {
94+
public ExceptionEmailSender(String[] recipients, String subject, String fromEmail,
95+
String message) {
9696
this.recipients = recipients;
9797
this.subject = subject;
9898
this.fromEmail = fromEmail;
@@ -122,9 +122,8 @@ private String getHandleExceptionMessage(HttpServletRequest request, Exception e
122122
Date time = Calendar.getInstance().getTime();
123123
User user = ControllerUtil.getSignedInUser();
124124

125-
String fullUrl = request.getScheme() + "://" + request.getServerName() + ":" +
126-
request.getServerPort() + request.getRequestURI() + "?" +
127-
request.getQueryString();
125+
String fullUrl = request.getScheme() + "://" + request.getServerName() + ":"
126+
+ request.getServerPort() + request.getRequestURI() + "?" + request.getQueryString();
128127

129128
Writer result = new StringWriter();
130129
PrintWriter printWriter = new PrintWriter(result);
@@ -138,12 +137,9 @@ private String getHandleExceptionMessage(HttpServletRequest request, Exception e
138137
username = "unknown";
139138
}
140139

141-
String message = "The following WISE exception was thrown on " +
142-
time.toString() + "\n\n" +
143-
"username: " + username + "\n" +
144-
"url: " + fullUrl + "\n\n" +
145-
"exception message: " + exception.toString() + "\n\n" +
146-
"stacktrace:\n" + stackTrace;
140+
String message = "The following WISE exception was thrown on " + time.toString() + "\n\n"
141+
+ "username: " + username + "\n" + "url: " + fullUrl + "\n\n" + "exception message: "
142+
+ exception.toString() + "\n\n" + "stacktrace:\n" + stackTrace;
147143

148144
return message;
149145
}

src/main/resources/application-dockerdev-sample.properties

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ spring.redis.pool.max.total=128
116116
# With this approach,
117117
# mail.user is the gmail username
118118
# mail.password is the gmail password
119-
# mail.from is the gmail address (ex [email protected])
120119
# mail.smtp.host=smtp.gmail.com
121120
# and leave everything else the default.
122121

src/main/resources/application_sample.properties

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ spring.redis.pool.max.total=128
116116
# With this approach,
117117
# mail.user is the gmail username
118118
# mail.password is the gmail password
119-
# mail.from is the gmail address (ex [email protected])
120119
# mail.smtp.host=smtp.gmail.com
121120
# and leave everything else the default.
122121

src/test/resources/application.properties

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ spring.redis.pool.max.total=128
114114
# With this approach,
115115
# mail.user is the gmail username
116116
# mail.password is the gmail password
117-
# mail.from is the gmail address (ex [email protected])
118117
# mail.smtp.host=smtp.gmail.com
119118
# and leave everything else the default.
120119

0 commit comments

Comments
 (0)