Skip to content

Commit

Permalink
feat: refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
MiguelAHM committed Jan 14, 2025
1 parent 359b45f commit c092bea
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,12 @@ private IpEntry searchFirstLessSpecific(final IpTree ipTree, final IpInterval se
}

private IpEntry searchTopLevelResource(final IpTree ipTree, final IpInterval searchIp){
IpEntry ipEntry;
try {
ipEntry = searchFirstLessSpecific(ipTree, searchIp);
IpEntry ipEntry = searchFirstLessSpecific(ipTree, searchIp);
return loopUpLevels(ipTree, ipEntry);
} catch (RdapException ex){
throw new RdapException("404 Not Found", "No top-level object has been found for " + searchIp.toString(), HttpStatus.NOT_FOUND_404);
}

return loopUpLevels(ipTree, ipEntry);
}

private IpEntry loopUpLevels(final IpTree ipTree, IpEntry searchIp) {
Expand All @@ -162,7 +160,7 @@ private IpEntry loopUpLevels(final IpTree ipTree, IpEntry searchIp) {
private boolean existAndNoAdministrative(final IpInterval searchIp, final IpEntry firstLessSpecific){
final RpslObject children = getResourceByKey(searchIp.toString());
final RpslObject rpslObject = getResourceByKey(firstLessSpecific.getKey().toString());
if (rpslObject == null || isAdministrativeResource(children, rpslObject)) {
if (children == null || rpslObject == null || isAdministrativeResource(children, rpslObject)) {
LOGGER.debug("INET(6)NUM {} does not exist in RIPE Database ", firstLessSpecific.getKey().toString());
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,12 +233,7 @@ private List<InternalNode<K, V>> internalFindFirstMoreSpecific(K range) {
}

private List<InternalNode<K, V>> internalFindMostSpecific(K range){
final List<InternalNode<K, V>> result = internalFindAllMoreSpecific(range);
if (result.isEmpty()){
return Lists.newArrayList();
}

return result.parallelStream()
return internalFindAllMoreSpecific(range).parallelStream()
.filter( kvInternalNode -> kvInternalNode.getChildren().isEmpty())
.toList();
}
Expand Down

0 comments on commit c092bea

Please sign in to comment.