ImmutableMap.Builder does not allow for duplicate keys, causes build() to fail.
Change-Id: I235ec0f802b3befbfa3e6338e8bd28814eb868c4
Showing
1 changed file
with
4 additions
and
3 deletions
... | @@ -16,6 +16,7 @@ | ... | @@ -16,6 +16,7 @@ |
16 | package org.onosproject.net.driver; | 16 | package org.onosproject.net.driver; |
17 | 17 | ||
18 | import com.google.common.collect.ImmutableMap; | 18 | import com.google.common.collect.ImmutableMap; |
19 | +import com.google.common.collect.Maps; | ||
19 | 20 | ||
20 | import java.util.Map; | 21 | import java.util.Map; |
21 | import java.util.Set; | 22 | import java.util.Set; |
... | @@ -72,8 +73,8 @@ public class DefaultDriver implements Driver { | ... | @@ -72,8 +73,8 @@ public class DefaultDriver implements Driver { |
72 | @Override | 73 | @Override |
73 | public Driver merge(Driver other) { | 74 | public Driver merge(Driver other) { |
74 | // Merge the behaviours. | 75 | // Merge the behaviours. |
75 | - ImmutableMap.Builder<Class<? extends Behaviour>, Class<? extends Behaviour>> | 76 | + Map<Class<? extends Behaviour>, Class<? extends Behaviour>> |
76 | - behaviours = ImmutableMap.builder(); | 77 | + behaviours = Maps.newHashMap(); |
77 | behaviours.putAll(this.behaviours); | 78 | behaviours.putAll(this.behaviours); |
78 | other.behaviours().forEach(b -> behaviours.put(b, other.implementation(b))); | 79 | other.behaviours().forEach(b -> behaviours.put(b, other.implementation(b))); |
79 | 80 | ||
... | @@ -82,7 +83,7 @@ public class DefaultDriver implements Driver { | ... | @@ -82,7 +83,7 @@ public class DefaultDriver implements Driver { |
82 | properties.putAll(this.properties).putAll(other.properties()); | 83 | properties.putAll(this.properties).putAll(other.properties()); |
83 | 84 | ||
84 | return new DefaultDriver(name, manufacturer, hwVersion, swVersion, | 85 | return new DefaultDriver(name, manufacturer, hwVersion, swVersion, |
85 | - behaviours.build(), properties.build()); | 86 | + ImmutableMap.copyOf(behaviours), properties.build()); |
86 | } | 87 | } |
87 | 88 | ||
88 | @Override | 89 | @Override | ... | ... |
-
Please register or login to post a comment