Skip to content

Commit 0209d61

Browse files
committed
Fix crash on startup with prod profile
1 parent ee2f7d6 commit 0209d61

File tree

4 files changed

+11
-24
lines changed

4 files changed

+11
-24
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ before_install:
2525
install:
2626
- git clone https://github.com/FAForever/faf-stack.git faf-stack
2727
&& pushd faf-stack
28-
&& git checkout 9f01fbe
28+
&& git checkout b9fc74d
2929
&& cp -r config.template config
3030
&& cp .env.template .env
3131
&& ./scripts/init-db.sh

src/inttest/resources/config/application.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ spring:
1818
h2:
1919
console:
2020
enabled: true
21+
mail:
22+
host: false
2123

2224

2325
faf-api:
Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,22 @@
11
package com.faforever.api.email;
22

3-
import com.faforever.api.email.NoopEmailSender.MailSenderCondition;
43
import lombok.extern.slf4j.Slf4j;
4+
import org.springframework.beans.factory.InitializingBean;
55
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
6-
import org.springframework.boot.autoconfigure.condition.NoneNestedConditions;
7-
import org.springframework.context.annotation.Conditional;
86
import org.springframework.stereotype.Component;
97

108
@Component
119
@Slf4j
12-
@Conditional(MailSenderCondition.class)
13-
public class NoopEmailSender implements EmailSender {
10+
@ConditionalOnProperty(value = "spring.mail.host", havingValue = "false")
11+
public class NoopEmailSender implements EmailSender, InitializingBean {
12+
@Override
13+
public void afterPropertiesSet() {
14+
log.warn("No email sender defined, using fallback NoopEmailSender instead!");
15+
}
16+
1417
@Override
1518
public void sendMail(String fromEmail, String fromName, String toEmail, String subject, String content) {
1619
log.debug("Would send email from '{} <{}>' to '{}' with subject '{}' and text: {}",
1720
fromName, fromEmail, toEmail, subject, content);
1821
}
19-
20-
static class MailSenderCondition extends NoneNestedConditions {
21-
22-
MailSenderCondition() {
23-
super(ConfigurationPhase.PARSE_CONFIGURATION);
24-
}
25-
26-
@ConditionalOnProperty("faf-api.mail.mandrill-api-key")
27-
static class HostProperty {
28-
29-
}
30-
31-
@ConditionalOnProperty("spring.mail.host")
32-
static class JndiNameProperty {
33-
34-
}
35-
}
3622
}

src/main/resources/config/application-prod.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ faf-api:
3636
clan:
3737
website-url-format: ${CLAN_WEBSITE_URL_FORMAT}
3838
mail:
39-
mandrill-api-key: ${MANDRILL_API_KEY}
4039
from-email-name: ${EMAIL_FROM_NAME}
4140
from-email-address: ${EMAIL_FROM_ADDRESS}
4241
registration:

0 commit comments

Comments
 (0)