Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
gsaviane opened this issue Nov 19, 2024 · 4 comments
Labels

Comments

@gsaviane
Copy link

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

@enochdavidson
Copy link

This issue has been fixed in jackson-databind 2.9.1
FasterXML/jackson-databind#1745
https://github.com/FasterXML/jackson/wiki/Jackson-Release-2.9.1

@gsaviane
Copy link
Author

This issue has been fixed in jackson-databind 2.9.1 FasterXML/jackson-databind#1745 https://github.com/FasterXML/jackson/wiki/Jackson-Release-2.9.1

Do you mean the Jackson library shaded in testcontainers embeds a prior version with that bug?
In our maven dependencyManagement we link to Jackson 2.17.0. But I don't think it gets picked up by testcontainers, otherwise the entire shaded logic would not work as intended

@enochdavidson
Copy link

Yes, testcontainers includes an outdated version of the Jackson library.
Please see

force 'com.fasterxml.jackson.core:jackson-databind:2.8.8'

Thus, Testcontainers should provide a fix.

@eddumelendez
Copy link
Member

In the meantime, you can update the dependency by yourself. I have done that in another project and list network wit no issues. Jackson version has not been updated to keep compatibility with other projects using older versions, see #3433.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants