Don't call open() from RealImapFolder.appendMessages()

This commit is contained in:
cketti 2024-04-25 21:39:07 +02:00
parent 874b06f415
commit 94e0ced621
2 changed files with 13 additions and 1 deletions

View file

@ -964,7 +964,6 @@ internal class RealImapFolder(
*/
@Throws(MessagingException::class)
override fun appendMessages(messages: List<Message>): Map<String, String>? {
open(OpenMode.READ_WRITE)
checkOpen()
return try {

View file

@ -994,6 +994,19 @@ class RealImapFolderTest {
assertThat(buffer.readUtf8()).isEqualTo("text")
}
@Test
fun `appendMessages() on closed folder should throw`() {
val folder = createFolder("Folder")
val messages = listOf(createImapMessage("1"))
assertFailure {
folder.appendMessages(messages)
}.isInstanceOf<MessagingException>()
.hasMessage("Folder Folder is not open.")
verifyNoMoreInteractions(imapConnection)
}
@Test
fun appendMessages_shouldIssueRespectiveCommand() {
val folder = createFolder("Folder")