Fix issue#12: NPE when multiple threads allocating ID

This commit is contained in:
Andy Clement
2013-06-27 08:25:23 -07:00
parent efa169fb8d
commit e79d937748

View File

@@ -79,7 +79,7 @@ public class NameRegistry {
// Check again, in case two threads passed the -1 check in the getIdOrAllocateFor method
int id = getIdFor(slashedClassName);
if (id == -1) {
id = nextTypeId++;
id = nextTypeId;
if (nextTypeId >= allocatedIds.length) {
size = size + 10;
// need to make more room
@@ -88,6 +88,7 @@ public class NameRegistry {
allocatedIds = newAllocatedIds;
}
allocatedIds[id] = slashedClassName;
nextTypeId++; // increase at the end once the value has been set in the array
}
return id;
}