Skip to content

Commit

Permalink
[HZ-1208] Fix persistence config merge from default map
Browse files Browse the repository at this point in the history
When map configuration is created based on "default" map config,
the HotRestart/DataPersistence configurations need to be merged.
Also, the returned MapConfig should bear the name of the requested
map configuration, not "default" or the wildcard based on which it was
created.
  • Loading branch information
Vassilis Bekiaris committed Sep 1, 2022
1 parent 39b1829 commit e7828b8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
import com.hazelcast.config.cp.CPSubsystemConfig;
import com.hazelcast.core.ManagedContext;
import com.hazelcast.internal.config.CacheSimpleConfigReadOnly;
import com.hazelcast.internal.config.DataPersistenceAndHotRestartMerger;
import com.hazelcast.internal.config.ExecutorConfigReadOnly;
import com.hazelcast.internal.config.ExternalDataStoreConfigReadOnly;
import com.hazelcast.internal.config.FlakeIdGeneratorConfigReadOnly;
Expand Down Expand Up @@ -254,7 +255,10 @@ private MapConfig getMapConfigOrNullInternal(String name, String fallbackName) {
}

private MapConfig getMapConfigInternal(String name, String fallbackName) {
return (MapConfig) configSearcher.getConfig(name, fallbackName, supplierFor(MapConfig.class));
MapConfig mapConfig = (MapConfig) configSearcher.getConfig(name, fallbackName, supplierFor(MapConfig.class));
mapConfig = new MapConfig(mapConfig.setName(name));
DataPersistenceAndHotRestartMerger.merge(mapConfig.getHotRestartConfig(), mapConfig.getDataPersistenceConfig());
return mapConfig;
}

@Override
Expand Down
2 changes: 2 additions & 0 deletions hazelcast/src/test/java/com/hazelcast/config/ConfigTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,13 @@ public void testInheritanceFromDefaultConfig() {
assertEqualsStringFormat("Expected %d sync backups, but found %d", 3, binaryMapConfig.getBackupCount());
assertEqualsStringFormat("Expected %s in-memory format, but found %s",
MapConfig.DEFAULT_IN_MEMORY_FORMAT, binaryMapConfig.getInMemoryFormat());
assertEquals("myBinaryMap", binaryMapConfig.getName());

MapConfig objectMapConfig = hz.getConfig().findMapConfig("myObjectMap");
assertEqualsStringFormat("Expected %d sync backups, but found %d", 5, objectMapConfig.getBackupCount());
assertEqualsStringFormat("Expected %s in-memory format, but found %s",
InMemoryFormat.OBJECT, objectMapConfig.getInMemoryFormat());
assertEquals("myObjectMap", objectMapConfig.getName());
}

@Test
Expand Down

0 comments on commit e7828b8

Please sign in to comment.