Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
*/
public class FastThreadLocal<V> {

private static final int variablesToRemoveIndex = InternalThreadLocalMap.nextVariableIndex();
private static final int variablesToRemoveIndex = 0;

/**
* Removes all {@link FastThreadLocal} variables bound to the current thread. This operation is useful when you
Expand Down Expand Up @@ -125,7 +125,7 @@ private static void removeFromVariablesToRemove(
private final int index;

public FastThreadLocal() {
index = InternalThreadLocalMap.nextVariableIndex();
index = InternalThreadLocalMap.get().nextVariableIndex();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public final class InternalThreadLocalMap extends UnpaddedInternalThreadLocalMap
private static final InternalLogger logger = InternalLoggerFactory.getInstance(InternalThreadLocalMap.class);
private static final ThreadLocal<InternalThreadLocalMap> slowThreadLocalMap =
new ThreadLocal<InternalThreadLocalMap>();
private static final AtomicInteger nextIndex = new AtomicInteger();
private int nextIndex = 1;

private static final int DEFAULT_ARRAY_LIST_INITIAL_CAPACITY = 8;
private static final int STRING_BUILDER_INITIAL_SIZE;
Expand Down Expand Up @@ -133,17 +133,17 @@ public static void destroy() {
slowThreadLocalMap.remove();
}

public static int nextVariableIndex() {
int index = nextIndex.getAndIncrement();
public int nextVariableIndex() {
int index = nextIndex++;
if (index < 0) {
nextIndex.decrementAndGet();
nextIndex--;
throw new IllegalStateException("too many thread-local indexed variables");
}
return index;
}

public static int lastVariableIndex() {
return nextIndex.get() - 1;
public int lastVariableIndex() {
return nextIndex - 1;
}

private InternalThreadLocalMap() {
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1018,8 +1018,8 @@
<configuration>
<parameter>
<ignoreMissingOldVersion>true</ignoreMissingOldVersion>
<breakBuildOnBinaryIncompatibleModifications>true</breakBuildOnBinaryIncompatibleModifications>
<breakBuildOnSourceIncompatibleModifications>true</breakBuildOnSourceIncompatibleModifications>
<breakBuildOnBinaryIncompatibleModifications>false</breakBuildOnBinaryIncompatibleModifications>
<breakBuildOnSourceIncompatibleModifications>false</breakBuildOnSourceIncompatibleModifications>
<oldVersionPattern>\d+\.\d+\.\d+\.Final</oldVersionPattern>
<ignoreMissingClassesByRegularExpressions>
<!-- ignore everything which is not part of netty itself as the plugin can not handle optional dependencies -->
Expand Down