Skip to content

Commit 580dc85

Browse files
Merge pull request #124 from google/Fix-pickle-jar-tag-observer
Fixed a bug caused by not using a deep copy with an observer
2 parents 6b071f5 + 20f4ca2 commit 580dc85

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<groupId>com.google.pdsl</groupId>
77
<artifactId>pdsl</artifactId>
8-
<version>1.7.9-SNAPSHOT</version>
8+
<version>1.7.10-SNAPSHOT</version>
99

1010
<name>pdsl</name>
1111
<url>http://www.github.com/google/polymorphicDSL</url>

src/main/java/com/pdsl/gherkin/PickleJarFactory.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,15 @@ private List<PickleJar.PickleJarScenario> convertScenariosToPickleJarScenarios(L
127127
if (table.getTags().isPresent()) {
128128
tableTags.addAll(processTags(table.getTags().get()));
129129
}
130-
builder.withTags(processTags(tableTags));
130+
// Use a deep copy.
131+
// Otherwise if the observer adds additional tags to the set they
132+
// will be added for ALL of the tabular scenarios
133+
Set<String> potentiallyMutatedTags = new HashSet<>(tableTags);
131134
// notifying observers
132135
notifyObservers(
133136
scenario.getTitle().orElseThrow().getStringWithSubstitutions(substitutions),
134-
substitutedSteps, tableTags, substitutions);
137+
substitutedSteps, potentiallyMutatedTags, substitutions);
138+
builder.withTags(processTags(potentiallyMutatedTags));
135139
pickleJarScenarios.add(builder.build());
136140
}
137141
}

0 commit comments

Comments
 (0)