Skip to content
New issue

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

JCache Cache.putAll(...) with immutable map can cause exception #841

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.io.IOException;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;

import javax.cache.integration.CacheWriter;
import javax.cache.integration.CacheWriterException;
Expand Down Expand Up @@ -72,6 +73,19 @@ public void putAll_fails() {
}
}

@Test
public void putAllImmutable_fails() {

Check warning

Code scanning / Pmd (reported by Codacy)

The instance method name 'putAllImmutable_fails' doesn't match '[a-z][a-zA-Z0-9]*'

The instance method name 'putAllImmutable_fails' doesn't match '[a-z][a-zA-Z0-9]*'
doThrow(CacheWriterException.class).when(writer).writeAll(any());
var immutableMap = Map.of(KEY_1, VALUE_1);

try {
jcache.putAll(immutableMap);
Assert.fail();
} catch (CacheWriterException e) {
assertThat(immutableMap).isEmpty();
}
}

@Test(expectedExceptions = CacheWriterException.class)
public void remove_fails() {
jcache.put(KEY_1, VALUE_1);
Expand Down