Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Intellij Community
Commits
774c187e
Commit
774c187e
authored
7 years ago
by
Alexander Kass
Browse files
Options
Download
Email Patches
Plain Diff
ConcurrentFactoryMap fix nullability issues
parent
e62585f6
Branches unavailable
Tags unavailable
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
platform/platform-tests/testSrc/com/intellij/util/containers/MapInvariantsTestSuite.java
+3
-4
.../com/intellij/util/containers/MapInvariantsTestSuite.java
platform/util/src/com/intellij/util/containers/ConcurrentFactoryMap.java
+7
-7
...rc/com/intellij/util/containers/ConcurrentFactoryMap.java
with
10 additions
and
11 deletions
+10
-11
platform/platform-tests/testSrc/com/intellij/util/containers/MapInvariantsTestSuite.java
+
3
-
4
View file @
774c187e
...
...
@@ -43,10 +43,9 @@ public class MapInvariantsTestSuite {
Assert
.
assertEquals
(
1
,
map
.
size
());
Assert
.
assertEquals
(
"Removed val differs"
,
val
,
map
.
remove
(
null
));
Assert
.
assertEquals
(
0
,
map
.
size
());
//todo: ConcurrentMap: strange nullability of remove(K, V), replace(K, V), replace(K, V, V)
//map.put(null, val);
//Assert.assertTrue("Removed val differs", map.remove(null, val));
//Assert.assertEquals(0, map.size());
map
.
put
(
null
,
val
);
Assert
.
assertTrue
(
"Removed val differs"
,
map
.
remove
(
null
,
val
));
Assert
.
assertEquals
(
0
,
map
.
size
());
}
@Test
...
...
This diff is collapsed.
Click to expand it.
platform/util/src/com/intellij/util/containers/ConcurrentFactoryMap.java
+
7
-
7
View file @
774c187e
...
...
@@ -175,23 +175,23 @@ public abstract class ConcurrentFactoryMap<K,V> implements ConcurrentMap<K,V> {
}
@Override
public
V
putIfAbsent
(
@NotNull
K
key
,
V
value
)
{
return
myMap
.
putIfAbsent
(
key
,
ConcurrentFactoryMap
.<
V
>
notNull
(
value
));
public
V
putIfAbsent
(
K
key
,
V
value
)
{
return
nullize
(
myMap
.
putIfAbsent
(
ConcurrentFactoryMap
.<
K
>
notNull
(
key
)
,
ConcurrentFactoryMap
.<
V
>
notNull
(
value
))
)
;
}
@Override
public
boolean
remove
(
@NotNull
Object
key
,
Object
value
)
{
return
myMap
.
remove
(
key
,
notNull
(
value
));
public
boolean
remove
(
Object
key
,
Object
value
)
{
return
myMap
.
remove
(
ConcurrentFactoryMap
.<
K
>
notNull
(
key
)
,
ConcurrentFactoryMap
.<
V
>
notNull
(
value
));
}
@Override
public
boolean
replace
(
@NotNull
K
key
,
@NotNull
V
oldValue
,
@NotNull
V
newValue
)
{
return
myMap
.
replace
(
key
,
oldValue
,
newValue
);
public
boolean
replace
(
K
key
,
V
oldValue
,
V
newValue
)
{
return
myMap
.
replace
(
ConcurrentFactoryMap
.<
K
>
notNull
(
key
)
,
ConcurrentFactoryMap
.<
V
>
notNull
(
oldValue
)
,
ConcurrentFactoryMap
.<
V
>
notNull
(
newValue
)
)
;
}
@Override
public
V
replace
(
@NotNull
K
key
,
@NotNull
V
value
)
{
return
myMap
.
replace
(
key
,
value
);
return
nullize
(
myMap
.
replace
(
ConcurrentFactoryMap
.<
K
>
notNull
(
key
)
,
ConcurrentFactoryMap
.<
V
>
notNull
(
value
)
))
;
}
/**
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help