From 2201b1a506bb08faaf217911ad642ff81fbfe3b4 Mon Sep 17 00:00:00 2001 From: Viktor Lofgren Date: Fri, 23 Feb 2024 11:39:19 +0100 Subject: [PATCH] (refac) Clean up code issues --- .../model/src/main/java/nu/marginalia/model/EdgeDomain.java | 2 +- .../src/main/java/nu/marginalia/link_parser/LinkParser.java | 2 +- .../nu/marginalia/index/results/IndexMetadataService.java | 2 +- .../java/nu/marginalia/index/searchset/SearchSetsService.java | 2 +- .../nu/marginalia/control/sys/model/ProcessHeartbeat.java | 4 +--- .../java/nu/marginalia/control/sys/model/TaskHeartbeat.java | 4 +--- .../java/nu/marginalia/actor/task/ActorProcessWatcher.java | 4 ++++ 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/code/common/model/src/main/java/nu/marginalia/model/EdgeDomain.java b/code/common/model/src/main/java/nu/marginalia/model/EdgeDomain.java index 0686a9ce..86c17824 100644 --- a/code/common/model/src/main/java/nu/marginalia/model/EdgeDomain.java +++ b/code/common/model/src/main/java/nu/marginalia/model/EdgeDomain.java @@ -127,7 +127,7 @@ public class EdgeDomain implements Serializable { ret.append(topDomain, 0, cutPoint); } - if (!"".equals(subDomain) && !"www".equals(subDomain)) { + if (!subDomain.isEmpty() && !"www".equals(subDomain)) { ret.append(":"); ret.append(subDomain); } diff --git a/code/features-crawl/link-parser/src/main/java/nu/marginalia/link_parser/LinkParser.java b/code/features-crawl/link-parser/src/main/java/nu/marginalia/link_parser/LinkParser.java index 08ccc221..652eab8d 100644 --- a/code/features-crawl/link-parser/src/main/java/nu/marginalia/link_parser/LinkParser.java +++ b/code/features-crawl/link-parser/src/main/java/nu/marginalia/link_parser/LinkParser.java @@ -209,7 +209,7 @@ public class LinkParser { } private boolean isUrlRelevant(String href) { - if (null == href || "".equals(href)) { + if (null == href || href.isEmpty()) { return false; } if (href.length() > 128) { diff --git a/code/index/src/main/java/nu/marginalia/index/results/IndexMetadataService.java b/code/index/src/main/java/nu/marginalia/index/results/IndexMetadataService.java index 5b082efe..5b8df400 100644 --- a/code/index/src/main/java/nu/marginalia/index/results/IndexMetadataService.java +++ b/code/index/src/main/java/nu/marginalia/index/results/IndexMetadataService.java @@ -56,7 +56,7 @@ public class IndexMetadataService { continue; } - long id = searchTermsUtil.getWordId(term); + long id = SearchTermsUtil.getWordId(term); termIdsList.add(id); termToId.put(term, id); } diff --git a/code/index/src/main/java/nu/marginalia/index/searchset/SearchSetsService.java b/code/index/src/main/java/nu/marginalia/index/searchset/SearchSetsService.java index 317bc239..52c5ad89 100644 --- a/code/index/src/main/java/nu/marginalia/index/searchset/SearchSetsService.java +++ b/code/index/src/main/java/nu/marginalia/index/searchset/SearchSetsService.java @@ -93,7 +93,7 @@ public class SearchSetsService { return anySet; } - if ("NONE".equals(searchSetIdentifier) || "".equals(searchSetIdentifier)) { + if ("NONE".equals(searchSetIdentifier) || searchSetIdentifier.isEmpty()) { return anySet; } diff --git a/code/services-core/control-service/src/main/java/nu/marginalia/control/sys/model/ProcessHeartbeat.java b/code/services-core/control-service/src/main/java/nu/marginalia/control/sys/model/ProcessHeartbeat.java index 7cf5205d..f2911ad2 100644 --- a/code/services-core/control-service/src/main/java/nu/marginalia/control/sys/model/ProcessHeartbeat.java +++ b/code/services-core/control-service/src/main/java/nu/marginalia/control/sys/model/ProcessHeartbeat.java @@ -20,9 +20,7 @@ public record ProcessHeartbeat( } public String progressStyle() { if ("RUNNING".equals(status) && progress != null) { - return """ - background: linear-gradient(90deg, #ccc 0%%, #ccc %d%%, #fff %d%%) - """.formatted(progress, progress, progress); + return STR."background: linear-gradient(90deg, #ccc 0%, #ccc \{progress}%, #fff \{progress}%)"; } return ""; } diff --git a/code/services-core/control-service/src/main/java/nu/marginalia/control/sys/model/TaskHeartbeat.java b/code/services-core/control-service/src/main/java/nu/marginalia/control/sys/model/TaskHeartbeat.java index 467ae493..203d36be 100644 --- a/code/services-core/control-service/src/main/java/nu/marginalia/control/sys/model/TaskHeartbeat.java +++ b/code/services-core/control-service/src/main/java/nu/marginalia/control/sys/model/TaskHeartbeat.java @@ -21,9 +21,7 @@ public record TaskHeartbeat( public String progressStyle() { if ("RUNNING".equals(status) && progress != null) { - return """ - background: linear-gradient(90deg, #ccc 0%%, #ccc %d%%, #fff %d%%) - """.formatted(progress, progress, progress); + return STR."background: linear-gradient(90deg, #ccc 0%, #ccc \{progress}%, #fff \{progress}%)"; } return ""; } diff --git a/code/services-core/executor-service/src/main/java/nu/marginalia/actor/task/ActorProcessWatcher.java b/code/services-core/executor-service/src/main/java/nu/marginalia/actor/task/ActorProcessWatcher.java index 4bae8674..65d59f7e 100644 --- a/code/services-core/executor-service/src/main/java/nu/marginalia/actor/task/ActorProcessWatcher.java +++ b/code/services-core/executor-service/src/main/java/nu/marginalia/actor/task/ActorProcessWatcher.java @@ -39,6 +39,10 @@ public class ActorProcessWatcher { public MqMessage waitResponse(MqOutbox outbox, ProcessService.ProcessId processId, long msgId) throws ActorControlFlowException, InterruptedException, SQLException { + // enums values only have a single instance, + // so it's safe to synchronize on them + // even though it looks a bit weird to + // synchronize on a parameter like this: synchronized (processId) { // Wake up the process spawning actor processId.notifyAll();