nithril / smtp-connection-pool

SMTP Connection Pool
Apache License 2.0
47 stars 19 forks source link

How do return borrowed objects? #11

Closed ghost closed 7 years ago

ghost commented 7 years ago

Please tell me how do i return borrowed object, as i set max limit to "1"

config.setMaxTotal(1);

and after sending 1 mail i can't able to borrrow another object from pool.

nithril commented 7 years ago

See test example and the test case. Connection must be borrowed inside a try with resource statement:

try (ClosableSmtpConnection transport = smtpConnectionPool.borrowObject()) {
}