Skip to content

Commit b2d8695

Browse files
committed
Version 6.3.4
Site updated: - Removed MYTHICALBOTS_XYZ Improve logging of empty/null Body
1 parent 79a191f commit b2d8695

File tree

3 files changed

+40
-21
lines changed

3 files changed

+40
-21
lines changed

build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ plugins{
99
id 'net.kyori.blossom' version '1.1.0'
1010
}
1111

12-
def ver = new Version(major: 6, minor: 3, patch: 3)
12+
def ver = new Version(major: 6, minor: 3, patch: 4)
1313

1414
allprojects {
1515
apply plugin: 'com.jfrog.bintray'
@@ -52,7 +52,7 @@ allprojects {
5252
jDocConfig.options {
5353
it.author()
5454
it.encoding = 'UTF-8'
55-
it.memberLevel = JavadocMemberLevel.PROTECTED
55+
it.memberLevel = JavadocMemberLevel.PUBLIC
5656

5757
if (it instanceof StandardJavadocDocletOptions) {
5858
def opt = it as StandardJavadocDocletOptions

core/src/main/java/org/botblock/javabotblockapi/core/Site.java

-13
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@
1818

1919
package org.botblock.javabotblockapi.core;
2020

21-
import org.botblock.javabotblockapi.core.annotations.DeprecatedSince;
22-
import org.botblock.javabotblockapi.core.annotations.PlannedRemoval;
23-
2421
import java.util.ArrayList;
2522
import java.util.Arrays;
2623
import java.util.List;
@@ -142,16 +139,6 @@ public class Site{
142139
*/
143140
public static final Site INFINITYBOTLIST_COM = new Site("infinitybotlist.com", HttpMethod.GET, HttpMethod.POST);
144141

145-
/**
146-
* <a href="https://mythicalbots.xyz" target="_blank">mythicalbots.xyz</a>
147-
*
148-
* @deprecated Renamed to {@link #BOTS_IDLEDEV_ORG bots.idledev.org}
149-
*/
150-
@Deprecated
151-
@DeprecatedSince(major = 6, minor = 3, patch = 2)
152-
@PlannedRemoval(major = 6, minor = 3, patch = 4)
153-
public static final Site MYTHICALBOTS_XYZ = new Site("mythicalbots.xyz");
154-
155142
/**
156143
* <a href="https://space-bot-list.xyz" target="_blank">space-bot-list.xyz</a>
157144
*/

request/src/main/java/org/botblock/javabotblockapi/requests/handler/RequestHandler.java

+38-6
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public void performPOST(@Nonnull JSONObject json, int sites) throws IOException{
115115
CheckUtil.condition(sites < 1, "The POST action requires at least 1 site!");
116116

117117
String url = BASE_URL + "count";
118-
final long timeout = sites * 10;
118+
final long timeout = sites * 10L;
119119

120120
OkHttpClient postClient = CLIENT.newBuilder()
121121
.callTimeout(timeout, TimeUnit.SECONDS)
@@ -135,12 +135,26 @@ public void performPOST(@Nonnull JSONObject json, int sites) throws IOException{
135135
ResponseBody responseBody = response.body();
136136
if(responseBody == null){
137137
LOG.error("Received empty Response from BotBlock API!");
138+
LOG.error(
139+
"Response{protocol={}, code={}, message={}, headers={}}",
140+
response.protocol(),
141+
response.code(),
142+
response.message(),
143+
response.headers().toString()
144+
);
138145
return;
139146
}
140147

141148
String bodyString = responseBody.string();
142149
if(bodyString.isEmpty()){
143150
LOG.error("Received empty Response from BotBlock API!");
151+
LOG.error(
152+
"Response{protocol={}, code={}, message={}, headers={}}",
153+
response.protocol(),
154+
response.code(),
155+
response.message(),
156+
response.headers().toString()
157+
);
144158
return;
145159
}
146160

@@ -171,7 +185,7 @@ public void performPOST(@Nonnull JSONObject json, int sites) throws IOException{
171185
}
172186
}
173187

174-
LOG.warn("One or more post requests returned a non-successful response. JSON with failed sites below.");
188+
LOG.warn("One or more POST requests returned a non-successful response. JSON with failed sites below.");
175189
LOG.warn(failures.toString());
176190
}
177191
}
@@ -189,12 +203,30 @@ private JSONObject performGET(@Nonnull String url, String header) throws IOExcep
189203

190204
try(Response response = CLIENT.newCall(request).execute()){
191205
ResponseBody body = response.body();
192-
if(body == null)
193-
throw new NullPointerException("Received empty response body.");
206+
if(body == null){
207+
LOG.error("Received empty Response from BotBlock API!");
208+
LOG.error(
209+
"Response{protocol={}, code={}, message={}, headers={}}",
210+
response.protocol(),
211+
response.code(),
212+
response.message(),
213+
response.headers().toString()
214+
);
215+
return null;
216+
}
194217

195218
String bodyString = body.string();
196-
if(bodyString.isEmpty())
197-
throw new NullPointerException("Received empty response body.");
219+
if(bodyString.isEmpty()){
220+
LOG.error("Received empty Response from BotBlock API!");
221+
LOG.error(
222+
"Response{protocol={}, code={}, message={}, headers={}}",
223+
response.protocol(),
224+
response.code(),
225+
response.message(),
226+
response.headers().toString()
227+
);
228+
return null;
229+
}
198230

199231
if(!response.isSuccessful()){
200232
if(response.code() == 429){

0 commit comments

Comments
 (0)