Skip to content

Commit 0ea4743

Browse files
committed
[FIX] Connect was not properly measured
- False measurement of connect timings as "connect" was a noop
1 parent 222a197 commit 0ea4743

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

src/main/scala-2.12/com/linagora/gatling/imap/protocol/ImapSessions.scala

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ import java.util.function.Consumer
77
import akka.actor.{Props, Stash}
88
import com.linagora.gatling.imap.protocol.command._
99
import com.yahoo.imapnio.async.client.ImapAsyncSession.DebugMode
10-
import com.yahoo.imapnio.async.client.{ImapAsyncClient, ImapAsyncSession, ImapAsyncSessionConfig}
10+
import com.yahoo.imapnio.async.client.{ImapAsyncClient, ImapAsyncSession, ImapAsyncSessionConfig, ImapFuture}
11+
import com.yahoo.imapnio.async.internal.ImapAsyncSessionImpl
1112
import io.gatling.core.akka.BaseActor
1213
import io.gatling.core.util.NameGen
1314
import javax.net.ssl.SSLContext
@@ -57,25 +58,25 @@ private object ImapSession {
5758
private class ImapSession(client: => ImapAsyncClient, protocol: ImapProtocol) extends BaseActor with Stash with NameGen {
5859
val uri = new URI(s"${protocol.protocol}://${protocol.host}:${protocol.port}")
5960
val config: Properties = protocol.config
60-
logger.debug(s"connecting to $uri with $config")
61-
val session: ImapAsyncSession = {
62-
val config = new ImapAsyncSessionConfig
63-
config.setConnectionTimeoutMillis(50000)
64-
config.setReadTimeoutMillis(60000)
65-
val sniNames = null
66-
67-
val localAddress = null
68-
client
69-
.createSession(uri, config, localAddress, sniNames, DebugMode.DEBUG_OFF, "ImapSession", ImapSession.sslContext)
70-
.get()
71-
.getSession
72-
}
61+
var session: ImapAsyncSession = null
7362

7463
override def receive: Receive = disconnected
7564

7665
def disconnected: Receive = {
7766
case Command.Connect(userId) =>
7867
logger.debug(s"got connect request, $userId connecting to $uri")
68+
69+
val config = new ImapAsyncSessionConfig
70+
config.setConnectionTimeoutMillis(50000)
71+
config.setReadTimeoutMillis(60000)
72+
val sniNames = null
73+
val localAddress = null
74+
75+
session = client
76+
.createSession(uri, config, localAddress, sniNames, DebugMode.DEBUG_OFF, "ImapSession", ImapSession.sslContext)
77+
.get()
78+
.getSession
79+
7980
context.become(connected)
8081
sender() ! Response.Connected(ImapResponses.empty)
8182
case Response.Disconnected(_) => ()
@@ -207,6 +208,7 @@ private class ImapSession(client: => ImapAsyncClient, protocol: ImapProtocol) ex
207208
case Command.Disconnect(userId) =>
208209
context.become(disconnected)
209210
val responseCallback: Consumer[java.lang.Boolean] = _ => {
211+
session = null
210212
sender() ! Response.Disconnected(s"Disconnected command for ${userId.value}")
211213
}
212214
val future = session.close()

0 commit comments

Comments
 (0)