Skip to content

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

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

Open
gsaviane opened this issue Nov 19, 2024 · 17 comments
Labels
resolution/waiting-for-info Waiting for more information of the issue author or another 3rd party. type/bug

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

@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.

@enochdavidson
Copy link

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.

@eddumelendez
How would I override the shaded jackson-databind to 2.9.1?

@eddumelendez
Copy link
Member

shaded dependencies can not be overridden. jackson dependencies are shaded and transitives dependencies in testcontainers. So, what I meant is just updating the transitives dependencies.

@bademux
Copy link

bademux commented Dec 16, 2024

Looks like I hit the same bug.
Any working solution? I'm not sure how we can overcome shaded jackson bug.
Thanks for any help in advance.

@EVPA0306
Copy link

EVPA0306 commented Feb 6, 2025

I had the same issue when I run TC tests on Jenkins pipeline.
I downgraded TC version to 1.19.5 and solved the issue!
Hope it helps

@eddumelendez
Copy link
Member

Can someone share a project that reproduces the issue?

@eddumelendez eddumelendez added the resolution/waiting-for-info Waiting for more information of the issue author or another 3rd party. label Feb 21, 2025
@EVPA0306
Copy link

I’m sorry, I can’t because it’s corporate project.

@eddumelendez
Copy link
Member

It doesn't need to be the same project. It can be a small project that has everything needed to reproduce the issue you mention.

@ZPavel
Copy link

ZPavel commented Mar 14, 2025

Hi.
I have the same issue. Any chance to be fixed soon please?
Thx, Pavel

@enochdavidson
Copy link

This temporary workaround worked for a Spring Boot application.
Copy com.fasterxml.jackson.databind.util.StdDateFormat from latest jackson-databind to the org.testcontainers.shaded.com.fasterxml.jackson.databind.util package in your source code and ensure it loads before other libraries.
Hope this helps!

@bademux
Copy link

bademux commented Mar 14, 2025

@enochdavidson are you sure it works without recompilation?
Package is different.

@enochdavidson
Copy link

enochdavidson commented Mar 19, 2025

@bademux
You need to copy the source (StdDateFormat.java) to your project and update the package and import statements if needed.

@dvinci-gefi
Copy link

I am also experiencing this issue when running tests on Gitlab CI with a docker executor. I tried to create a project for reproduction, but with no success so far.

It happens when we call the start() method of GenericContainer.

java.lang.RuntimeException: org.testcontainers.shaded.com.fasterxml.jackson.databind.exc.InvalidFormatException: Can not deserialize value of type java.util.Date from String "2025-03-03T14:25:12.722942905+01:00": not a valid representation (error: Failed to parse Date value '2025-03-03T14:25:12.722942905+01:00': Can not parse date "2025-03-03T14:25:12.722942905+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) at org.testcontainers.shaded.com.github.dockerjava.core.exec.InspectNetworkCmdExec.execute(InspectNetworkCmdExec.java:26) at org.testcontainers.shaded.com.github.dockerjava.core.exec.InspectNetworkCmdExec.execute(InspectNetworkCmdExec.java:12) at org.testcontainers.shaded.com.github.dockerjava.core.exec.AbstrSyncDockerCmdExec.exec(AbstrSyncDockerCmdExec.java:21) at org.testcontainers.shaded.com.github.dockerjava.core.command.AbstrDockerCmd.exec(AbstrDockerCmd.java:33) at org.testcontainers.shaded.com.github.dockerjava.core.command.InpectNetworkCmdImpl.exec(InpectNetworkCmdImpl.java:7) at org.testcontainers.dockerclient.DockerClientProviderStrategy.resolveDockerHostIpAddress(DockerClientProviderStrategy.java:453) at org.testcontainers.dockerclient.DockerClientProviderStrategy.getDockerHostIpAddress(DockerClientProviderStrategy.java:424) at org.testcontainers.DockerClientFactory.client(DockerClientFactory.java:208) at org.testcontainers.DockerClientFactory$1.getDockerClient(DockerClientFactory.java:108) at com.github.dockerjava.api.DockerClientDelegate.authConfig(DockerClientDelegate.java:109) at org.testcontainers.containers.GenericContainer.start(GenericContainer.java:321) at org.testcontainers.lifecycle.Startable$start.call(Unknown Source)

@kiview
Copy link
Member

kiview commented Apr 4, 2025

As @eddumelendez pointed out above, can someone please share a minimal reproducer?
I would like to understand if this comes through a combination of different dependencies leading to weird Jackson version mixes, or if it originates from Docker Engine or Kernel versions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
resolution/waiting-for-info Waiting for more information of the issue author or another 3rd party. type/bug
Projects
None yet
Development

No branches or pull requests

8 participants