microstream icon indicating copy to clipboard operation
microstream copied to clipboard

After changing Set to Lazy<Set> we get Incompatible types: java.util.Set -> one.microstream.reference.Lazy

Open c-koell opened this issue 2 years ago • 3 comments

Environment Details

  • MicroStream Version: 07.00.00-MS-GA
  • JDK version: OpenJDK 17
  • OS: Windows 10
  • Used frameworks: MicroStream CDI on OpenLiberty

Describe the bug

I have tested a little bit and tried to change the Set of the Root Object to a Layz Set

[INFO] one.microstream.persistence.binary.exceptions.BinaryPersistenceException: Incompatible types: java.util.Set -> one.microstream.reference.Lazy
[INFO] 	at one.microstream.persistence.binary.types.BinaryValueTranslatorProvider$Default.validateCompatibleTargetType(BinaryValueTranslatorProvider.java:238)
[INFO] 	at one.microstream.persistence.binary.types.BinaryValueTranslatorProvider$Default.provideValueTranslator(BinaryValueTranslatorProvider.java:226)
[INFO] 	at one.microstream.persistence.binary.types.BinaryValueTranslatorProvider$Default.provideTargetValueTranslator(BinaryValueTranslatorProvider.java:354)
[INFO] 	at one.microstream.persistence.binary.types.BinaryLegacyTypeHandlerCreator$Default.deriveValueTranslators(BinaryLegacyTypeHandlerCreator.java:162)
[INFO] 	at one.microstream.persistence.binary.types.BinaryLegacyTypeHandlerCreator$Default.deriveReflectiveHandler(BinaryLegacyTypeHandlerCreator.java:254)
[INFO] 	at one.microstream.persistence.binary.types.BinaryLegacyTypeHandlerCreator$Default.deriveReflectiveHandler(BinaryLegacyTypeHandlerCreator.java:1)
[INFO] 	at one.microstream.persistence.types.PersistenceLegacyTypeHandlerCreator$Abstract.createLegacyTypeHandler(PersistenceLegacyTypeHandlerCreator.java:125)
[INFO] 	at one.microstream.persistence.types.PersistenceLegacyTypeMapper$Default.createLegacyTypeHandler(PersistenceLegacyTypeMapper.java:200)
[INFO] 	at one.microstream.persistence.types.PersistenceLegacyTypeMapper$Default.ensureLegacyTypeHandler(PersistenceLegacyTypeMapper.java:400)
[INFO] 	at one.microstream.persistence.types.PersistenceTypeHandlerManager$Default.ensureLegacyTypeHandler(PersistenceTypeHandlerManager.java:468)
[INFO] 	at one.microstream.persistence.types.PersistenceTypeHandlerManager$Default.ensureTypeHandler(PersistenceTypeHandlerManager.java:459)
[INFO] 	at one.microstream.persistence.types.PersistenceTypeHandlerManager$Default.lambda$2(PersistenceTypeHandlerManager.java:493)
[INFO] 	at one.microstream.collections.ChainStorageStrong.iterate(ChainStorageStrong.java:1335)
[INFO] 	at one.microstream.collections.HashEnum.iterate(HashEnum.java:701)
[INFO] 	at one.microstream.persistence.types.PersistenceTypeHandlerManager$Default.ensureTypeHandlers(PersistenceTypeHandlerManager.java:492)
[INFO] 	at one.microstream.persistence.types.PersistenceTypeHandlerManager$Default.ensureTypeHandlersByTypeIds(PersistenceTypeHandlerManager.java:484)
[INFO] 	at one.microstream.storage.embedded.types.EmbeddedStorageManager$Default.ensureRequiredTypeHandlers(EmbeddedStorageManager.java:340)
[INFO] 	at one.microstream.storage.embedded.types.EmbeddedStorageManager$Default.start(EmbeddedStorageManager.java:250)
[INFO] 	at one.microstream.storage.embedded.types.EmbeddedStorageManager$Default.start(EmbeddedStorageManager.java:1)
[INFO] 	at one.microstream.storage.embedded.types.EmbeddedStorageFoundation.start(EmbeddedStorageFoundation.java:244)
[INFO] 	at one.microstream.storage.embedded.types.EmbeddedStorageFoundation.start(EmbeddedStorageFoundation.java:212)
[INFO] 	at one.microstream.integrations.cdi.types.StorageManagerProducer.getStoreManager(StorageManagerProducer.java:63)
[INFO] 	at jdk.internal.reflect.GeneratedMethodAccessor1476.invoke(Unknown Source)
[INFO] 	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
[INFO] 	at org.jboss.weld.injection.StaticMethodInjectionPoint.invoke(StaticMethodInjectionPoint.java:95)

To Reproduce

Change the internal Type to a Layze Type

Expected behavior

Hmm i think it should be possible or not ?

c-koell avatar May 06 '22 08:05 c-koell

Hi @c-koell ,

The exception is expected since the type that is associated with the data when it is stored in the past, does not match with the current types in the application in this run. It is not like the standard JVM serialization that it just accepts anything that is stored. We avoid all kinds of security vulnerabilities .

You have the option to map the types, from Set to Lazy<Set> but this mapping is performed at all levels and not only for the rot object. See for an explanation https://docs.microstream.one/manual/5.0/storage/legacy-type-mapping/index.html#_explicit_mapping_of_classes

rdebusscher avatar May 09 '22 07:05 rdebusscher

We can think about a feature that allows for code changes like in your case as it probably makes sense that at some point you sometimes want to start using Lazy<T> types when the data grows.

rdebusscher avatar May 09 '22 07:05 rdebusscher

@rdebusscher that would be cool. I Think it is a normal evolve that you change at a later time to lazy.

c-koell avatar May 09 '22 08:05 c-koell