package org.opencloudb.net;

import java.io.IOException;

public class NIOReactorPool {
	private final NIOReactor[] reactors;
	private volatile int nextReactor;

	public NIOReactorPool(String name, int poolSize) throws IOException {
		reactors = new NIOReactor[poolSize];
		for (int i = 0; i < poolSize; i++) {
			NIOReactor reactor = new NIOReactor(name + "-" + i);
			reactors[i] = reactor;
			reactor.startup();
		}
	}

	public NIOReactor getNextReactor() {
		if (++nextReactor == reactors.length) {
			nextReactor = 0;
		}
		return reactors[nextReactor];
	}
}

@@ -454,16 +454,18 @@
 tor() %7B%0A
+//
 %09%09if (++
@@ -498,16 +498,18 @@
 ngth) %7B%0A
+//
 %09%09%09nextR
@@ -520,20 +520,24 @@
 or = 0;%0A
+//
 %09%09%7D%0A
+//
 %09%09return
@@ -559,14 +559,151 @@
 eactor%5D;
+%0A%0A        int i = ++nextReactor;%0A        if (i %3E= reactors.length) %7B%0A            i=nextReactor = 0;%0A        %7D%0A        return reactors%5Bi%5D;
 %0A%09%7D%0A%7D%0A

fix NIOReactorPool 数组越界