Make Copy of collate parameter map

Test failures showed problems with passing down
the same collate parameter map reference from the
phrase suggestion builder to the context where.
This changes the collate parameter setters to
make a shallow copy of the map passed in.
This commit is contained in:
Christoph Büscher 2016-03-11 15:20:52 +01:00
parent daeffb149c
commit 7aa29e3f7c
2 changed files with 5 additions and 3 deletions

View File

@ -346,10 +346,12 @@ public class PhraseSuggestionBuilder extends SuggestionBuilder<PhraseSuggestionB
}
/**
* Sets additional params for collate script
* Adds additional parameters for collate scripts. Previously added parameters on the
* same builder will be overwritten.
*/
public PhraseSuggestionBuilder collateParams(Map<String, Object> collateParams) {
this.collateParams = collateParams;
Objects.requireNonNull(collateParams, "collate parameters cannot be null.");
this.collateParams = new HashMap<>(collateParams);
return this;
}

View File

@ -201,7 +201,7 @@ class PhraseSuggestionContext extends SuggestionContext {
}
void setCollateScriptParams(Map<String, Object> collateScriptParams) {
this.collateScriptParams = collateScriptParams;
this.collateScriptParams = new HashMap<>(collateScriptParams);
}
void setCollatePrune(boolean prune) {