Author: jleroux
Date: Sun Dec 10 12:00:07 2017 New Revision: 1817703 URL: http://svn.apache.org/viewvc?rev=1817703&view=rev Log: Fixed: Fix Default or Empty Catch block in Java and Groovy files (OFBIZ-8341) While reviewing recent Michael's FB commits I spotted a bunch of (unrelated) swallowed exceptions. This fixes them Also few formatting and use of multi catches Modified: ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppinglist/ShoppingListEvents.java ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/SSLUtil.java ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/collections/ResourceBundleMapWrapper.java ofbiz/ofbiz-framework/trunk/framework/common/src/main/java/org/apache/ofbiz/common/qrcode/QRCodeServices.java Modified: ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppinglist/ShoppingListEvents.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppinglist/ShoppingListEvents.java?rev=1817703&r1=1817702&r2=1817703&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppinglist/ShoppingListEvents.java (original) +++ ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppinglist/ShoppingListEvents.java Sun Dec 10 12:00:07 2017 @@ -323,6 +323,7 @@ public class ShoppingListEvents { quantity = new BigDecimal(quantityStr); } catch (NumberFormatException e) { // do nothing, just won't pass to service if it is null + Debug.logError(e, module); } Map<String, Object> serviceInMap = new HashMap<String, Object>(); Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/SSLUtil.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/SSLUtil.java?rev=1817703&r1=1817702&r2=1817703&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/SSLUtil.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/SSLUtil.java Sun Dec 10 12:00:07 2017 @@ -118,7 +118,7 @@ public final class SSLUtil { ((X509TrustManager) mgr).checkClientTrusted(chain, authType); return true; } catch (CertificateException e) { - // do nothing; just loop + Debug.logError(e, module); } } } Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/collections/ResourceBundleMapWrapper.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/collections/ResourceBundleMapWrapper.java?rev=1817703&r1=1817702&r2=1817703&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/collections/ResourceBundleMapWrapper.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/collections/ResourceBundleMapWrapper.java Sun Dec 10 12:00:07 2017 @@ -257,6 +257,7 @@ public class ResourceBundleMapWrapper im value = this.resourceBundle.getObject((String) arg0); } catch (MissingResourceException mre) { // do nothing, this will be handled by recognition that the value is still null + Debug.logError(mre, module); } } } Modified: ofbiz/ofbiz-framework/trunk/framework/common/src/main/java/org/apache/ofbiz/common/qrcode/QRCodeServices.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/common/src/main/java/org/apache/ofbiz/common/qrcode/QRCodeServices.java?rev=1817703&r1=1817702&r2=1817703&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/common/src/main/java/org/apache/ofbiz/common/qrcode/QRCodeServices.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/common/src/main/java/org/apache/ofbiz/common/qrcode/QRCodeServices.java Sun Dec 10 12:00:07 2017 @@ -155,10 +155,8 @@ public class QRCodeServices { try { logoImageResult = ImageTransform.getBufferedImage(FileUtil.getFile(logoImage).getAbsolutePath(), locale); logoBufferedImage = (BufferedImage) logoImageResult.get("bufferedImage"); - } catch (IllegalArgumentException e) { - // do nothing - } catch (IOException e) { - // do nothing + } catch (IllegalArgumentException | IOException e) { + Debug.logError(e, module); } } if (UtilValidate.isEmpty(logoBufferedImage)) { @@ -168,11 +166,11 @@ public class QRCodeServices { BufferedImage newBufferedImage = null; if (UtilValidate.isNotEmpty(logoBufferedImage)) { if (UtilValidate.isNotEmpty(logoImageMaxWidth) && UtilValidate.isNotEmpty(logoImageMaxHeight) && (logoBufferedImage.getWidth() > logoImageMaxWidth.intValue() || logoBufferedImage.getHeight() > logoImageMaxHeight.intValue())) { - Map<String, String> typeMap = new HashMap<>(); - typeMap.put("width", logoImageMaxWidth.toString()); - typeMap.put("height", logoImageMaxHeight.toString()); - Map<String, Map<String, String>> dimensionMap = new HashMap<>(); - dimensionMap.put("QRCode", typeMap); + Map<String, String> typeMap = new HashMap<>(); + typeMap.put("width", logoImageMaxWidth.toString()); + typeMap.put("height", logoImageMaxHeight.toString()); + Map<String, Map<String, String>> dimensionMap = new HashMap<>(); + dimensionMap.put("QRCode", typeMap); Map<String, Object> logoImageResult = ImageTransform.scaleImage(logoBufferedImage, (double) logoBufferedImage.getWidth(), (double) logoBufferedImage.getHeight(), dimensionMap, "QRCode", locale); logoBufferedImage = (BufferedImage) logoImageResult.get("bufferedImage"); } @@ -192,17 +190,13 @@ public class QRCodeServices { } DetectorResult detectorResult = null; if (UtilValidate.isNotEmpty(newBufferedImage)) { - BitMatrix newBitMatrix = createMatrixFromImage(newBufferedImage); + BitMatrix newBitMatrix = createMatrixFromImage(newBufferedImage); DecoderResult result = null; try { detectorResult = new Detector(newBitMatrix).detect(decodeHints); - result = decoder.decode(detectorResult.getBits(), decodeHints); - } catch (ChecksumException e) { - // do nothing - } catch (FormatException e) { - // do nothing - } catch (NotFoundException e) { - // do nothing + result = decoder.decode(detectorResult.getBits(), decodeHints); + } catch (ChecksumException | FormatException | NotFoundException e) { + Debug.logError(e, module); } if (UtilValidate.isNotEmpty(result) && !result.getText().equals(message)) { detectorResult = new Detector(bitMatrix).detect(decodeHints); |
Free forum by Nabble | Edit this page |