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

listPublicIpAddresses NullPointerException on shared networks with a VR (4.22)

Aberta Para iniciantes
#14,248 0 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
2/5
Tempo estimado
1-3 horas
Facilidade para iniciantes
80/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Ativa
Stack de tecnologia
java
Domínio
api, backend

Direção de pesquisa

Comece em ApiResponseHelper.java, em showVmInfoForSharedNetworks(), concentrando-se no branch de rede não virtual e na busca da NIC. Compare o helper existente que ignora placeholders com o comportamento descrito em #8622 e #8624 e reproduza o problema fazendo chamadas repetidas a listPublicIpAddresses em uma rede compartilhada. O trabalho estará concluído quando a requisição não falhar mais intermitentemente com uma NullPointerException.

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

Descrição

bug
problem

On 4.22.1.0, listPublicIpAddresses with forvirtualnetwork=false sometimes fails with a 530:

2026-09-25 06:50:01,162 ERROR [c.c.a.ApiServer] (qtp2038105753-72330:[ctx-762cfe49, ctx-ac3b837a, ctx-e861c603]) (logid:e972f310) unhandled exception executing api command: [Ljava.lang.String;@4e95c7d5 java.lang.NullPointerException: Cannot invoke "java.lang.Long.longValue()" because "this.instanceId" is null
2026-09-25 06:50:01,165 INFO  [a.c.c.a.ApiServlet] (qtp2038105753-72330:[ctx-762cfe49, ctx-ac3b837a, ctx-e861c603]) (logid:e972f310) (userId=8 accountId=2 sessionId=null) 0:0:0:0:0:0:0:1 -- GET allocatedonly=false&apikey=<redacted>&command=listPublicIpAddresses&forvirtualnetwork=false&listall=true&page=1&pagesize=500&response=json&signature=<redacted> 530 Cannot invoke "java.lang.Long.longValue()" because "this.instanceId" is null

The same request succeeds on some attempts and fails on others.

It looks like the DomainRouter branch added to ApiResponseHelper.showVmInfoForSharedNetworks() in #10458 is hitting the VR's placeholder NIC, which has a null instance_id. Our shared network has two NIC rows for the VR's IP (the placeholder and the real one), and the NIC lookup can return either, which would explain why it's intermittent. It seems to be the same or a similar problem as #8622, which #8624 fixed for the system VM branch.

versions

ACS 4.22.1.0, KVM, advanced zone. The shared network offering uses VirtualRouter for DHCP, DNS and UserData.

The steps to reproduce the bug
  1. Create a shared network whose offering uses VirtualRouter for DHCP/DNS, and deploy a VM on it so the VR starts.
  2. As admin, call listPublicIpAddresses networkid= forvirtualnetwork=false a few times.
  3. Some calls fail with the NPE above.
What to do about it?

findNonPlaceHolderByIp4AddressAndNetworkId() looks to skip placeholder IP addresses, so should be able to change this line in ApiResponseHelper.java:

Change:

        if (!forVirtualNetworks) {
            NicVO nic = ApiDBUtils.findByIp4AddressAndNetworkId(ipAddr.getAddress().toString(), ipAddr.getNetworkId());

To:

        if (!forVirtualNetworks) {
            NicVO nic = ApiDBUtils.findNonPlaceHolderByIp4AddressAndNetworkId(ipAddr.getAddress().toString(), ipAddr.getNetworkId());
Linguagem predominante
Java
Estrelas
3.1k
Forks
1.4k
Merge médio
5d 15h
PRs com merge (30d)
24

Preparar o ambiente

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 apache/cloudstack

Todas as issues de apache/cloudstack

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.