From e548f25f2de683212ecf7faa2bf92b24b51ad402 Mon Sep 17 00:00:00 2001 From: 0xb00bface <0xboobface@gmail.com> Date: Sat, 9 Jan 2021 14:03:03 +0100 Subject: [PATCH] Remove some compiler and sonar warnings --- client/.classpath | 6 +++++- client/.settings/org.eclipse.jdt.core.prefs | 6 +++--- client/pom.xml | 4 ++-- .../jasmin/LiveJasminFollowedUpdateService.java | 14 ++++---------- .../sites/showup/ShowupFollowedUpdateService.java | 5 +++-- .../java/ctbrec/UnexpectedResponseException.java | 9 +++++++++ .../recorder/download/dash/DashDownload.java | 1 + 7 files changed, 27 insertions(+), 18 deletions(-) create mode 100644 common/src/main/java/ctbrec/UnexpectedResponseException.java diff --git a/client/.classpath b/client/.classpath index 0f3dcb1f..34bb78b4 100644 --- a/client/.classpath +++ b/client/.classpath @@ -11,7 +11,11 @@ - + + + + + diff --git a/client/.settings/org.eclipse.jdt.core.prefs b/client/.settings/org.eclipse.jdt.core.prefs index 335156c0..3b784bcd 100644 --- a/client/.settings/org.eclipse.jdt.core.prefs +++ b/client/.settings/org.eclipse.jdt.core.prefs @@ -1,9 +1,9 @@ eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate -org.eclipse.jdt.core.compiler.codegen.targetPlatform=12 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=15 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=12 +org.eclipse.jdt.core.compiler.compliance=15 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate @@ -13,4 +13,4 @@ org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning org.eclipse.jdt.core.compiler.release=disabled -org.eclipse.jdt.core.compiler.source=12 +org.eclipse.jdt.core.compiler.source=15 diff --git a/client/pom.xml b/client/pom.xml index c6aad92e..1857d6d4 100644 --- a/client/pom.xml +++ b/client/pom.xml @@ -14,8 +14,8 @@ UTF-8 - 11 - 11 + 15 + 15 ${project.groupId}-${project.version}-final diff --git a/client/src/main/java/ctbrec/ui/sites/jasmin/LiveJasminFollowedUpdateService.java b/client/src/main/java/ctbrec/ui/sites/jasmin/LiveJasminFollowedUpdateService.java index c183a9fc..452ea270 100644 --- a/client/src/main/java/ctbrec/ui/sites/jasmin/LiveJasminFollowedUpdateService.java +++ b/client/src/main/java/ctbrec/ui/sites/jasmin/LiveJasminFollowedUpdateService.java @@ -30,12 +30,10 @@ public class LiveJasminFollowedUpdateService extends PaginatedScheduledService { private static final Logger LOG = LoggerFactory.getLogger(LiveJasminFollowedUpdateService.class); private LiveJasmin liveJasmin; private String url; - private boolean showOnline = true; public LiveJasminFollowedUpdateService(LiveJasmin liveJasmin) { this.liveJasmin = liveJasmin; this.url = liveJasmin.getBaseUrl() + "/en/member/favorite"; - //this.url = liveJasmin.getBaseUrl() + "/en/free/favourite/get-favourite-list?_dc=" + ts; } @Override @@ -43,15 +41,15 @@ public class LiveJasminFollowedUpdateService extends PaginatedScheduledService { return new Task>() { @Override public List call() throws IOException { - if(!liveJasmin.credentialsAvailable()) { + if (!liveJasmin.credentialsAvailable()) { throw new NotLoggedInExcetion("Credentials missing"); } boolean loggedIn = SiteUiFactory.getUi(liveJasmin).login(); - if(!loggedIn) { - throw new RuntimeException("Couldn't login to livejasmin"); + if (!loggedIn) { + throw new NotLoggedInExcetion("Couldn't login to livejasmin"); } - //LOG.debug("Fetching page {}", url); + LOG.debug("Fetching page {}", url); Request request = new Request.Builder() .url(url) .header(USER_AGENT, Config.getInstance().getSettings().httpUserAgent) @@ -80,8 +78,4 @@ public class LiveJasminFollowedUpdateService extends PaginatedScheduledService { } }; } - - public void setShowOnline(boolean showOnline) { - this.showOnline = showOnline; - } } diff --git a/client/src/main/java/ctbrec/ui/sites/showup/ShowupFollowedUpdateService.java b/client/src/main/java/ctbrec/ui/sites/showup/ShowupFollowedUpdateService.java index 856cc00b..e3d6e4d0 100644 --- a/client/src/main/java/ctbrec/ui/sites/showup/ShowupFollowedUpdateService.java +++ b/client/src/main/java/ctbrec/ui/sites/showup/ShowupFollowedUpdateService.java @@ -14,6 +14,7 @@ import org.json.JSONObject; import ctbrec.Config; import ctbrec.Model; +import ctbrec.UnexpectedResponseException; import ctbrec.io.HttpException; import ctbrec.sites.showup.Showup; import ctbrec.sites.showup.ShowupModel; @@ -55,7 +56,7 @@ public class ShowupFollowedUpdateService extends PaginatedScheduledService { .filter(m -> onlineModels.containsKey(m.getName()) == showOnline) .collect(Collectors.toList()); } else { - throw new RuntimeException("Request was not successful: " + body); + throw new UnexpectedResponseException("Request was not successful: " + body); } } else { throw new HttpException(response.code(), response.message()); @@ -83,7 +84,7 @@ public class ShowupFollowedUpdateService extends PaginatedScheduledService { for (int i = 0; i < online.length(); i++) { JSONObject m = online.getJSONObject(i); String preview = site.getBaseUrl() + "/files/" + m.optString("big_img") + ".jpg"; - //onlineModels.put(m.optLong("uid"), preview); + onlineModels.put(String.valueOf(m.optLong("uid")), preview); } return onlineModels; } diff --git a/common/src/main/java/ctbrec/UnexpectedResponseException.java b/common/src/main/java/ctbrec/UnexpectedResponseException.java new file mode 100644 index 00000000..a06cecaf --- /dev/null +++ b/common/src/main/java/ctbrec/UnexpectedResponseException.java @@ -0,0 +1,9 @@ +package ctbrec; + +public class UnexpectedResponseException extends RuntimeException { + + public UnexpectedResponseException(String msg) { + super(msg); + } + +} diff --git a/common/src/main/java/ctbrec/recorder/download/dash/DashDownload.java b/common/src/main/java/ctbrec/recorder/download/dash/DashDownload.java index e28a6ba6..b8c1a8bf 100644 --- a/common/src/main/java/ctbrec/recorder/download/dash/DashDownload.java +++ b/common/src/main/java/ctbrec/recorder/download/dash/DashDownload.java @@ -276,6 +276,7 @@ public class DashDownload extends AbstractDownload { } } + @SuppressWarnings("deprecation") private boolean splitRecording() { if (config.getSettings().splitRecordings > 0) { Duration recordingDuration = Duration.between(splitRecStartTime, ZonedDateTime.now());