Skip to content

Commit ced1bc4

Browse files
committed
Fix PMD AvoidDecimalLiteralsInBigDecimalConstructor in
org.apache.commons.jxpath.util.BasicTypeConverter.allocateNumber(Class, double)
1 parent ce218ed commit ced1bc4

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/changes/changes.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ The <action> type attribute can be add,update,fix,remove.
134134
<action dev="ggregory" type="fix" due-to="Gary Gregory">Make the private JDOMNodePointer.id field final.</action>
135135
<action dev="ggregory" type="fix" due-to="Gary Gregory">ExpressionContext.getContextNodeList() now uses generics.</action>
136136
<action dev="ggregory" type="fix" due-to="Gary Gregory">BasicTypeConverter.unmodifiableCollection(Collection) now uses generics.</action>
137+
<action dev="ggregory" type="fix" due-to="Gary Gregory. PMD">Fix PMD AvoidDecimalLiteralsInBigDecimalConstructor in org.apache.commons.jxpath.util.BasicTypeConverter.allocateNumber(Class, double).</action>
137138
<!-- ADD -->
138139
<action issue="JXPATH-123" dev="mbenson" type="add">
139140
XPath function "ends-with" is not implemented (although "starts-with" is).

src/main/java/org/apache/commons/jxpath/util/BasicTypeConverter.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,7 @@ protected Number allocateNumber(Class type, final double value) {
173173
return BigInteger.valueOf((long) value);
174174
}
175175
if (type == BigDecimal.class) {
176-
// TODO ? https://pmd.sourceforge.io/pmd-6.50.0/pmd_rules_java_errorprone.html#avoiddecimalliteralsinbigdecimalconstructor
177-
return new BigDecimal(value); // NOPMD
176+
return new BigDecimal(Double.toString(value));
178177
}
179178
final String className = type.getName();
180179
Class initialValueType = null;

0 commit comments

Comments
 (0)