From 320d6a28b60873c8e8163b27ed1389978aed4ee6 Mon Sep 17 00:00:00 2001 From: Luck Date: Sun, 4 Nov 2018 01:05:41 +0000 Subject: some misc refactoring --- .../java/me/lucko/spark/common/command/modules/HeapModule.java | 8 +++++--- .../java/me/lucko/spark/common/command/modules/SamplerModule.java | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) (limited to 'spark-common/src/main/java/me/lucko/spark/common/command') diff --git a/spark-common/src/main/java/me/lucko/spark/common/command/modules/HeapModule.java b/spark-common/src/main/java/me/lucko/spark/common/command/modules/HeapModule.java index 8752443..318ce25 100644 --- a/spark-common/src/main/java/me/lucko/spark/common/command/modules/HeapModule.java +++ b/spark-common/src/main/java/me/lucko/spark/common/command/modules/HeapModule.java @@ -23,13 +23,15 @@ package me.lucko.spark.common.command.modules; import me.lucko.spark.common.SparkPlatform; import me.lucko.spark.common.command.Command; import me.lucko.spark.common.command.CommandModule; -import me.lucko.spark.common.http.Bytebin; import me.lucko.spark.memory.HeapDump; +import okhttp3.MediaType; + import java.io.IOException; import java.util.function.Consumer; public class HeapModule implements CommandModule { + private static final MediaType JSON_TYPE = MediaType.parse("application/json; charset=utf-8"); @Override public void registerCommands(Consumer> consumer) { @@ -50,9 +52,9 @@ public class HeapModule implements CommandModule { byte[] output = heapDump.formCompressedDataPayload(); try { - String pasteId = Bytebin.postCompressedContent(output); + String key = SparkPlatform.BYTEBIN_CLIENT.postGzippedContent(output, JSON_TYPE); platform.sendPrefixedMessage("&bHeap dump output:"); - platform.sendLink(SparkPlatform.VIEWER_URL + pasteId); + platform.sendLink(SparkPlatform.VIEWER_URL + key); } catch (IOException e) { platform.sendPrefixedMessage("&cAn error occurred whilst uploading the data."); e.printStackTrace(); diff --git a/spark-common/src/main/java/me/lucko/spark/common/command/modules/SamplerModule.java b/spark-common/src/main/java/me/lucko/spark/common/command/modules/SamplerModule.java index 693ffd9..5fd8b5b 100644 --- a/spark-common/src/main/java/me/lucko/spark/common/command/modules/SamplerModule.java +++ b/spark-common/src/main/java/me/lucko/spark/common/command/modules/SamplerModule.java @@ -25,13 +25,14 @@ import me.lucko.spark.common.command.Command; import me.lucko.spark.common.command.CommandModule; import me.lucko.spark.common.command.tabcomplete.CompletionSupplier; import me.lucko.spark.common.command.tabcomplete.TabCompleter; -import me.lucko.spark.common.http.Bytebin; import me.lucko.spark.sampler.Sampler; import me.lucko.spark.sampler.SamplerBuilder; import me.lucko.spark.sampler.ThreadDumper; import me.lucko.spark.sampler.ThreadGrouper; import me.lucko.spark.sampler.TickCounter; +import okhttp3.MediaType; + import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; @@ -42,6 +43,7 @@ import java.util.concurrent.TimeUnit; import java.util.function.Consumer; public class SamplerModule implements CommandModule { + private static final MediaType JSON_TYPE = MediaType.parse("application/json; charset=utf-8"); /** Guards {@link #activeSampler} */ private final Object[] activeSamplerMutex = new Object[0]; @@ -236,9 +238,9 @@ public class SamplerModule implements CommandModule { platform.runAsync(() -> { byte[] output = sampler.formCompressedDataPayload(); try { - String pasteId = Bytebin.postCompressedContent(output); + String key = SparkPlatform.BYTEBIN_CLIENT.postGzippedContent(output, JSON_TYPE); platform.sendPrefixedMessage("&bSampling results:"); - platform.sendLink(SparkPlatform.VIEWER_URL + pasteId); + platform.sendLink(SparkPlatform.VIEWER_URL + key); } catch (IOException e) { platform.sendPrefixedMessage("&cAn error occurred whilst uploading the results."); e.printStackTrace(); -- cgit