Skip to content

[Bug]: Cannot parse Date when deserializing com.github.dockerjava.api.model.Network object #9542

Open
@gsaviane

Description

@gsaviane

Module

Core

Testcontainers version

1.20.3

Using the latest Testcontainers version?

Yes

Host OS

Ubuntu 20.04

Host Arch

x86_64

Docker version

Client:
 Version:           24.0.7
 API version:       1.43
 Go version:        go1.21.1
 Git commit:        24.0.7-0ubuntu2~20.04.1
 Built:             Wed Mar 13 20:29:24 2024
 OS/Arch:           linux/amd64
 Context:           default

Server:
 Engine:
  Version:          24.0.7
  API version:      1.43 (minimum version 1.12)
  Go version:       go1.21.1
  Git commit:       24.0.7-0ubuntu2~20.04.1
  Built:            Wed Mar 13 20:29:24 2024
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.7.12
  GitCommit:        
 runc:
  Version:          1.1.12-0ubuntu2~20.04.1
  GitCommit:        
 docker-init:
  Version:          0.19.0
  GitCommit:

What happened?

We have some integration tests written in Junit5 brining up a GenericContainer for end-to-end tests between components. When the tests are run in a host process the GenericContainer object is created successfully, but when tests are run within a container (like in Jenkins) the GenericContainer fails to build, throwing the exception reported in the log pane.

Debugging the code, it seems the GenericContainer fails to deserialize dates in com.github.dockerjava.api.model.Network object when inspecting the docker network. The date format returned with docker network inspect is indeed "2024-11-13T21:04:48.309416219+0100", but apparently the BaseSettings initialized in ObjectMapper uses a StdDateFormat that is not able to parse it.

Reverting the dependency to testcontainers 1.17.6 made it work. I think this could be a regression.

Relevant log output

java.lang.RuntimeException: org.testcontainers.shaded.com.fasterxml.jackson.databind.exc.InvalidFormatException: Can not deserialize value of type java.util.Date from String "2024-11-13T21:04:48.309416219+01:00": not a valid representation (error: Failed to parse Date value '2024-11-13T21:04:48.309416219+01:00': Can not parse date "2024-11-13T21:04:48.309416219+0100": while it seems to fit format 'yyyy-MM-dd'T'HH:mm:ss.SSSZ', parsing fails (leniency? null))

 at [Source: N/A; line: -1, column: -1] (through reference chain: com.github.dockerjava.api.model.Network["Created"])
	at org.testcontainers.shaded.com.github.dockerjava.core.DefaultInvocationBuilder.get(DefaultInvocationBuilder.java:77) ~[testcontainers-1.20.3.jar:1.20.3]
	at org.testcontainers.shaded.com.github.dockerjava.core.exec.InspectNetworkCmdExec.execute(InspectNetworkCmdExec.java:26) ~[testcontainers-1.20.3.jar:1.20.3]
	at org.testcontainers.shaded.com.github.dockerjava.core.exec.InspectNetworkCmdExec.execute(InspectNetworkCmdExec.java:12) ~[testcontainers-1.20.3.jar:1.20.3]
	at org.testcontainers.shaded.com.github.dockerjava.core.exec.AbstrSyncDockerCmdExec.exec(AbstrSyncDockerCmdExec.java:21) ~[testcontainers-1.20.3.jar:1.20.3]
	at org.testcontainers.shaded.com.github.dockerjava.core.command.AbstrDockerCmd.exec(AbstrDockerCmd.java:33) ~[testcontainers-1.20.3.jar:1.20.3]
	at org.testcontainers.shaded.com.github.dockerjava.core.command.InpectNetworkCmdImpl.exec(InpectNetworkCmdImpl.java:7) ~[testcontainers-1.20.3.jar:1.20.3]
	at org.testcontainers.dockerclient.DockerClientProviderStrategy.resolveDockerHostIpAddress(DockerClientProviderStrategy.java:453) ~[testcontainers-1.20.3.jar:1.20.3]
	at org.testcontainers.dockerclient.DockerClientProviderStrategy.getDockerHostIpAddress(DockerClientProviderStrategy.java:424) ~[testcontainers-1.20.3.jar:1.20.3]
	at org.testcontainers.DockerClientFactory.dockerHostIpAddress(DockerClientFactory.java:344) ~[testcontainers-1.20.3.jar:1.20.3]
	at org.testcontainers.containers.ContainerState.getHost(ContainerState.java:64) ~[testcontainers-1.20.3.jar:1.20.3]
	at org.testcontainers.containers.wait.strategy.HostPortWaitStrategy.waitUntilReady(HostPortWaitStrategy.java:112) ~[testcontainers-1.20.3.jar:1.20.3]
	at org.testcontainers.containers.wait.strategy.AbstractWaitStrategy.waitUntilReady(AbstractWaitStrategy.java:52) ~[testcontainers-1.20.3.jar:1.20.3]
	at org.testcontainers.containers.GenericContainer.waitUntilContainerStarted(GenericContainer.java:901) ~[testcontainers-1.20.3.jar:1.20.3]
	at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:492) ~[testcontainers-1.20.3.jar:1.20.3]
	at org.testcontainers.containers.GenericContainer.lambda$doStart$0(GenericContainer.java:346) ~[testcontainers-1.20.3.jar:1.20.3]
	at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:81) ~[duct-tape-1.0.8.jar:?]
	at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:336) ~[testcontainers-1.20.3.jar:1.20.3]
	at org.testcontainers.containers.GenericContainer.start(GenericContainer.java:322) ~[testcontainers-1.20.3.jar:1.20.3]
	at org.testcontainers.containers.PortForwardingContainer.createSSHSession(PortForwardingContainer.java:43) ~[testcontainers-1.20.3.jar:1.20.3]
	at org.testcontainers.containers.PortForwardingContainer.getSshConnection(PortForwardingContainer.java:38) ~[testcontainers-1.20.3.jar:1.20.3]
	at org.testcontainers.containers.PortForwardingContainer.exposeHostPort(PortForwardingContainer.java:69) ~[testcontainers-1.20.3.jar:1.20.3]
	at org.testcontainers.containers.PortForwardingContainer.exposeHostPort(PortForwardingContainer.java:63) ~[testcontainers-1.20.3.jar:1.20.3]
	at org.testcontainers.Testcontainers.exposeHostPorts(Testcontainers.java:14) ~[testcontainers-1.20.3.jar:1.20.3]

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    resolution/waiting-for-infoWaiting for more information of the issue author or another 3rd party.type/bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions