File tree 2 files changed +9
-6
lines changed
cucumber-core/src/main/java/io/cucumber/core/runner
2 files changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -87,6 +87,11 @@ final class CachingGlue implements Glue {
87
87
private final EventBus bus ;
88
88
private StepTypeRegistry stepTypeRegistry ;
89
89
private Locale locale = null ;
90
+ private int parameterTypeDefinitionsHashCode = 0 ;
91
+ private int stepDefinitionsHashCode = 0 ;
92
+ private int dataTableTypeDefinitionsHashCode = 0 ;
93
+ private int docStringTypeDefinitionsHashCode = 0 ;
94
+ private StepExpressionFactory stepExpressionFactory = null ;
90
95
91
96
CachingGlue (EventBus bus ) {
92
97
this .bus = bus ;
@@ -237,12 +242,7 @@ List<DocStringTypeDefinition> getDocStringTypeDefinitions() {
237
242
StepTypeRegistry getStepTypeRegistry () {
238
243
return stepTypeRegistry ;
239
244
}
240
- int parameterTypeDefinitionsHashCode = 0 ;
241
- int stepDefinitionsHashCode = 0 ;
242
- int dataTableTypeDefinitionsHashCode = 0 ;
243
- int docStringTypeDefinitionsHashCode = 0 ;
244
245
245
- StepExpressionFactory stepExpressionFactory = null ;
246
246
void prepareGlue (Locale locale ) throws DuplicateStepDefinitionException {
247
247
int parameterTypeDefinitionsHashCodeNew = parameterTypeDefinitions .hashCode ();
248
248
int dataTableTypeDefinitionsHashCodeNew = dataTableTypeDefinitions .hashCode ();
Original file line number Diff line number Diff line change 21
21
import java .net .URI ;
22
22
import java .util .ArrayList ;
23
23
import java .util .Collection ;
24
+ import java .util .HashMap ;
24
25
import java .util .List ;
25
26
import java .util .Locale ;
27
+ import java .util .Map ;
26
28
import java .util .Objects ;
27
29
import java .util .stream .Collectors ;
28
30
@@ -39,6 +41,7 @@ public final class Runner {
39
41
private final Collection <? extends Backend > backends ;
40
42
private final Options runnerOptions ;
41
43
private final ObjectFactory objectFactory ;
44
+ private final Map <String , Locale > localeCache = new HashMap <>();
42
45
private List <SnippetGenerator > snippetGenerators ;
43
46
44
47
public Runner (
@@ -80,7 +83,7 @@ public void runPickle(Pickle pickle) {
80
83
81
84
private Locale localeForPickle (Pickle pickle ) {
82
85
String language = pickle .getLanguage ();
83
- return new Locale (language );
86
+ return localeCache . computeIfAbsent ( language , ( lang ) -> new Locale (language ) );
84
87
}
85
88
86
89
public void runBeforeAllHooks () {
You can’t perform that action at this time.
0 commit comments