mirror of
https://github.com/TeamPiped/Piped-Backend.git
synced 2025-04-29 08:20:30 +05:30
Log pubsub failures.
This commit is contained in:
parent
cf9d1cd8cf
commit
b8c6fbf9b1
@ -20,7 +20,7 @@ public class Multithreading {
|
||||
}
|
||||
|
||||
public static void runAsyncLimitedPubSub(final Runnable runnable) {
|
||||
esLimited.submit(runnable);
|
||||
esLimitedPubSub.submit(runnable);
|
||||
}
|
||||
|
||||
public static ExecutorService getCachedExecutor() {
|
||||
|
@ -1,12 +1,14 @@
|
||||
package me.kavin.piped.utils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpRequest.BodyPublishers;
|
||||
import java.net.http.HttpRequest.Builder;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.net.http.HttpResponse.BodyHandlers;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
@ -22,6 +24,7 @@ import javax.persistence.criteria.CriteriaBuilder;
|
||||
import javax.persistence.criteria.CriteriaQuery;
|
||||
import javax.persistence.criteria.Root;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||
import org.hibernate.Session;
|
||||
import org.json.JSONObject;
|
||||
@ -975,8 +978,9 @@ public class ResponseHelper {
|
||||
builder.method("POST",
|
||||
BodyPublishers.ofString(String.valueOf(formBody.substring(0, formBody.length() - 1))));
|
||||
|
||||
Constants.h2client.send(builder.build(), BodyHandlers.ofInputStream());
|
||||
HttpResponse<InputStream> resp = Constants.h2client.send(builder.build(), BodyHandlers.ofInputStream());
|
||||
|
||||
if (resp.statusCode() == 204) {
|
||||
if (pubsub == null)
|
||||
pubsub = new PubSub(channelId, System.currentTimeMillis());
|
||||
else
|
||||
@ -987,6 +991,9 @@ public class ResponseHelper {
|
||||
if (!s.getTransaction().isActive())
|
||||
s.getTransaction().begin();
|
||||
s.getTransaction().commit();
|
||||
} else
|
||||
System.out.println(
|
||||
"Failed to subscribe: " + resp.statusCode() + "\n" + IOUtils.toString(resp.body(), "UTF-8"));
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user