arjun4084346 commented on code in PR #3536:
URL: https://github.com/apache/gobblin/pull/3536#discussion_r959027766
##########
gobblin-service/src/main/java/org/apache/gobblin/service/monitoring/GitFlowGraphMonitor.java:
##########
@@ -120,15 +119,19 @@ void processGitConfigChanges() throws GitAPIException,
IOException {
}
List<DiffEntry> changes = this.gitRepo.getChanges();
- Collections.sort(changes, (o1, o2) -> {
- Integer o1Depth = (o1.getNewPath() != null) ? (new
Path(o1.getNewPath())).depth() : (new Path(o1.getOldPath())).depth();
- Integer o2Depth = (o2.getNewPath() != null) ? (new
Path(o2.getNewPath())).depth() : (new Path(o2.getOldPath())).depth();
- return o1Depth.compareTo(o2Depth);
- });
+ Collections.sort(changes, new GitFlowgraphComparator());
processGitConfigChangesHelper(changes);
//Decrements the latch count. The countdown latch is initialized to 1. So
after the first time the latch is decremented,
// the following operation should be a no-op.
this.initComplete.countDown();
}
+ class GitFlowgraphComparator implements Comparator<DiffEntry> {
Review Comment:
This is good too. Another simple way would have been to create a static
field in the class
```private static Comparator comparator = (Comparator<DiffEntry>) (o1, o2)
-> {
Integer o1Depth = (o1.getNewPath() != null) ? (new
Path(o1.getNewPath())).depth() : (new Path(o1.getOldPath())).depth();
Integer o2Depth = (o2.getNewPath() != null) ? (new
Path(o2.getNewPath())).depth() : (new Path(o2.getOldPath())).depth();
return o1Depth.compareTo(o2Depth);
};```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]