This repository was archived by the owner on Dec 3, 2019. It is now read-only.
This repository was archived by the owner on Dec 3, 2019. It is now read-only.
Closed
Description
I encountered some unexpected timeouts in a spray.io project, and it seems to be related to the encoding of LocalDateTime values.
Test snippet:
import scala.concurrent.{Await, Future}
import scala.concurrent.duration._
import com.github.mauricio.async.db.postgresql.PostgreSQLConnection
import com.github.mauricio.async.db.postgresql.util.URLParser
import org.joda.time.LocalDateTime
object LocalDateTimeTest extends App {
def await[T](f: Future[T]): T = Await.result(f, 5 seconds)
val conn = new PostgreSQLConnection(
URLParser.parse("jdbc:postgresql://localhost:5432/db?user=testuser&password=")
)
try {
await(conn.connect)
val date1 = new LocalDateTime
await(conn.sendPreparedStatement("CREATE TEMP TABLE test(t TIMESTAMP)"))
await(conn.sendPreparedStatement("INSERT INTO test(t) VALUES(?)", Seq(date1)))
val result = await(conn.sendPreparedStatement("SELECT t FROM test"))
val date2 = result.rows.get.head(0)
assert(date2 == date1)
} finally {
conn.disconnect
}
}
scala> await(conn.sendPreparedStatement("INSERT INTO test(t) VALUES(?)", Seq(date1)))
java.util.concurrent.TimeoutException: Futures timed out after [5 seconds]
at scala.concurrent.impl.Promise$DefaultPromise.ready(Promise.scala:219)
at scala.concurrent.impl.Promise$DefaultPromise.result(Promise.scala:223)
at scala.concurrent.Await$$anonfun$result$1.apply(package.scala:107)
at scala.concurrent.BlockContext$DefaultBlockContext$.blockOn(BlockContext.scala:53)
at scala.concurrent.Await$.result(package.scala:107)
...
I'm using Scala 2.10.3 and PostgreSQL 9.3.2.