peter-lawrey/Java-Thread-Affinity — Issue #19: ArrayIndexOutOfBoundsException during 
Author: akerbos
Created: 2012-03-01 16:16:54+00:00
State: open

Under certain circumstances, `AffinityStrategy#matches` is called with `-1` in one of the parameters. This causes `cpuLayout.socketId` to fail.

When this occurred, the native library was missing and I did not have `ANY` as last strategy. I do not know wether this is of import.

From looking in the code, it seems as if `-1` is used to encode "no suitable core found". It is then used as "last assigned core" which is compared with all possible new cores, leading to the error.

Possible fix:

* Always assign an arbitrary core if the last was `-1`
* Do not store `-1` as last but the last index greater `0` (if any)