Skip to content

Commit 0bbed47

Browse files
committed
Fixes for spotless and PMD
1 parent d9b1ac7 commit 0bbed47

File tree

1 file changed

+9
-9
lines changed
  • ticketing-eventing/mail-handler-service/src/main/java/de/muenchen/oss/dbs/ticketing/eventing/mailhandler/adapter/out/mail

1 file changed

+9
-9
lines changed

ticketing-eventing/mail-handler-service/src/main/java/de/muenchen/oss/dbs/ticketing/eventing/mailhandler/adapter/out/mail/MailAdapter.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import jakarta.mail.MessagingException;
66
import jakarta.mail.internet.MimeMessage;
77
import jakarta.mail.util.ByteArrayDataSource;
8-
98
import java.io.BufferedInputStream;
109
import java.io.IOException;
1110
import java.io.InputStream;
@@ -36,21 +35,22 @@ public void sendMail(final MailMessage mailMessage) {
3635
helper.setText(mailMessage.getBody(), true);
3736
for (final Map.Entry<String, InputStream> entry : mailMessage.getAttachments().entrySet()) {
3837
//TODO is there a way to do this with streaming? The following line loads the attachment into RAM...
39-
InputStream bis = new BufferedInputStream(entry.getValue());
40-
String mime = detectMimeType(bis);
41-
log.debug("Mime-Type for " + entry.getKey() + " found " + mime);
42-
final DataSource dataSource = new ByteArrayDataSource(bis, mime);
43-
helper.addAttachment(entry.getKey(), dataSource);
44-
//maybe like this?
45-
//helper.addAttachment(e.getKey(), new InputStreamSourceImpl(e.getValue()));
38+
try (InputStream bis = new BufferedInputStream(entry.getValue())) {
39+
final String mime = detectMimeType(bis);
40+
log.debug("Mime-Type for " + entry.getKey() + " found " + mime);
41+
final DataSource dataSource = new ByteArrayDataSource(bis, mime);
42+
helper.addAttachment(entry.getKey(), dataSource);
43+
//maybe like this?
44+
//helper.addAttachment(e.getKey(), new InputStreamSourceImpl(e.getValue()));
45+
}
4646
}
4747
mailSender.send(mimeMessage);
4848
} catch (final MessagingException | IOException e) {
4949
throw new RuntimeException(e);
5050
}
5151
}
5252

53-
public String detectMimeType(InputStream inputStream) throws IOException {
53+
public String detectMimeType(final InputStream inputStream) throws IOException {
5454
return tika.detect(inputStream);
5555
}
5656

0 commit comments

Comments
 (0)