[ https://issues.apache.org/jira/browse/ZOOKEEPER-3415?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16856900#comment-16856900 ]
Brian Nixon commented on ZOOKEEPER-3415: ---------------------------------------- As an example: {code:java} +++ b/zookeeper-server/src/main/java/org/apache/zookeeper/server/ZooKeeperServer.java @@ -37,6 +37,7 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicLong; import java.util.function.BiConsumer; +import java.util.stream.Collectors; import javax.security.sasl.SaslException; @@ -383,17 +384,9 @@ public void loadData() throws IOException, InterruptedException { } // Clean up dead sessions - List<Long> deadSessions = new ArrayList<>(); - for (Long session : zkDb.getSessions()) { - if (zkDb.getSessionWithTimeOuts().get(session) == null) { - deadSessions.add(session); - } - } - - for (long session : deadSessions) { - // XXX: Is lastProcessedZxid really the best thing to use? - killSession(session, zkDb.getDataTreeLastProcessedZxid()); - } + zkDb.getSessions().stream() + .filter(session -> zkDb.getSessionWithTimeOuts().get(session) == null) + .forEach(session -> killSession(session, zkDb.getDataTreeLastProcessedZxid())); // Make a clean snapshot takeSnapshot(); {code} > convert internal logic to use java 8 streams > -------------------------------------------- > > Key: ZOOKEEPER-3415 > URL: https://issues.apache.org/jira/browse/ZOOKEEPER-3415 > Project: ZooKeeper > Issue Type: Wish > Affects Versions: 3.6.0 > Reporter: Brian Nixon > Priority: Trivial > > There are a number of places in the code where for loops are used to perform > basic filtering and collection. The java 8 stream api's make these operations > much more polished. Since the master branch has been at this language level > for a while, I'd wish for a (series of) refactor(s) to convert more of these > loops to streams. -- This message was sent by Atlassian JIRA (v7.6.3#76005)