Author: jleroux
Date: Mon Nov 20 12:32:44 2017 New Revision: 1815797 URL: http://svn.apache.org/viewvc?rev=1815797&view=rev Log: Fixed: Fix Default or Empty Catch block in Java and Groovy files (OFBIZ-8341) While reviewing r1812057 I spotted a bunch of swallowed ClassCastExceptions I then reviewed all ClassCastExceptions and this fixes all of them with a minimal logging Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/collections/ResourceBundleMapWrapper.java ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/string/UelUtil.java ofbiz/ofbiz-framework/trunk/framework/common/src/main/java/org/apache/ofbiz/common/FindServices.java ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/jdbc/JdbcValueHandler.java ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/calendar/TemporalExpressions.java 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=1815797&r1=1815796&r2=1815797&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 Mon Nov 20 12:32:44 2017 @@ -26,8 +26,10 @@ import java.util.MissingResourceExceptio import java.util.ResourceBundle; import java.util.Set; +import org.apache.ofbiz.base.util.Debug; import org.apache.ofbiz.base.util.UtilProperties; import org.apache.ofbiz.base.util.string.FlexibleStringExpander; +import org.apache.ofbiz.service.calendar.TemporalExpressions.Frequency; /** * Generic ResourceBundle Map Wrapper, given ResourceBundle allows it to be used as a Map @@ -36,6 +38,7 @@ import org.apache.ofbiz.base.util.string @SuppressWarnings("serial") public class ResourceBundleMapWrapper implements Map<String, Object>, Serializable { + public static final String module = Frequency.class.getName(); protected MapStack<String> rbmwStack; protected ResourceBundle initialResourceBundle; protected Map<String, Object> context; @@ -122,8 +125,8 @@ public class ResourceBundleMapWrapper im try { String str = (String) value; return FlexibleStringExpander.expandString(str, context); - } catch (Exception e) { - // Potential ClassCastException - do nothing + } catch (ClassCastException e) { + Debug.logInfo(e.getMessage(), module); } } return value; Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/string/UelUtil.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/string/UelUtil.java?rev=1815797&r1=1815796&r2=1815797&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/string/UelUtil.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/string/UelUtil.java Mon Nov 20 12:32:44 2017 @@ -248,7 +248,9 @@ public final class UelUtil { try { ReadOnlyExpression other = (ReadOnlyExpression) obj; return this.object.equals(other.object); - } catch (ClassCastException e) {} + } catch (ClassCastException e) { + Debug.logInfo(e.getMessage(), module); + } return false; } @@ -285,7 +287,9 @@ public final class UelUtil { try { BasicValueExpression other = (BasicValueExpression) obj; return this.varName.equals(other.varName); - } catch (ClassCastException e) {} + } catch (ClassCastException e) { + Debug.logInfo(e.getMessage(), module); + } return false; } @Override @@ -342,7 +346,9 @@ public final class UelUtil { BasicContext elContext = (BasicContext) context; elContext.variables.put(property.toString(), val); context.setPropertyResolved(true); - } catch (ClassCastException e) {} + } catch (ClassCastException e) { + Debug.logInfo(e.getMessage(), module); + } } } } Modified: ofbiz/ofbiz-framework/trunk/framework/common/src/main/java/org/apache/ofbiz/common/FindServices.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/common/src/main/java/org/apache/ofbiz/common/FindServices.java?rev=1815797&r1=1815796&r2=1815797&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/common/src/main/java/org/apache/ofbiz/common/FindServices.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/common/src/main/java/org/apache/ofbiz/common/FindServices.java Mon Nov 20 12:32:44 2017 @@ -445,7 +445,7 @@ public class FindServices { list = it.getPartialList(start+1, viewSize); // list starts at '1' listSize = it.getResultsSizeAfterPartialList(); } catch (ClassCastException | NullPointerException | GenericEntityException e) { - Debug.logInfo("Problem getting partial list" + e,module); + Debug.logInfo("Problem getting partial list" + e, module); } result.put("listSize", listSize); Modified: ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/jdbc/JdbcValueHandler.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/jdbc/JdbcValueHandler.java?rev=1815797&r1=1815796&r2=1815797&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/jdbc/JdbcValueHandler.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/jdbc/JdbcValueHandler.java Mon Nov 20 12:32:44 2017 @@ -435,7 +435,9 @@ public abstract class JdbcValueHandler<T Debug.logWarning("Clob java-type used for java.lang.String. Use java.lang.String java-type instead.", module); ps.setString(parameterIndex, str); return; - } catch (ClassCastException e) {} + } catch (ClassCastException e) { + Debug.logInfo(e.getMessage(), module); + } ps.setClob(parameterIndex, (java.sql.Clob) obj); return; } Modified: ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/calendar/TemporalExpressions.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/calendar/TemporalExpressions.java?rev=1815797&r1=1815796&r2=1815797&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/calendar/TemporalExpressions.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/calendar/TemporalExpressions.java Mon Nov 20 12:32:44 2017 @@ -35,7 +35,6 @@ import com.ibm.icu.util.Calendar; */ @SuppressWarnings("serial") public class TemporalExpressions implements Serializable { - public static final String module = TemporalExpressions.class.getName(); public static final TemporalExpression NullExpression = new Null(); // Expressions are evaluated from smallest unit of time to largest. // When unit of time is the same, then they are evaluated from @@ -58,6 +57,7 @@ public class TemporalExpressions impleme /** A temporal expression that represents a range of dates. */ public static class DateRange extends TemporalExpression { + public static final String module = DateRange.class.getName(); protected final org.apache.ofbiz.base.util.DateRange range; public DateRange(Date date) { @@ -95,6 +95,7 @@ public class TemporalExpressions impleme return this.range.equals(((DateRange) obj).range); } catch (ClassCastException e) { + Debug.logInfo(e.getMessage(), module); } } return false; @@ -135,6 +136,7 @@ public class TemporalExpressions impleme /** A temporal expression that represents a day in the month. */ public static class DayInMonth extends TemporalExpression { + public static final String module = DayInMonth.class.getName(); protected final int dayOfWeek; protected final int occurrence; @@ -207,6 +209,7 @@ public class TemporalExpressions impleme return this.dayOfWeek == that.dayOfWeek && this.occurrence == that.occurrence; } catch (ClassCastException e) { + Debug.logInfo(e.getMessage(), module); } } return false; @@ -287,6 +290,7 @@ public class TemporalExpressions impleme /** A temporal expression that represents a day of month range. */ public static class DayOfMonthRange extends TemporalExpression { + public static final String module = DayOfMonthRange.class.getName(); protected final int end; protected final int start; @@ -338,6 +342,7 @@ public class TemporalExpressions impleme return this.start == that.start && this.end == that.end; } catch (ClassCastException e) { + Debug.logInfo(e.getMessage(), module); } } return false; @@ -403,6 +408,7 @@ public class TemporalExpressions impleme /** A temporal expression that represents a day of week range. */ public static class DayOfWeekRange extends TemporalExpression { + public static final String module = DayOfWeekRange.class.getName(); protected final int end; protected final int start; @@ -456,6 +462,7 @@ public class TemporalExpressions impleme return this.start == that.start && this.end == that.end; } catch (ClassCastException e) { + Debug.logInfo(e.getMessage(), module); } } return false; @@ -543,6 +550,7 @@ public class TemporalExpressions impleme /** A temporal expression that represents a difference of two temporal expressions. */ public static class Difference extends TemporalExpression { + public static final String module = Difference.class.getName(); protected final TemporalExpression excluded; protected final TemporalExpression included; @@ -591,6 +599,7 @@ public class TemporalExpressions impleme return this.included.equals(that.included) && this.excluded.equals(that.excluded); } catch (ClassCastException e) { + Debug.logInfo(e.getMessage(), module); } } return false; @@ -644,8 +653,9 @@ public class TemporalExpressions impleme } } - /** A temporal expression that represents a frequency. */ + /* A temporal expression that represents a frequency. */ public static class Frequency extends TemporalExpression { + public static final String module = Frequency.class.getName(); protected final int freqCount; protected final int freqType; protected final Date start; @@ -705,6 +715,7 @@ public class TemporalExpressions impleme return this.start.equals(that.start) && this.freqType == that.freqType && this.freqCount == that.freqCount; } catch (ClassCastException e) { + Debug.logInfo(e.getMessage(), module); } } return false; @@ -807,6 +818,7 @@ public class TemporalExpressions impleme /** A temporal expression that represents an hour range. */ public static class HourRange extends TemporalExpression { + public static final String module = HourRange.class.getName(); protected final int end; protected final int start; @@ -861,6 +873,7 @@ public class TemporalExpressions impleme return this.start == that.start && this.end == that.end; } catch (ClassCastException e) { + Debug.logInfo(e.getMessage(), module); } } return false; @@ -961,6 +974,7 @@ public class TemporalExpressions impleme /** A temporal expression that represents a mathematical intersection of all of its * member expressions. */ public static class Intersection extends TemporalExpression { + public static final String module = Intersection.class.getName(); protected final Set<TemporalExpression> expressionSet; public Intersection(Set<TemporalExpression> expressionSet) { @@ -1020,6 +1034,7 @@ public class TemporalExpressions impleme return this.expressionSet.equals(((Intersection) obj).expressionSet); } catch (ClassCastException e) { + Debug.logInfo(e.getMessage(), module); } } return false; @@ -1088,6 +1103,7 @@ public class TemporalExpressions impleme /** A temporal expression that represents a minute range. */ public static class MinuteRange extends TemporalExpression { + public static final String module = MinuteRange.class.getName(); protected final int end; protected final int start; @@ -1142,6 +1158,7 @@ public class TemporalExpressions impleme return this.start == that.start && this.end == that.end; } catch (ClassCastException e) { + Debug.logInfo(e.getMessage(), module); } } return false; @@ -1238,6 +1255,7 @@ public class TemporalExpressions impleme /** A temporal expression that represents a month range. */ public static class MonthRange extends TemporalExpression { + public static final String module = MonthRange.class.getName(); protected final int end; protected final int start; @@ -1291,6 +1309,7 @@ public class TemporalExpressions impleme return this.start == that.start && this.end == that.end; } catch (ClassCastException e) { + Debug.logInfo(e.getMessage(), module); } } return false; @@ -1395,6 +1414,7 @@ public class TemporalExpressions impleme /** A temporal expression that provides a substitution for an excluded temporal expression. */ public static class Substitution extends TemporalExpression { + public static final String module = Substitution.class.getName(); protected final TemporalExpression excluded; protected final TemporalExpression included; protected final TemporalExpression substitute; @@ -1452,6 +1472,7 @@ public class TemporalExpressions impleme return this.included.equals(that.included) && this.excluded.equals(that.excluded) && this.substitute.equals(that.substitute); } catch (ClassCastException e) { + Debug.logInfo(e.getMessage(), module); } } return false; @@ -1518,6 +1539,7 @@ public class TemporalExpressions impleme /** A temporal expression that represents a mathematical union of all of its * member expressions. */ public static class Union extends TemporalExpression { + public static final String module = Union.class.getName(); protected final Set<TemporalExpression> expressionSet; public Union(Set<TemporalExpression> expressionSet) { @@ -1570,6 +1592,7 @@ public class TemporalExpressions impleme return this.expressionSet.equals(((Union) obj).expressionSet); } catch (ClassCastException e) { + Debug.logInfo(e.getMessage(), module); } } return false; |
Free forum by Nabble | Edit this page |