*/
package org.sonar.server.email;
+import java.net.MalformedURLException;
+import java.time.Duration;
import org.apache.commons.mail.Email;
import org.apache.commons.mail.EmailException;
import org.apache.commons.mail.HtmlEmail;
import org.sonar.api.config.EmailSettings;
import static java.nio.charset.StandardCharsets.UTF_8;
+import static java.time.temporal.ChronoUnit.SECONDS;
import static org.apache.commons.lang.StringUtils.equalsIgnoreCase;
import static org.apache.commons.lang.StringUtils.isBlank;
import static org.apache.commons.lang.StringUtils.isNotBlank;
-import java.net.MalformedURLException;
public abstract class EmailSender<T extends BasicEmail> {
- protected static final int SOCKET_TIMEOUT = 30_000;
+ private static final Duration SOCKET_TIMEOUT = Duration.of(30, SECONDS);
protected final EmailSettings emailSettings;
}
}
- public HtmlEmail createEmail(T report) throws MalformedURLException, EmailException {
+ public HtmlEmail createEmail(T report) throws MalformedURLException, EmailException {
HtmlEmail email = new HtmlEmail();
setEmailSettings(email);
import java.net.MalformedURLException;
import java.net.URL;
+import java.time.Duration;
import java.util.Objects;
import java.util.Set;
import java.util.regex.Pattern;
import org.sonar.server.issue.notification.EmailTemplate;
import org.sonar.server.notification.NotificationChannel;
+import static java.time.temporal.ChronoUnit.SECONDS;
import static java.util.Objects.requireNonNull;
/**
private static final Logger LOG = LoggerFactory.getLogger(EmailNotificationChannel.class);
/**
- * @see org.apache.commons.mail.Email#setSocketConnectionTimeout(int)
- * @see org.apache.commons.mail.Email#setSocketTimeout(int)
+ * @see org.apache.commons.mail.Email#setSocketConnectionTimeout(Duration)
+ * @see org.apache.commons.mail.Email#setSocketTimeout(Duration)
*/
- private static final int SOCKET_TIMEOUT = 30_000;
+ private static final Duration SOCKET_TIMEOUT = Duration.of(30, SECONDS);
private static final Pattern PATTERN_LINE_BREAK = Pattern.compile("[\n\r]");