<jupyter_start><jupyter_text>Java Client Issue: Event Loop ExceptionReproducible case for event loop exception. How to get event loops working in the docker container?This notebook requires Aerospike datbase running on localhost. Visit [Aerospike notebooks repo](https://github.com/aerospike-examples/interactive-notebooks) for additional details and the docker container.  Ensure database is runningThis notebook requires that Aerospike datbase is running.<jupyter_code>import io.github.spencerpark.ijava.IJava;
import io.github.spencerpark.jupyter.kernel.magic.common.Shell;
IJava.getKernelInstance().getMagics().registerMagics(Shell.class);
%sh asd<jupyter_output><empty_output><jupyter_text>Download Aerospike client from POMHere the Java client version 5.0.0 is installed.<jupyter_code>%%loadFromPOM
<dependencies>
  <dependency>
    <groupId>com.aerospike</groupId>
    <artifactId>aerospike-client</artifactId>
    <version>5.0.0</version>
  </dependency>
   <dependency>
        <groupId>io.netty</groupId>
        <artifactId>netty-all</artifactId>
        <version>4.1.53.Final</version>
        <scope>compile</scope>
    </dependency>
</dependencies><jupyter_output><empty_output><jupyter_text>Connect to database and populate test dataThe test data has ten records with user-key "id1-10", two bins (fields) "bin1" and "bin2", in the namespace "test" and set "test_small".<jupyter_code>import com.aerospike.client.AerospikeClient;
import com.aerospike.client.Bin;
import com.aerospike.client.Key;
import com.aerospike.client.policy.WritePolicy;

AerospikeClient client = new AerospikeClient("localhost", 3000);
System.out.println("Initialized the client and connected to the cluster.");

String Namespace = "test";
String SmallSet = "test_small";

WritePolicy wpolicy = new WritePolicy();
wpolicy.sendKey = true;
for (int i = 1; i <= 10; i++) {
    Key key = new Key(Namespace, SmallSet, "id-"+i);
    Bin bin1 = new Bin(new String("bin1"), i);
    Bin bin2 = new Bin(new String("bin2"), 1000+i);
    client.put(wpolicy, key, bin1, bin2);
}

System.out.format("Test data popuated");;<jupyter_output>Initialized the client and connected to the cluster.
Test data popuated<jupyter_text>Issue: Event Loop Throws a Null Pointer Exception.Fails with the null pointer exception.   Using DIRECT_NIO<jupyter_code>// background execution
import io.netty.channel.EventLoopGroup;
import io.netty.channel.epoll.EpollEventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
import com.aerospike.client.async.EventLoop;
import com.aerospike.client.async.EventLoops;
import com.aerospike.client.async.EventPolicy;
import com.aerospike.client.async.NettyEventLoops;
import com.aerospike.client.async.NioEventLoops;
import com.aerospike.client.listener.RecordListener;
import com.aerospike.client.util.Util;
import com.aerospike.client.Record;
import com.aerospike.client.AerospikeException;

// a simple record listener - prints out the key and bins
public class MyRecordListener implements RecordListener {
    public void onSuccess(Key key, Record record) throws AerospikeException {
        System.out.format("set=%s key=%s bins=%s\n", key.setName, key.userKey, record.bins);
    }
    public void onFailure(AerospikeException e) {
        System.out.format("Query failed: " + Util.getErrorMessage(e));
    }
}

EventPolicy eventPolicy = new EventPolicy();
eventPolicy.maxCommandsInProcess = 10;
eventPolicy.maxCommandsInQueue = 10;

// direct nio
EventLoops eventLoops = new NioEventLoops(eventPolicy, 1);
EventLoop eventLoop = eventLoops.get(0);

//execute get in background
Key key = new Key(Namespace, SmallSet, "id-5");
client.get(eventLoop, new MyRecordListener(), null, key);<jupyter_output><empty_output><jupyter_text>Using NETTY_NIO<jupyter_code>EventLoopGroup group = new NioEventLoopGroup(1);
EventLoops eventLoops = new NettyEventLoops(eventPolicy, group);
EventLoop eventLoop = eventLoops.get(0);

//execute get in background
Key key = new Key(Namespace, SmallSet, "id-5");
client.get(eventLoop, new MyRecordListener(), null, key);<jupyter_output><empty_output><jupyter_text>Using NETTY_EPOLL<jupyter_code>EventLoopGroup group = new EpollEventLoopGroup(1);
EventLoops eventLoops = new NettyEventLoops(eventPolicy, group);
EventLoop eventLoop = eventLoops.get(0);

//execute get in background
Key key = new Key(Namespace, SmallSet, "id-5");
client.get(eventLoop, new MyRecordListener(), null, key);<jupyter_output><empty_output><jupyter_text>Clean up<jupyter_code>client.truncate(null, Namespace, null, null);
client.close();
System.out.println("Removed data and closed server connection.");<jupyter_output>Removed data and closed server connection.
{'fraction_non_alphanumeric': 0.11123017573939134, 'fraction_numerical': 0.00964423489069867, 'mean_word_length': 5.944940476190476, 'pattern_counts': {'":': 0, '<': 48, '<?xml version=': 0, '>': 47, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '639438', 'license': 'Apache-2.0', 'n_tokens_mistral': 1539, 'n_tokens_neox': 1464, 'n_words': 360, 'path': 'notebooks/java/eventloop-exception.ipynb', 'repo_name': 'artanderson/experiments', 'size': '4666'}