MeltwaterArchive/rabbit-puppy

NPE when arguments not specified

ottfro opened this issue · 2 comments

Running

users:
    guest:
        password: guest
        admin: true

vhosts:
    docservice:

permissions:
    guest@docservice:
        configure: .*
        write: .*
        read: .*

exchanges:
    data.out@docservice:
        type: topic

queues:
    to-data@docservice

bindings:
    data.out@docservice:
      - destination: to-data
        destination_type: queue
        routing_key: "#.#.#.#.#.validdate"

results in:

08:45:57.207 [main] INFO  c.m.p.Main - Reading configuration from /config/rabbitcfg.yaml
08:45:57.668 [main] INFO  c.m.p.RabbitPuppy - Broker not available, waiting...
08:45:58.686 [main] INFO  c.m.p.RabbitPuppy - Broker not available, waiting...
08:45:59.770 [main] INFO  c.m.p.RabbitPuppy - Creating vhost docservice
08:45:59.952 [main] INFO  c.m.p.RabbitPuppy - Setting permissions for user guest at vhost docservice
08:45:59.995 [main] INFO  c.m.p.RabbitPuppy - Creating exchange data.out at vhost docservice with configuration ExchangeData(type=topic, durable=true, auto_delete=false, internal=false, arguments={})
08:46:00.028 [main] INFO  c.m.p.RabbitPuppy - Creating queue to-data at vhost docservice with configuration QueueData(durable=true, auto_delete=false, arguments={})
08:46:00.101 [main] INFO  c.m.p.RabbitPuppy - Ensuring binding data.out@docservice BindingData(destination=to-data, destination_type=queue, routing_key=#.#.#.#.#.validdate, arguments=null)
08:46:00.102 [main] INFO  c.m.p.RabbitPuppy - Creating binding data.out@docservice : BindingData(destination=to-data, destination_type=queue, routing_key=#.#.#.#.#.validdate, arguments=null)
Exception in thread "main" java.lang.NullPointerException: null value in entry: arguments=null
    at com.google.common.collect.CollectPreconditions.checkEntryNotNull(CollectPreconditions.java:33)
    at com.google.common.collect.ImmutableMap.entryOf(ImmutableMap.java:135)
    at com.google.common.collect.ImmutableMap.of(ImmutableMap.java:89)
    at com.meltwater.puppy.rest.RabbitRestClient.createBinding(RabbitRestClient.java:186)
    at com.meltwater.puppy.RabbitPuppy.lambda$null$12(RabbitPuppy.java:255)
    at java.util.ArrayList.forEach(ArrayList.java:1249)
    at com.meltwater.puppy.RabbitPuppy.lambda$createBindings$13(RabbitPuppy.java:250)
    at java.util.LinkedHashMap$LinkedEntrySet.forEach(LinkedHashMap.java:663)
    at com.meltwater.puppy.RabbitPuppy.createBindings(RabbitPuppy.java:237)
    at com.meltwater.puppy.RabbitPuppy.apply(RabbitPuppy.java:83)
    at com.meltwater.puppy.Main.run(Main.java:64)
    at com.meltwater.puppy.Main.main(Main.java:50)

We've settled on not allowing null maps, instead you should explicitly specify an empty map like so:

vhosts:
    docservice: {}

queues:
    to-data@docservice: {}
vorce commented

Maybe we should add that as an example in the README