Skip to content
This repository was archived by the owner on Jan 31, 2022. It is now read-only.

Commit 8ff1680

Browse files
committed
Code correction: Avoiding #GOTOFAIL
1 parent 4034a6c commit 8ff1680

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

algoliasearch/src/main/java/com/algolia/search/saas/BaseIndex.java

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,9 @@ protected JSONObject getObject(String objectID, List<String> attributesToRetrie
151151
StringBuilder params = new StringBuilder();
152152
params.append("?attributes=");
153153
for (int i = 0; i < attributesToRetrieve.size(); ++i) {
154-
if (i > 0)
154+
if (i > 0) {
155155
params.append(",");
156+
}
156157
params.append(URLEncoder.encode(attributesToRetrieve.get(i), "UTF-8"));
157158
}
158159
return client.getRequest("/1/indexes/" + encodedIndexName + "/" + URLEncoder.encode(objectID, "UTF-8") + params.toString(), false);
@@ -267,8 +268,9 @@ protected JSONObject saveObjects(JSONArray inputArray) throws AlgoliaException {
267268
* @throws AlgoliaException
268269
*/
269270
protected JSONObject deleteObject(String objectID) throws AlgoliaException {
270-
if (objectID.length() == 0)
271+
if (objectID.length() == 0) {
271272
throw new AlgoliaException("Invalid objectID");
273+
}
272274
try {
273275
return client.deleteRequest("/1/indexes/" + encodedIndexName + "/" + URLEncoder.encode(objectID, "UTF-8"));
274276
} catch (UnsupportedEncodingException e) {
@@ -335,10 +337,11 @@ protected void deleteByQuery(Query query) throws AlgoliaException {
335337
*/
336338
protected JSONObject search(Query query) throws AlgoliaException {
337339
String paramsString = query.getQueryString();
338-
if (paramsString.length() > 0)
340+
if (paramsString.length() > 0) {
339341
return client.getRequest("/1/indexes/" + encodedIndexName + "?" + paramsString, true);
340-
else
342+
} else {
341343
return client.getRequest("/1/indexes/" + encodedIndexName, true);
344+
}
342345
}
343346

344347
/**
@@ -348,10 +351,11 @@ protected JSONObject search(Query query) throws AlgoliaException {
348351
*/
349352
protected byte[] searchRaw(Query query) throws AlgoliaException {
350353
String paramsString = query.getQueryString();
351-
if (paramsString.length() > 0)
354+
if (paramsString.length() > 0) {
352355
return client.getRequestRaw("/1/indexes/" + encodedIndexName + "?" + paramsString, true);
353-
else
356+
} else {
354357
return client.getRequestRaw("/1/indexes/" + encodedIndexName, true);
358+
}
355359
}
356360

357361
/**
@@ -366,8 +370,9 @@ protected void waitTask(String taskID, long timeToWait) throws AlgoliaException
366370
try {
367371
while (true) {
368372
JSONObject obj = client.getRequest("/1/indexes/" + encodedIndexName + "/task/" + URLEncoder.encode(taskID, "UTF-8"), false);
369-
if (obj.getString("status").equals("published"))
373+
if (obj.getString("status").equals("published")) {
370374
return;
375+
}
371376
try {
372377
Thread.sleep(timeToWait >= MAX_TIME_MS_TO_WAIT ? MAX_TIME_MS_TO_WAIT : timeToWait);
373378
} catch (InterruptedException e) {

0 commit comments

Comments
 (0)