Skip to content

Commit 0ff76a0

Browse files
[refactor] Made SonarCloud recommended changes.
1 parent 1499ef9 commit 0ff76a0

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

exist-core/src/main/java/org/exist/xquery/functions/map/SingleKeyMapType.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,9 @@ public Sequence get(final AtomicValue key) {
7070

7171
@Override
7272
public AbstractMapType merge(final Iterable<AbstractMapType> others) {
73-
final MapType map = new MapType(getExpression(), context, collator, key, value);
74-
return map.merge(others);
73+
try (final MapType map = new MapType(getExpression(), context, collator, key, value)) {
74+
return map.merge(others);
75+
}
7576
}
7677

7778
@Override

exist-core/src/main/java/org/exist/xquery/value/DoubleValue.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public boolean hasFractionalPart() {
109109
if (isInfinite()) {
110110
return false;
111111
}
112-
return new DecimalValue(getExpression(), new BigDecimal(value)).hasFractionalPart();
112+
return new DecimalValue(getExpression(), BigDecimal.valueOf(value)).hasFractionalPart();
113113
}
114114

115115
@Override
@@ -192,7 +192,7 @@ public AtomicValue convertTo(final int requiredType) throws XPathException {
192192
+ "') to "
193193
+ Type.getTypeName(requiredType));
194194
}
195-
return new DecimalValue(getExpression(), new BigDecimal(value));
195+
return new DecimalValue(getExpression(), BigDecimal.valueOf(value));
196196
case Type.INTEGER:
197197
case Type.NON_POSITIVE_INTEGER:
198198
case Type.NEGATIVE_INTEGER:
@@ -224,7 +224,7 @@ public AtomicValue convertTo(final int requiredType) throws XPathException {
224224
if (requiredType != Type.INTEGER && value > Integer.MAX_VALUE) {
225225
throw new XPathException(getExpression(), ErrorCodes.FOCA0003, "Value is out of range for type " + Type.getTypeName(requiredType));
226226
}
227-
return new IntegerValue(getExpression(), Double.valueOf(value).longValue(), requiredType);
227+
return new IntegerValue(getExpression(), new Double(value).longValue(), requiredType);
228228
case Type.BOOLEAN:
229229
return new BooleanValue(getExpression(), this.effectiveBooleanValue());
230230
default:

exist-core/src/main/java/org/exist/xquery/value/FloatValue.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ public boolean hasFractionalPart() {
167167
if (isInfinite()) {
168168
return false;
169169
}
170-
return new DecimalValue(getExpression(), new BigDecimal(value)).hasFractionalPart();
170+
return new DecimalValue(getExpression(), BigDecimal.valueOf(value)).hasFractionalPart();
171171
}
172172

173173
/* (non-Javadoc)

0 commit comments

Comments
 (0)