Skip to content

Commit

Permalink
Avoid indirectory relying on commons-lang3.
Browse files Browse the repository at this point in the history
Not all versions of `MutableInt` have the `decrementAndGet` method.
Using it can thus lead to `NoSuchMethodError` at runtime.
To work around this, we just create our own very minimal Counter class,
which has just the two methods that we actually need, and nothing more.
  • Loading branch information
chrisvest committed Apr 5, 2018
1 parent c632588 commit f520f1b
Showing 1 changed file with 17 additions and 4 deletions.
Expand Up @@ -19,14 +19,27 @@
*/
package org.neo4j.kernel.impl.pagecache;

import org.apache.commons.lang3.mutable.MutableInt;

import java.util.HashMap;
import java.util.Map;

class ProfileRefCounts
{
private final Map<Profile,MutableInt> bag;
private static class Counter
{
private int count;

void increment()
{
count++;
}

int decrementAndGet()
{
return --count;
}
}

private final Map<Profile,Counter> bag;

ProfileRefCounts()
{
Expand All @@ -37,7 +50,7 @@ synchronized void incrementRefCounts( Profile[] profiles )
{
for ( Profile profile : profiles )
{
bag.computeIfAbsent( profile, p -> new MutableInt() ).increment();
bag.computeIfAbsent( profile, p -> new Counter() ).increment();
}
}

Expand Down

0 comments on commit f520f1b

Please sign in to comment.