Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0038567Openbravo ERPA. Platformpublic2018-05-17 08:552018-06-04 10:53
alostale 
alostale 
normalmajorhave not tried
closedfixed 
5
 
3.0PR18Q3 
caristu
Core
No
0038567: can get stuck sending emails
If email server is unresponsive, threads trying to send emails can get indefinitely stuck trying to connect to it.
1. Configure a very slow smtp server
    You can use, ie., a fake smpt server like dumbster [1]
        
           SimpleSmtpServer.start(8025);
        

    and add breakpoints to simulate slowness

2. Configure Client in Openbravo to make use of it
3. Open a completed Sales Order
4. Click on send email
  -> Check the threads gets stuck while the email server is not responding:
"ajp-bio-127.0.0.1-8009-exec-678" daemon prio=10 tid=0x00007fd2800cf800 nid=0x1f7ff runnable [0x00007fd38befb000]
   java.lang.Thread.State: RUNNABLE
    at java.net.SocketInputStream.socketRead0(Native Method)
    at java.net.SocketInputStream.read(SocketInputStream.java:153)
    at java.net.SocketInputStream.read(SocketInputStream.java:122)
    at com.sun.mail.util.TraceInputStream.read(TraceInputStream.java:110)
    at java.io.BufferedInputStream.fill(BufferedInputStream.java:235)
    at java.io.BufferedInputStream.read(BufferedInputStream.java:254)
    - locked <0x00000001efd082a0> (a java.io.BufferedInputStream)
    at com.sun.mail.util.LineInputStream.readLine(LineInputStream.java:89)
    at com.sun.mail.smtp.SMTPTransport.readServerResponse(SMTPTransport.java:2131)
    at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1912)
    at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:638)
    at javax.mail.Service.connect(Service.java:317)
    - locked <0x00000001efd083f0> (a com.sun.mail.smtp.SMTPTransport)
    at javax.mail.Service.connect(Service.java:176)
    at javax.mail.Service.connect(Service.java:125)
    at org.openbravo.erpCommon.utility.poc.EmailManager.sendEmail(EmailManager.java:170)
    at org.openbravo.erpCommon.utility.reporting.printing.PrintController.sendDocumentEmail(PrintController.java:815)

---
[1] https://github.com/kirviq/dumbster [^]
As quick win, before a more complete solution is implemented by 0038524, add a hardcoded connection timeout (ie. 10min) so in case it is not possible to connect during that time, an exception will be thrown and the thread will be released.
Performance
related to design defect 0038524 closed jarmendariz can't configure timeout for sending emails 
depends on backport 00385683.0PR18Q2.1 closed alostale can get stuck sending emails 
depends on backport 00385693.0PR18Q1.4 closed alostale can get stuck sending emails 
Issue History
2018-05-17 08:55alostaleNew Issue
2018-05-17 08:55alostaleAssigned To => alostale
2018-05-17 08:55alostaleModules => Core
2018-05-17 08:55alostaleTriggers an Emergency Pack => No
2018-05-17 08:55alostaleIssue generated from0038524
2018-05-17 08:55alostaleRelationship addedrelated to 0038524
2018-05-17 08:55alostaleStatusnew => scheduled
2018-05-17 17:19alostaleSteps to Reproduce Updatedbug_revision_view_page.php?rev_id=17157#r17157
2018-05-17 17:19alostaleReview Assigned To => caristu
2018-05-17 17:23hgbotCheckin
2018-05-17 17:23hgbotNote Added: 0104570
2018-05-17 17:23hgbotStatusscheduled => resolved
2018-05-17 17:23hgbotResolutionopen => fixed
2018-05-17 17:23hgbotFixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/fca1e4e422854d56678c04061a176e0ea257c1f0 [^]
2018-05-17 17:24alostaleTag Attached: Performance
2018-05-17 21:41hudsonbotCheckin
2018-05-17 21:41hudsonbotNote Added: 0104582
2018-06-04 10:53caristuNote Added: 0104906
2018-06-04 10:53caristuStatusresolved => closed
2018-06-04 10:53caristuFixed in Version => 3.0PR18Q3

Notes
(0104570)
hgbot   
2018-05-17 17:23   
Repository: erp/devel/pi
Changeset: fca1e4e422854d56678c04061a176e0ea257c1f0
Author: Asier Lostalé <asier.lostale <at> openbravo.com>
Date: Thu May 17 17:22:21 2018 +0200
URL: http://code.openbravo.com/erp/devel/pi/rev/fca1e4e422854d56678c04061a176e0ea257c1f0 [^]

fixed bug 38567: can get stuck forever sending emails

  Added a fixed 10 minutes timeout for communications with smtp servers, this
  same timeout is applied to connection creation as well as reading responses
  from server. Note it is not applied to writing operations.

---
M src/org/openbravo/erpCommon/utility/poc/EmailManager.java
---
(0104582)
hudsonbot   
2018-05-17 21:41   
A changeset related to this issue has been promoted main and to the
Central Repository, after passing a series of tests.

Promotion changeset: https://code.openbravo.com/erp/devel/main/rev/4e28963f0fe6 [^]
Maturity status: Test
(0104906)
caristu   
2018-06-04 10:53   
Code reviewed + tested OK.