Skip to content

Commit b9c3070

Browse files
rishabhdaimRishabh Kumar
andauthored
OAK-11769 : replaced DoubleMath.fuzzyCompare with commons-math3 Precision (#2345)
* OAK-11769 : replaced Doubles.fuzzyCompare with commons-math3 Precision * OAK-11769 : added apache commons-math3 to test-bundles.xml --------- Co-authored-by: Rishabh Kumar <diam@adobe.com>
1 parent 56dfda4 commit b9c3070

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

oak-it-osgi/test-bundles.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
<include>commons-logging:commons-logging</include>
4040
<include>com.fasterxml.jackson.core:jackson-core</include>
4141
<include>org.apache.commons:commons-lang3</include>
42+
<include>org.apache.commons:commons-math3</include>
4243
<include>org.apache.commons:commons-text</include>
4344
<include>org.apache.commons:commons-collections4</include>
4445
<include>org.apache.jackrabbit:jackrabbit-jcr-commons</include>

oak-run-elastic/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
105 MB: Azure updates
4343
107 MB: RDB/Tomcat (OAK-10752)
4444
-->
45-
<max.jar.size>117000000</max.jar.size>
45+
<max.jar.size>119000000</max.jar.size>
4646

4747
</properties>
4848

oak-store-document/pom.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,10 @@
152152
<groupId>commons-io</groupId>
153153
<artifactId>commons-io</artifactId>
154154
</dependency>
155+
<dependency>
156+
<groupId>org.apache.commons</groupId>
157+
<artifactId>commons-math3</artifactId>
158+
</dependency>
155159
<dependency>
156160
<groupId>org.quartz-scheduler</groupId>
157161
<artifactId>quartz</artifactId>

oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoThrottlerFactory.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818
*/
1919
package org.apache.jackrabbit.oak.plugins.document.mongo;
2020

21+
import org.apache.commons.math3.util.Precision;
2122
import org.apache.jackrabbit.guava.common.util.concurrent.AtomicDouble;
2223
import org.apache.jackrabbit.oak.plugins.document.Throttler;
2324
import org.jetbrains.annotations.NotNull;
2425

25-
import static org.apache.jackrabbit.guava.common.math.DoubleMath.fuzzyCompare;
2626
import static java.util.Objects.requireNonNull;
2727
import static org.apache.jackrabbit.oak.plugins.document.Throttler.NO_THROTTLING;
2828

@@ -78,13 +78,13 @@ public long throttlingTime() {
7878
final double oplogWindow = this.oplogWindow.doubleValue();
7979
long throttleTime = throttlingTime;
8080

81-
if (fuzzyCompare(oplogWindow,threshold/8, 0.001) <= 0) {
81+
if (Precision.compareTo(oplogWindow,threshold/8, 0.001) <= 0) {
8282
throttleTime = throttleTime * 8;
83-
} else if (fuzzyCompare(oplogWindow,threshold/4, 0.001) <= 0) {
83+
} else if (Precision.compareTo(oplogWindow,threshold/4, 0.001) <= 0) {
8484
throttleTime = throttleTime * 4;
85-
} else if (fuzzyCompare(oplogWindow, threshold/2, 0.001) <= 0) {
85+
} else if (Precision.compareTo(oplogWindow, threshold/2, 0.001) <= 0) {
8686
throttleTime = throttleTime * 2;
87-
} else if (fuzzyCompare(oplogWindow, threshold,0.001) <= 0) {
87+
} else if (Precision.compareTo(oplogWindow, threshold,0.001) <= 0) {
8888
throttleTime = throttlingTime;
8989
} else {
9090
throttleTime = 0;

0 commit comments

Comments
 (0)