spring-loaded icon indicating copy to clipboard operation
spring-loaded copied to clipboard

spring-loaded fails against vert.x

Open forseti opened this issue 8 years ago • 0 comments

Hi Spring-Loaded Team,

I found an issue when testing spring-loaded against standalone vert.x app (on gradle using the application plugin)

I have a class Counter that implements vert.x's Handler:

public class Counter implements Handler {
    AtomicInteger count = new AtomicInteger()
    private final String id

    Counter(String id) {
        this.id = id
    }

    @Override
    void handle(event) {
        println "Counting ${id}: ${count.incrementAndGet() + 1000}"
    }
}

Then I have this Counter run within vert.x's Periodic and infinite while(true)

public static void main(String[] args)
......................
        // This does not work
        vertx.setPeriodic(1500, new Counter("With Vertx"))


        // This actually works
        Counter counter = new Counter("Without Vertx")
        while (true) {
            sleep(1500)
            counter.handle(null)
        }
.....................
}

So it goes roughly like this on console:

Counting With Vertx: 1001
Counting Without Vertx: 1001
Counting With Vertx: 1001
Counting Without Vertx: 1001

After I change 1000 to 10000 in the Counter's output

        println "Counting ${id}: ${count.incrementAndGet() + 10000}"

The Counter that runs inside vert.x does not reload

Counting Without Vertx: 10022
Counting Without Vertx: 10023

I attached the project for inspection.

micro-app.zip

Thanks!!

Regards,

Donny

forseti avatar May 01 '16 12:05 forseti