From e79d9377489967e54709fd1162663e60615d6f71 Mon Sep 17 00:00:00 2001 From: Andy Clement Date: Thu, 27 Jun 2013 08:25:23 -0700 Subject: [PATCH] Fix issue#12: NPE when multiple threads allocating ID --- .../src/main/java/org/springsource/loaded/NameRegistry.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/org.springsource.loaded/src/main/java/org/springsource/loaded/NameRegistry.java b/org.springsource.loaded/src/main/java/org/springsource/loaded/NameRegistry.java index 4976634..57da77c 100644 --- a/org.springsource.loaded/src/main/java/org/springsource/loaded/NameRegistry.java +++ b/org.springsource.loaded/src/main/java/org/springsource/loaded/NameRegistry.java @@ -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; }