Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IllegalStateException because of a NPE #344

Closed
hheg opened this issue Sep 21, 2020 · 6 comments
Closed

IllegalStateException because of a NPE #344

hheg opened this issue Sep 21, 2020 · 6 comments
Assignees
Labels
Milestone

Comments

@hheg
Copy link

hheg commented Sep 21, 2020

GreenMail 1.5.10 sometimes fail to deliver a mail due to a NPE. GreenMail is run as a docker instance.

14:24:35.502 INFO smtp.SmtpManager| Created user login 7eadcd01-adb3-4584-99e0-fec861e2e54c@test1.com for address 7eadcd01-adb3-4584-99e0-fec861e2e54c@test1.com with password 7eadcd01-adb3-4584-99e0-fec861e2e54c@test1.com because it didn't exist before.

14:24:35.503 Caused by: java.lang.IllegalStateException: Can not deliver com.icegreen.greenmail.mail.MovingMessage@543ef658 for user UserImpl{email='7eadcd01-adb3-4584-99e0-fec861e2e54c@test1.com', login='7eadcd01-adb3-4584-99e0-fec861e2e54c@test1.com'}
at com.icegreen.greenmail.user.UserImpl.deliver(UserImpl.java:58)
at com.icegreen.greenmail.smtp.SmtpManager$Incoming.handle(SmtpManager.java:98)
... 7 more
Caused by: java.lang.NullPointerException 
at com.icegreen.greenmail.user.UserImpl.deliver(UserImpl.java:56)
... 8 more

I'm not sure about the stacktrace since it may have been rearranged when the log was ingested.

@marcelmay marcelmay self-assigned this Sep 21, 2020
@marcelmay marcelmay added the bug label Sep 21, 2020
@marcelmay
Copy link
Member

@hheg , thx for reporting.

I tried to reproduce/provoke with a simple test, but failed:

int i=0;
while(true) {
    GreenMailUtil.sendTextEmailTest("to+"+i+"@localhost", "from@localhost",  "subject", "body"); 
    i++;
}

Can you try latest version 1.6.0 (or 1.5.14) and let me know if the issue still occurs sporadically?

@hheg hheg changed the title IllegalStateException because a NPE IllegalStateException because of a NPE Sep 22, 2020
@hheg
Copy link
Author

hheg commented Sep 22, 2020

Still got this with 1.6.0:

251254  INFO           smtp.SmtpManager| Created user login 3170335f-1e10-423b-b2c8-454e99365619@test1.com for address 3170335f-1e10-423b-b2c8-454e99365619@test1.com with password 3170335f-1e10-423b-b2c8-454e99365619@test1.com because it didn't exist before.
251263  ERROR      commands.DataCommand| Can not send state '250 OK', aborted.
java.lang.IllegalStateException: Can not deliver message com.icegreen.greenmail.mail.MovingMessage@364fb9ff to 3170335f-1e10-423b-b2c8-454e99365619@test1.com
	at com.icegreen.greenmail.smtp.SmtpManager$Incoming.handle(SmtpManager.java:100)
	at com.icegreen.greenmail.smtp.SmtpManager$Incoming.enqueue(SmtpManager.java:81)
	at com.icegreen.greenmail.smtp.SmtpManager.send(SmtpManager.java:56)
	at com.icegreen.greenmail.smtp.commands.DataCommand.execute(DataCommand.java:66)
	at com.icegreen.greenmail.smtp.SmtpHandler.handleCommand(SmtpHandler.java:103)
	at com.icegreen.greenmail.smtp.SmtpHandler.run(SmtpHandler.java:53)
	at com.icegreen.greenmail.server.AbstractServer$1.run(AbstractServer.java:156)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IllegalStateException: Can not deliver com.icegreen.greenmail.mail.MovingMessage@364fb9ff for user UserImpl{email='3170335f-1e10-423b-b2c8-454e99365619@test1.com', login='3170335f-1e10-423b-b2c8-454e99365619@test1.com'}
	at com.icegreen.greenmail.user.UserImpl.deliver(UserImpl.java:63)
	at com.icegreen.greenmail.smtp.SmtpManager$Incoming.handle(SmtpManager.java:98)
	... 7 more
Caused by: java.lang.NullPointerException
	at com.icegreen.greenmail.user.UserImpl.deliver(UserImpl.java:61)
	... 8 more

@marcelmay
Copy link
Member

@hheg , any suggestion how I can provoke this issue eg with latest version 1.6.1 ?

@pbilstein
Copy link

Same error happened today during a presentation.. greenmail 1.6.3 standalone docker version.
Mail sending client was Spring Boot 2.5.4 with Spring starter mail client.
During startup there was a mail client (Mailspring) connected to the failing user.

5433    DEBUG           smtp.SmtpServer| Handling new client connection smtp:0.0.0.0:3025<-/172.17.0.1:49642
5436    DEBUG          user.UserManager| Authenticating user test@test.neoalto.de
5460    ERROR      commands.DataCommand| Can not send state '250 OK', aborted.
java.lang.IllegalStateException: Can not deliver message com.icegreen.greenmail.mail.MovingMessage@21978c7c to user_activation@test.neoalto.de
	at com.icegreen.greenmail.smtp.SmtpManager$Incoming.handle(SmtpManager.java:100)
	at com.icegreen.greenmail.smtp.SmtpManager$Incoming.enqueue(SmtpManager.java:81)
	at com.icegreen.greenmail.smtp.SmtpManager.send(SmtpManager.java:56)
	at com.icegreen.greenmail.smtp.commands.DataCommand.execute(DataCommand.java:65)
	at com.icegreen.greenmail.smtp.SmtpHandler.handleCommand(SmtpHandler.java:97)
	at com.icegreen.greenmail.smtp.SmtpHandler.run(SmtpHandler.java:53)
	at com.icegreen.greenmail.server.AbstractServer.lambda$handleClientSocket$0(AbstractServer.java:160)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IllegalStateException: Can not deliver com.icegreen.greenmail.mail.MovingMessage@21978c7c for user UserImpl{email='user_activation@test.neoalto.de', login='user_activation@test.neoalto.de'}
	at com.icegreen.greenmail.user.UserImpl.deliver(UserImpl.java:63)
	at com.icegreen.greenmail.smtp.SmtpManager$Incoming.handle(SmtpManager.java:98)
	... 7 more
Caused by: java.lang.NullPointerException
	at com.icegreen.greenmail.user.UserImpl.deliver(UserImpl.java:61)
	... 8 more
5573    DEBUG map.ImapRequestLineReader| IMAP Line received : <�>
5573    DEBUG map.ImapRequestLineReader| IMAP Line received : <�>
7054    DEBUG           imap.ImapServer| Handling new client connection imap:0.0.0.0:3143<-/172.17.0.1:57366
7054    DEBUG  util.LoggingOutputStream| S: * OK IMAP4rev1 Server GreenMail v1.6.3 ready\r\n

marcelmay added a commit that referenced this issue Sep 26, 2021
- Improved log output by adding MovingMessage#toString()
- Possible cause could be dubious invocation chain of UserManager.createUser -> addUser ->
  removeUser. Removed addUser, this could possibly break code.
@marcelmay
Copy link
Member

@pbilstein , thanks for the stack trace.

I'm still having problems to reproduce this issue, so I added some debug output.
There's a dubious handling of creating new user, which could lead to such an internal, inconsistent state.

@marcelmay marcelmay added this to the 2.0.0-alpha-3 milestone Feb 20, 2022
@marcelmay
Copy link
Member

marcelmay commented Feb 20, 2022

Please reopen if persists with upcoming 2.0.0-alpha-3 or 1.6.6 release. See my previous comment on d880c4e .

marcelmay added a commit that referenced this issue Feb 20, 2022
…#344, fixes #432)

- Improved log output by adding MovingMessage#toString()
- Possible cause could be dubious invocation chain of UserManager.createUser -> addUser ->
  removeUser. Removed addUser, this could possibly break code.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants