We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pattensはlistを受け取った際にそのlistオブジェクトをそのままインスタンスに保持する。 そのため、受け取ったlistがmutableな場合には以下の操作で定義されたPatternsの挙動が改変できてしまう。
var list = new ArrayList<>( List.<Tuple2<Predicate<Integer>, Function<Integer, String>>>of( when(equalsTo(3), then("b")), // このパターンが消されてしまうので when(equalsTo(4), thenSupply(() -> "c")), when(i -> i > 0, thenApply(Object::toString)), // 3はこちらで処理されるようになる when(i -> i < 0, thenApply(sequenceOf((UnaryOperator<Integer>) i -> i + 1, Number::longValue, Object::toString))))); Patterns<Integer, String> target = Patterns.of(list); list.remove(0);
これを防ぐため、Patternsは受け取ったリストのコピーを保持するように改修する必要がある。
実際にPatternsを破壊するテストケースが実装されているので、 そのケースによってPatternsが破壊されなくなることを確認したらそのケース名のみを変更すればよい。
The text was updated successfully, but these errors were encountered:
Merge pull request #24 from tk-hirom/#19-safe_coppy
3d78411
イシュー19番の対応
No branches or pull requests
改修について
現状
Pattensはlistを受け取った際にそのlistオブジェクトをそのままインスタンスに保持する。
そのため、受け取ったlistがmutableな場合には以下の操作で定義されたPatternsの挙動が改変できてしまう。
破壊例
対応
これを防ぐため、Patternsは受け取ったリストのコピーを保持するように改修する必要がある。
単体テスト
実際にPatternsを破壊するテストケースが実装されているので、
そのケースによってPatternsが破壊されなくなることを確認したらそのケース名のみを変更すればよい。
The text was updated successfully, but these errors were encountered: