Hacktoberfest 2026: as issues que os mantenedores marcaram para outubro, abertas e boas para iniciantes. Ver issues do Hacktoberfest

[Bug]: LoggedPullImageResultCallback throws java.lang.ArithmeticException: / by zero

Aberta
#11,416 1 comentário 2 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

@arimu1 já está trabalhando nisso.

Desde 29/7/2026.

  • #11953 de @arimu1 — aberto

Avaliação

Dificuldade
2/5
Tempo estimado
1-3 horas
Facilidade para iniciantes
58/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Estagnada
Stack de tecnologia
docker, java
Domínio
testing-qa

Direção de pesquisa

Comece em core/src/main/java/org/testcontainers/images/LoggedPullImageResultCallback.java, especialmente no cálculo da duração em torno das linhas 113 e 121 e no método onComplete. Revise as convenções existentes de testes do Core, adicione cobertura para um pull concluído em menos de um segundo e execute os testes relevantes do Core para confirmar que a conclusão não lança mais ArithmeticException.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

type/bug
Module

Core

Testcontainers version

1.21.3

Using the latest Testcontainers version?

Yes

Host OS

Linux

Host Arch

x86

Docker version
Docker Client 28.0.4
Docker Server 28.0.4
What happened?

When running tests in GitHub actions, it fails due to line 121 in LoggedPullImageResultCallback throws an java.lang.ArithmeticException: / by zero. Out of 10 times running our tests, it has failed 8 times and succeeded2. I have not been able to reproduce this in a reliable way but it seems like this would happen if a pull takes less than one full second since duration will become 0.

My first hypothesis was that this could happen if one already pulled the image in question but it seems that if the image is found locally, completed will never be set to true and therefore the line that throws the exception will never be executed.

Our current hypothesis is that there could be a race condition if a pull of an image is triggered twice. So just before the first pull invocation completes, another process triggers a pull. It's not fully found locally so we'll enter the "pull flow" but just at the last second, causing it to complete less in less than a second and trigger this issue.

If my hypothesis is correct it's hard to reliably create a way to replicate this but I think it would be worth it to be a bit more defensive in this part of the code and not throw an exception if it happens that a pull takes less than a second.

Relevant log output
OurTestClass > initializationError FAILED
    org.opentest4j.AssertionFailedError: failed to start service!
        at app//xx.xxxxxx.ourlibrary.integrationtests.IntegrationTestPostProcessor.postProcessTestInstance(IntegrationTestPostProcessor.java:112)
        at [email protected]/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184)
        at [email protected]/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
        at [email protected]/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179)
        at [email protected]/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
        at [email protected]/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1708)
        at [email protected]/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
        at [email protected]/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
        at [email protected]/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151)
        at [email protected]/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174)
        at [email protected]/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
        at [email protected]/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596)
        at [email protected]/java.util.Optional.orElseGet(Optional.java:364)
        at [email protected]/java.util.ArrayList.forEach(ArrayList.java:1596)

        Caused by:
        java.lang.ArithmeticException: / by zero
            at org.testcontainers.images.LoggedPullImageResultCallback.onComplete(LoggedPullImageResultCallback.java:120)
            at org.testcontainers.images.TimeLimitedLoggedPullImageResultCallback.onComplete(TimeLimitedLoggedPullImageResultCallback.java:91)
            at xx.xxxxxx.ourlibrary.integrationtests.testcontainers.ReactivePullImageResultCallback.onComplete(ReactivePullImageResultCallback.java:17)
            at org.testcontainers.shaded.com.github.dockerjava.core.exec.AbstrAsyncDockerCmdExec$1.onComplete(AbstrAsyncDockerCmdExec.java:51)
            at org.testcontainers.shaded.com.github.dockerjava.core.DefaultInvocationBuilder.lambda$executeAndStream$1(DefaultInvocationBuilder.java:276)
            at java.base/java.lang.Thread.run(Thread.java:1583)
Additional Information

No response

Linguagem predominante
Java
Estrelas
8.7k
Forks
1.9k
Merge médio
20h 43min
PRs com merge (30d)
4

Preparar o ambiente

Abrir no Codespaces

Inicia o contêiner de desenvolvimento do projeto no navegador, com a sua própria conta do GitHub.

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de testcontainers/testcontainers-java

Todas as issues de testcontainers/testcontainers-java

Issues semelhantes

Mais issues de Java

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.