Skip to content
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

IScheduledExecutorService appears not to use HazelcastInstanceAware on local operations #9675

stevebarham opened this issue Jan 17, 2017 · 2 comments


None yet
3 participants
Copy link

commented Jan 17, 2017

Version: 3.8 EA

I've been using the IScheduledExecutorService which was added in Hazelcast 3.8. It appears that when operations are scheduled and executed on a single local node, that the HazelcastInstance does not get injected. An instance is injected if the task is submitted and executed on a remote node.

Sample reproduction case; console contains:

Testing via ExecutorService
Injected state: true
Testing via ScheduledExecutorService
Injected state: false


Testing via ExecutorService
Injected state: true
Testing via ScheduledExecutorService
Injected state: true

Test case:

import com.hazelcast.core.Hazelcast;
import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.core.HazelcastInstanceAware;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;

import static org.junit.Assert.assertTrue;

public class HazelcastInstanceAwareTest {
    HazelcastInstance instance;

    public void setup() {
        instance = Hazelcast.newHazelcastInstance();

    public void teardown() throws Exception {

    public void test() throws ExecutionException, InterruptedException {
        System.err.println("Testing via ExecutorService");
        assertTrue(instance.getExecutorService("foo").submit((Callable<Boolean>) new AwareRunnable()).get());

        System.err.println("Testing via ScheduledExecutorService");
        instance.getScheduledExecutorService("bar").scheduleAtFixedRate(new AwareRunnable(), 0, 5, TimeUnit.SECONDS);


    static class AwareRunnable implements Runnable, Callable<Boolean>, HazelcastInstanceAware, Serializable {
        private volatile HazelcastInstance instance;

        public void setHazelcastInstance(final HazelcastInstance instance) {
            this.instance = instance;

        public void run() {

        public Boolean call() {
            final boolean injected = (instance != null);
            System.err.println("Injected state: " + injected);
            return injected;

@jerrinot jerrinot added this to the 3.8 milestone Jan 17, 2017


This comment has been minimized.

Copy link

commented Jan 17, 2017

@stevebarham: good one, thanks for reporting it!


This comment has been minimized.

Copy link

commented Jan 19, 2017

Nice one, thanks all!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.