From 99e1b7a06262aae2d5f48cf4061d9096abac1acb Mon Sep 17 00:00:00 2001 From: Ksenia Solnyshko Date: Thu, 27 Jun 2024 00:45:24 +0300 Subject: [PATCH] Codeclimate --- .../ru/vk/itmo/test/solnyshkoksenia/MergeRangeResult.java | 2 +- .../java/ru/vk/itmo/test/solnyshkoksenia/MyHttpServer.java | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/ru/vk/itmo/test/solnyshkoksenia/MergeRangeResult.java b/src/main/java/ru/vk/itmo/test/solnyshkoksenia/MergeRangeResult.java index 285164826..dd5f0ef00 100644 --- a/src/main/java/ru/vk/itmo/test/solnyshkoksenia/MergeRangeResult.java +++ b/src/main/java/ru/vk/itmo/test/solnyshkoksenia/MergeRangeResult.java @@ -13,7 +13,7 @@ import java.util.List; import java.util.NoSuchElementException; -public class MergeRangeResult { +public final class MergeRangeResult { private static final Comparator comparator = new MemorySegmentComparator(); private MergeRangeResult() { diff --git a/src/main/java/ru/vk/itmo/test/solnyshkoksenia/MyHttpServer.java b/src/main/java/ru/vk/itmo/test/solnyshkoksenia/MyHttpServer.java index 3a27e2d53..f8a2c5df4 100644 --- a/src/main/java/ru/vk/itmo/test/solnyshkoksenia/MyHttpServer.java +++ b/src/main/java/ru/vk/itmo/test/solnyshkoksenia/MyHttpServer.java @@ -150,7 +150,8 @@ private void sendLocalRange(CustomHttpSession session, String start, String end) } private void sendClusterRange(CustomHttpSession session, Request request, String start, String end) { - List> responses = getResponses(request, config.clusterUrls(), request.getURI().replace("&cluster=1", ""), + List> responses = getResponses(request, config.clusterUrls(), + request.getURI().replace("&cluster=1", ""), responseInfo -> new CustomSubscriber()); Iterator> localIterator = invokeLocalRange(start, end); @@ -312,8 +313,8 @@ private static Response getBestResponse(List responses) { Response bestResp = responses.getFirst(); for (int i = 1; i < responses.size(); i++) { String bestRespTime = bestResp.getHeader(HEADER_TIMESTAMP_HEADER); - if (responses.get(i).getHeader(HEADER_TIMESTAMP) != null && (bestRespTime == null || - Long.parseLong(responses.get(i).getHeader(HEADER_TIMESTAMP_HEADER)) + if (responses.get(i).getHeader(HEADER_TIMESTAMP) != null && (bestRespTime == null + || Long.parseLong(responses.get(i).getHeader(HEADER_TIMESTAMP_HEADER)) > Long.parseLong(bestRespTime))) { bestResp = responses.get(i); }