Skip to content

Commit 79bac5d

Browse files
committed
bugfix: Avoid nondeterminism by using a LinkedHashMap instead of a HashMap
1 parent 0cdecf3 commit 79bac5d

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

src/main/java/org/variantsync/diffdetective/feature/BooleanAbstraction.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import org.variantsync.functjonal.Functjonal;
44

5+
import java.util.LinkedHashMap;
56
import java.util.Map;
67
import java.util.function.Function;
78
import java.util.regex.Pattern;
@@ -28,9 +29,9 @@ private BooleanAbstraction(){}
2829
"<=", LEQ,
2930
">", GT,
3031
"<", LT,
31-
"\\+", ADD,
32+
Pattern.quote("+"), ADD,
3233
"-", SUB,
33-
"\\*", MUL,
34+
Pattern.quote("*"), MUL,
3435
"/", DIV,
3536
"%", MOD
3637
));
@@ -44,7 +45,9 @@ private static Map<Pattern, String> compile(final Map<String, String> regex_repl
4445
return Functjonal.bimap(
4546
regex_replace,
4647
Pattern::compile,
47-
Function.identity()
48+
Function.identity(),
49+
// Use a linked hashmap here to ensure that regexes are always replaced in the same order.
50+
LinkedHashMap::new
4851
);
4952
}
5053

0 commit comments

Comments
 (0)