Merge pull request #502 from UniquePassive/screenshot-resleak
screenshot plugin: fix okhttp resource leak on imgur upload
This commit is contained in:
@@ -430,21 +430,23 @@ public class ScreenshotPlugin extends Plugin
|
|||||||
@Override
|
@Override
|
||||||
public void onResponse(Call call, Response response) throws IOException
|
public void onResponse(Call call, Response response) throws IOException
|
||||||
{
|
{
|
||||||
InputStream in = response.body().byteStream();
|
try (InputStream in = response.body().byteStream())
|
||||||
ImageUploadResponse imageUploadResponse = RuneLiteAPI.GSON
|
|
||||||
.fromJson(new InputStreamReader(in), ImageUploadResponse.class);
|
|
||||||
|
|
||||||
if (imageUploadResponse.isSuccess())
|
|
||||||
{
|
{
|
||||||
String link = imageUploadResponse.getData().getLink();
|
ImageUploadResponse imageUploadResponse = RuneLiteAPI.GSON
|
||||||
|
.fromJson(new InputStreamReader(in), ImageUploadResponse.class);
|
||||||
|
|
||||||
StringSelection selection = new StringSelection(link);
|
if (imageUploadResponse.isSuccess())
|
||||||
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
|
|
||||||
clipboard.setContents(selection, selection);
|
|
||||||
|
|
||||||
if (config.notifyWhenTaken())
|
|
||||||
{
|
{
|
||||||
notifier.notify("A screenshot was uploaded and inserted into your clipboard!", TrayIcon.MessageType.INFO);
|
String link = imageUploadResponse.getData().getLink();
|
||||||
|
|
||||||
|
StringSelection selection = new StringSelection(link);
|
||||||
|
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
|
||||||
|
clipboard.setContents(selection, selection);
|
||||||
|
|
||||||
|
if (config.notifyWhenTaken())
|
||||||
|
{
|
||||||
|
notifier.notify("A screenshot was uploaded and inserted into your clipboard!", TrayIcon.MessageType.INFO);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user