Improved: Merge identical catch blocks in single catch block(OFBIZ-11827)

In Java SE 7 and later, a single catch block can handle more than one type of exception. This feature can reduce code duplication and lessen the temptation to catch an overly broad exception.

Thanks: Jacques for the review.
This commit is contained in:
Pawan Verma
2020-06-27 11:24:33 +05:30
parent 7680c0d3ab
commit 1f97f89bae
22 changed files with 51 additions and 264 deletions
@@ -129,12 +129,9 @@ public class ContentDocument implements LuceneDocument {
String text;
try {
text = ContentWorker.renderContentAsText(dispatcher, contentId, null, locale, mimeTypeId, true);
} catch (GeneralException e) {
} catch (GeneralException | IOException e) {
Debug.logError(e, MODULE);
return false;
} catch (IOException e2) {
Debug.logError(e2, MODULE);
return false;
}
if (UtilValidate.isNotEmpty(text)) {
Field field = new TextField("content", text, Store.NO);
@@ -204,9 +204,7 @@ public class ProductDocument implements LuceneDocument {
Map<String, Object> drContext = UtilMisc.<String, Object>toMap("product", product);
String contentText = DataResourceWorker.renderDataResourceAsText(null, delegator, productContentAndInfo.getString("dataResourceId"), drContext, null, null, false);
addTextField(doc, "content", contentText, false, "fullText", delegator);
} catch (IOException e1) {
Debug.logError(e1, "Error getting content text to index", MODULE);
} catch (GeneralException e1) {
} catch (IOException | GeneralException e1) {
Debug.logError(e1, "Error getting content text to index", MODULE);
}
@@ -126,9 +126,7 @@ public class SearchServices {
return ServiceUtil.returnError(ServiceUtil.getErrorMessage(result));
}
}
} catch (GenericEntityException e) {
Debug.logError(e, MODULE);
} catch (GenericServiceException e) {
} catch (GenericEntityException | GenericServiceException e) {
Debug.logError(e, MODULE);
}
return ServiceUtil.returnSuccess();