Skip to content
Permalink
Browse files
CONFIGURATION-803 java8 lambda improvements (#112)
  • Loading branch information
arturobernalg committed Jun 26, 2021
1 parent 754b3b5 commit 33da480e63bb9d75674d219e8986ea013a2a6937
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 80 deletions.
@@ -739,15 +739,7 @@ private Map<String, Object> getFilteredParameters()
{
final Map<String, Object> filteredMap =
new HashMap<>(getParameters());
for (final Iterator<String> it = filteredMap.keySet().iterator(); it
.hasNext();)
{
final String key = it.next();
if (key.startsWith(BuilderParameters.RESERVED_PARAMETER_PREFIX))
{
it.remove();
}
}
filteredMap.keySet().removeIf(key -> key.startsWith(BuilderParameters.RESERVED_PARAMETER_PREFIX));
return filteredMap;
}

@@ -110,7 +110,7 @@
* {@code MultiFileConfigurationBuilder}.
*/
private final EventListener<ConfigurationBuilderEvent> managedBuilderDelegationListener =
event -> handleManagedBuilderEvent(event);
this::handleManagedBuilderEvent;

/**
* Creates a new instance of {@code MultiFileConfigurationBuilder} and sets
@@ -360,13 +360,7 @@ Operations fetchOperations(final ImmutableNode target, final int level)
final Integer nodeLevel =
Integer.valueOf(level == LEVEL_UNKNOWN ? level(target)
: level);
Map<ImmutableNode, Operations> levelOperations =
operations.get(nodeLevel);
if (levelOperations == null)
{
levelOperations = new HashMap<>();
operations.put(nodeLevel, levelOperations);
}
Map<ImmutableNode, Operations> levelOperations = operations.computeIfAbsent(nodeLevel, k -> new HashMap<>());
Operations ops = levelOperations.get(target);
if (ops == null)
{
@@ -104,26 +104,21 @@ public void testAppendWhileConcurrentAccess() throws InterruptedException
final AtomicBoolean stop = new AtomicBoolean();
final String property =
SystemConfiguration.class.getName() + ".testProperty";
final Thread t = new Thread()
{
@Override
public void run()
final Thread t = new Thread(() -> {
boolean setValue = true;
while (!stop.get())
{
boolean setValue = true;
while (!stop.get())
if (setValue)
{
System.setProperty(property, "true");
}
else
{
if (setValue)
{
System.setProperty(property, "true");
}
else
{
System.clearProperty(property);
}
setValue = !setValue;
System.clearProperty(property);
}
setValue = !setValue;
}
};
});
try
{
t.start();
@@ -1351,38 +1351,10 @@ public void testInitPropertiesMultiThreaded() throws InterruptedException
for (int i = 0; i < loops; i++)
{
final FileHandler handler = new FileHandler();
final Thread t1 = new Thread()
{
@Override
public void run()
{
handler.setFileSystem(fileSystem);
}
};
final Thread t2 = new Thread()
{
@Override
public void run()
{
handler.setFileName(TEST_FILENAME);
}
};
final Thread t3 = new Thread()
{
@Override
public void run()
{
handler.setEncoding(encoding);
}
};
final Thread t4 = new Thread()
{
@Override
public void run()
{
handler.setLocationStrategy(locationStrategy);
}
};
final Thread t1 = new Thread(() -> handler.setFileSystem(fileSystem));
final Thread t2 = new Thread(() -> handler.setFileName(TEST_FILENAME));
final Thread t3 = new Thread(() -> handler.setEncoding(encoding));
final Thread t4 = new Thread(() -> handler.setLocationStrategy(locationStrategy));
final List<Thread> threads = Arrays.asList(t1, t2, t3, t4);
for (final Thread t : threads)
{
@@ -657,23 +657,18 @@ public void testConcurrentUpdate() throws InterruptedException
for (int i = 0; i < threadCount; i++)
{
final String authorName = authorPrefix + i;
threads[i] = new Thread()
{
@Override
public void run()
threads[i] = new Thread(() -> {
try
{
try
{
latch.await();
model.addProperty(KEY,
Collections.singleton(authorName), resolver);
}
catch (final InterruptedException iex)
{
// ignore
}
latch.await();
model.addProperty(KEY,
Collections.singleton(authorName), resolver);
}
};
catch (final InterruptedException iex)
{
// ignore
}
});
threads[i].start();
}
latch.countDown();

0 comments on commit 33da480

Please sign in to comment.