From deb948e3680a278125a67d3120fae7797a7e8341 Mon Sep 17 00:00:00 2001 From: Denis Stepanov Date: Tue, 27 Feb 2024 11:37:25 +0100 Subject: [PATCH] Micronaut 4.4 changes --- gradle/libs.versions.toml | 2 +- .../support/deserializers/DeserBean.java | 146 ++++++++---------- .../SpecificObjectDeserializer.java | 14 +- .../serde/support/serializers/SerBean.java | 37 ++--- .../serde/MockSerdeIntrospections.groovy | 4 +- 5 files changed, 92 insertions(+), 111 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 018e1492d..6baa1212e 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -16,7 +16,7 @@ jetbrains-annotations = "24.1.0" jmh = "1.37" groovy = "4.0.18" -micronaut = "4.3.3" +micronaut = "4.4.999-SNAPSHOT" micronaut-platform = "4.2.4" micronaut-docs = "2.0.0" micronaut-test = "4.2.0" diff --git a/serde-support/src/main/java/io/micronaut/serde/support/deserializers/DeserBean.java b/serde-support/src/main/java/io/micronaut/serde/support/deserializers/DeserBean.java index c107bece6..3ecb18e37 100644 --- a/serde-support/src/main/java/io/micronaut/serde/support/deserializers/DeserBean.java +++ b/serde-support/src/main/java/io/micronaut/serde/support/deserializers/DeserBean.java @@ -25,7 +25,8 @@ import io.micronaut.core.beans.BeanIntrospection; import io.micronaut.core.beans.BeanMethod; import io.micronaut.core.beans.BeanProperty; -import io.micronaut.core.beans.UnsafeBeanProperty; +import io.micronaut.core.beans.BeanWriteProperty; +import io.micronaut.core.beans.UnsafeBeanWriteProperty; import io.micronaut.core.bind.annotation.Bindable; import io.micronaut.core.convert.ConversionService; import io.micronaut.core.convert.exceptions.ConversionErrorException; @@ -83,7 +84,7 @@ final class DeserBean { @Nullable public final DerProperty[] unwrappedProperties; @Nullable - public final AnySetter anySetter; + public final AnySetter anySetter; @Nullable public final String wrapperProperty; @Nullable @@ -167,13 +168,13 @@ public DeserBean(DeserializationConfiguration defaultDeserializationConfiguratio } List> creatorUnwrapped = null; - AnySetter anySetterValue = null; + AnySetter anySetterValue = null; List> unwrappedProperties = null; for (int i = 0; i < constructorArguments.length; i++) { Argument constructorArgument = resolveArgument((Argument) constructorArguments[i]); final AnnotationMetadata annotationMetadata = resolveArgumentMetadata(introspection, constructorArgument, constructorArgument.getAnnotationMetadata()); if (annotationMetadata.isAnnotationPresent(SerdeConfig.SerAnySetter.class)) { - anySetterValue = new AnySetter<>(constructorArgument, i); + anySetterValue = new AnySetter(constructorArgument, i); continue; } @@ -271,13 +272,14 @@ public DeserBean(DeserializationConfiguration defaultDeserializationConfiguratio } if (anySetterValue == null) { - anySetterValue = (anySetter != null ? new AnySetter(anySetter) : null); + anySetterValue = (anySetter != null ? new AnySetter((BeanMethod) anySetter) : null); } - if (!introspection.getBeanProperties().isEmpty() || !jsonSetters.isEmpty()) { + Collection> beanProperties = introspection.getBeanWriteProperties(); + if (!beanProperties.isEmpty() || !jsonSetters.isEmpty()) { PropertiesBag.Builder readPropertiesBuilder = new PropertiesBag.Builder<>(introspection); int i = -1; - for (BeanProperty beanProperty : introspection.getBeanProperties()) { + for (BeanWriteProperty beanProperty : beanProperties) { final AnnotationMetadata annotationMetadata = beanProperty.getAnnotationMetadata(); final String propertyName = resolveName( serdeArgumentConf, @@ -292,9 +294,6 @@ public DeserBean(DeserializationConfiguration defaultDeserializationConfiguratio if (creatorParams != null && creatorParams.propertyIndexOf(propertyName) != -1) { continue; } - if (beanProperty.isReadOnly()) { - continue; - } if (isIgnored(beanProperty) || allowPropertyPredicate != null && !allowPropertyPredicate.test(propertyName)) { ignoredProperties.add(propertyName); continue; @@ -305,7 +304,7 @@ public DeserBean(DeserializationConfiguration defaultDeserializationConfiguratio ignoredProperties.remove(propertyName); if (annotationMetadata.isAnnotationPresent(SerdeConfig.SerAnySetter.class)) { - anySetterValue = new AnySetter(beanProperty); + anySetterValue = new AnySetter((BeanWriteProperty) beanProperty); } else { final boolean isUnwrapped = annotationMetadata.hasAnnotation(SerdeConfig.SerUnwrapped.class); final Argument propertyArgument = resolveArgument(beanProperty.asArgument()); @@ -459,7 +458,7 @@ private boolean isSimpleBean() { } if (injectProperties != null) { for (DerProperty property : injectProperties.getProperties()) { - if (property.isAnySetter || property.views != null || property.managedRef != null || introspection != property.instrospection || property.backRef != null || property.beanProperty == null) { + if (property.isAnySetter || property.views != null || property.managedRef != null || introspection != property.introspection || property.backRef != null || property.beanProperty == null) { return false; } } @@ -473,7 +472,7 @@ private boolean isRecordLikeBean() { } if (creatorParams != null) { for (DerProperty property : creatorParams.getProperties()) { - if (property.beanProperty != null && !property.beanProperty.isReadOnly() || property.isAnySetter || property.views != null || property.managedRef != null || introspection != property.instrospection || property.backRef != null) { + if (property.beanProperty != null || property.isAnySetter || property.views != null || property.managedRef != null || introspection != property.introspection || property.backRef != null) { return false; } } @@ -610,27 +609,24 @@ private boolean isIgnored(AnnotationMetadata annotationMetadata) { || annotationMetadata.booleanValue(SerdeConfig.class, SerdeConfig.IGNORED_DESERIALIZATION).orElse(false); } - static final class AnySetter { + static final class AnySetter { // CHECKSTYLE:OFF - final Argument valueType; - private final BiConsumer> mapSetter; - private final TriConsumer valueSetter; + final Argument valueType; + private final BiConsumer> mapSetter; + private final TriConsumer valueSetter; // Null when DeserBean not initialized - public Deserializer deserializer; + public Deserializer deserializer; public final boolean constructorArgument; // CHECKSTYLE:ON - private AnySetter(BeanMethod anySetter) { + private AnySetter(BeanMethod anySetter) { final Argument[] arguments = anySetter.getArguments(); // if the argument length is 1 we are dealing with a map parameter // otherwise we are dealing with 2 parameter variant final boolean singleArg = arguments.length == 1; - final Argument argument = - (Argument) (singleArg ? arguments[0].getTypeVariable("V").orElse(Argument.OBJECT_ARGUMENT) : arguments[1]); - this.valueType = argument; -// this.deserializer = argument.equalsType(Argument.OBJECT_ARGUMENT) ? null : findDeserializer(decoderContext, argument); + this.valueType = (Argument) (singleArg ? arguments[0].getTypeVariable("V").orElse(Argument.OBJECT_ARGUMENT) : arguments[1]); if (singleArg) { this.valueSetter = null; this.mapSetter = anySetter::invoke; @@ -641,31 +637,25 @@ private AnySetter(BeanMethod anySetter) { constructorArgument = false; } - private AnySetter(BeanProperty anySetter) { + private AnySetter(BeanWriteProperty anySetter) { // if the argument length is 1 we are dealing with a map parameter // otherwise we are dealing with 2 parameter variant - final Argument argument = (Argument) anySetter.asArgument().getTypeVariable("V").orElse(Argument.OBJECT_ARGUMENT); - this.valueType = argument; -// this.deserializer = argument.equalsType(Argument.OBJECT_ARGUMENT) ? null : findDeserializer(decoderContext, argument); + this.valueType = (Argument) anySetter.asArgument().getTypeVariable("V").orElse(Argument.OBJECT_ARGUMENT); this.mapSetter = anySetter::set; this.valueSetter = null; this.constructorArgument = false; } - private AnySetter(Argument anySetter, int index) throws SerdeException { + private AnySetter(Argument anySetter, int index) { // if the argument length is 1 we are dealing with a map parameter // otherwise we are dealing with 2 parameter variant - final Argument argument = (Argument) anySetter.getTypeVariable("V").orElse(Argument.OBJECT_ARGUMENT); - this.valueType = argument; -// this.deserializer = argument.equalsType(Argument.OBJECT_ARGUMENT) ? null : findDeserializer(decoderContext, argument); - this.mapSetter = (o, map) -> { - ((Object[]) o)[index] = map; - }; + this.valueType = (Argument) anySetter.getTypeVariable("V").orElse(Argument.OBJECT_ARGUMENT); + this.mapSetter = (o, map) -> ((Object[]) o)[index] = map; this.valueSetter = null; this.constructorArgument = true; } - void bind(Map values, Object object) { + void bind(Map values, Object object) { if (values != null) { if (mapSetter != null) { mapSetter.accept(object, values); @@ -691,7 +681,7 @@ private interface TriConsumer { @Internal // CHECKSTYLE:OFF public static final class DerProperty { - public final BeanIntrospection instrospection; + public final BeanIntrospection introspection; public final int index; public final Argument

argument; @Nullable @@ -707,7 +697,7 @@ public static final class DerProperty { public final String[] aliases; @Nullable - public final UnsafeBeanProperty beanProperty; + public final UnsafeBeanWriteProperty beanProperty; public final DeserBean

unwrapped; public final DerProperty unwrappedProperty; @@ -718,14 +708,14 @@ public static final class DerProperty { public Deserializer

deserializer; DerProperty(ConversionService conversionService, - BeanIntrospection introspection, - int index, - String property, - Argument

argument, - @Nullable BeanProperty beanProperty, - @Nullable BeanMethod beanMethod, - @Nullable DeserBean

unwrapped, - @Nullable DerProperty unwrappedProperty) throws SerdeException { + BeanIntrospection introspection, + int index, + String property, + Argument

argument, + @Nullable BeanWriteProperty beanProperty, + @Nullable BeanMethod beanMethod, + @Nullable DeserBean

unwrapped, + @Nullable DerProperty unwrappedProperty) throws SerdeException { this(conversionService, introspection, index, @@ -740,16 +730,16 @@ public static final class DerProperty { } DerProperty(ConversionService conversionService, - BeanIntrospection instrospection, - int index, - String property, - Argument

argument, - AnnotationMetadata argumentMetadata, - @Nullable BeanProperty beanProperty, - @Nullable BeanMethod beanMethod, - @Nullable DeserBean

unwrapped, - @Nullable DerProperty unwrappedProperty) throws SerdeException { - this.instrospection = instrospection; + BeanIntrospection introspection, + int index, + String property, + Argument

argument, + AnnotationMetadata argumentMetadata, + @Nullable BeanWriteProperty beanProperty, + @Nullable BeanMethod beanMethod, + @Nullable DeserBean

unwrapped, + @Nullable DerProperty unwrappedProperty) throws SerdeException { + this.introspection = introspection; this.index = index; this.argument = argument; Class type = argument.getType(); @@ -760,15 +750,15 @@ public static final class DerProperty { this.nonNull = argument.isNonNull(); this.nullable = argument.isNullable(); if (beanProperty != null) { - this.beanProperty = (UnsafeBeanProperty) beanProperty; + this.beanProperty = (UnsafeBeanWriteProperty) beanProperty; } else if (beanMethod != null) { this.beanProperty = new BeanMethodAsBeanProperty<>(property, beanMethod); } else { this.beanProperty = null; } // compute default - AnnotationMetadata annotationMetadata = resolveArgumentMetadata(instrospection, argument, argumentMetadata); - this.views = SerdeAnnotationUtil.resolveViews(instrospection, annotationMetadata); + AnnotationMetadata annotationMetadata = resolveArgumentMetadata(introspection, argument, argumentMetadata); + this.views = SerdeAnnotationUtil.resolveViews(introspection, annotationMetadata); try { this.defaultValue = annotationMetadata @@ -776,7 +766,7 @@ public static final class DerProperty { .map(s -> conversionService.convertRequired(s, argument)) .orElse(null); } catch (ConversionErrorException e) { - throw new SerdeException((index > -1 ? "Constructor Argument" : "Property") + " [" + argument + "] of type [" + instrospection.getBeanType().getName() + "] defines an invalid default value", e); + throw new SerdeException((index > -1 ? "Constructor Argument" : "Property") + " [" + argument + "] of type [" + introspection.getBeanType().getName() + "] defines an invalid default value", e); } this.unwrapped = unwrapped; this.unwrappedProperty = unwrappedProperty; @@ -797,7 +787,7 @@ public static final class DerProperty { public void setDefaultPropertyValue(Deserializer.DecoderContext decoderContext, @NonNull B bean) throws SerdeException { if (explicitlyRequired) { - throw new SerdeException("Unable to deserialize type [" + instrospection.getBeanType().getName() + "]. Required property [" + argument + + throw new SerdeException("Unable to deserialize type [" + introspection.getBeanType().getName() + "]. Required property [" + argument + "] is not present in supplied data"); } P value = provideDefaultValue(decoderContext); @@ -808,7 +798,7 @@ public void setDefaultPropertyValue(Deserializer.DecoderContext decoderContext, public void setDefaultConstructorValue(Deserializer.DecoderContext decoderContext, @NonNull Object[] params) throws SerdeException { if (explicitlyRequired) { - throw new SerdeException("Unable to deserialize type [" + instrospection.getBeanType().getName() + "]. Required constructor parameter [" + argument + "] at index [" + index + "] is not present or is null in the supplied data"); + throw new SerdeException("Unable to deserialize type [" + introspection.getBeanType().getName() + "]. Required constructor parameter [" + argument + "] at index [" + index + "] is not present or is null in the supplied data"); } params[index] = provideDefaultValue(decoderContext, mustSetField || argument.isPrimitive()); } @@ -827,7 +817,7 @@ public void deserializeAndSetConstructorValue(Decoder objectDecoder, Deserialize } catch (InvalidFormatException e) { throw new InvalidPropertyFormatException(e, argument); } catch (Exception e) { - throw new SerdeException("Error decoding property [" + argument + "] of type [" + instrospection.getBeanType() + "]: " + e.getMessage(), e); + throw new SerdeException("Error decoding property [" + argument + "] of type [" + introspection.getBeanType() + "]: " + e.getMessage(), e); } } @@ -841,7 +831,7 @@ public void deserializeAndSetPropertyValue(Decoder objectDecoder, Deserializer.D } catch (InvalidFormatException e) { throw new InvalidPropertyFormatException(e, argument); } catch (Exception e) { - throw new SerdeException("Error decoding property [" + argument + "] of type [" + instrospection.getBeanType() + "]: " + e.getMessage(), e); + throw new SerdeException("Error decoding property [" + argument + "] of type [" + introspection.getBeanType() + "]: " + e.getMessage(), e); } } @@ -854,7 +844,7 @@ public void deserializeAndCallBuilder(Decoder objectDecoder, Deserializer.Decode } catch (InvalidFormatException e) { throw new InvalidPropertyFormatException(e, argument); } catch (Exception e) { - throw new SerdeException("Error decoding property [" + argument + "] of type [" + instrospection.getBeanType() + "]: " + e.getMessage(), e); + throw new SerdeException("Error decoding property [" + argument + "] of type [" + introspection.getBeanType() + "]: " + e.getMessage(), e); } } @@ -864,7 +854,7 @@ private P deserializeValue(Decoder objectDecoder, Deserializer.DecoderContext de return value; } if (explicitlyRequired) { - throw new SerdeException("Unable to deserialize type [" + instrospection.getBeanType().getName() + "]. Required property [" + argument + + throw new SerdeException("Unable to deserialize type [" + introspection.getBeanType().getName() + "]. Required property [" + argument + "] is not present in supplied data"); } return provideDefaultValue(decoderContext); @@ -884,15 +874,15 @@ private P provideDefaultValue(Deserializer.DecoderContext decoderContext, boolea } - private static AnnotationMetadata resolveArgumentMetadata(BeanIntrospection instrospection, Argument

argument, AnnotationMetadata annotationMetadata) { + private static AnnotationMetadata resolveArgumentMetadata(BeanIntrospection introspection, Argument

argument, AnnotationMetadata annotationMetadata) { // records store metadata in the bean property - final AnnotationMetadata propertyMetadata = instrospection.getProperty(argument.getName(), argument.getType()) + final AnnotationMetadata propertyMetadata = introspection.getProperty(argument.getName(), argument.getType()) .map(BeanProperty::getAnnotationMetadata) .orElse(AnnotationMetadata.EMPTY_METADATA); return new AnnotationMetadataHierarchy(propertyMetadata, annotationMetadata); } - private static final class BeanMethodAsBeanProperty implements UnsafeBeanProperty { + private static final class BeanMethodAsBeanProperty implements UnsafeBeanWriteProperty { private final String name; private final BeanMethod beanMethod; @@ -906,16 +896,6 @@ public BeanMethodAsBeanProperty(String name, BeanMethod beanMethod) { this.type = argument.getType(); } - @Override - public boolean isReadOnly() { - return true; - } - - @Override - public P getUnsafe(B bean) { - throw new IllegalStateException("Not supported"); - } - @Override public B withValueUnsafe(B bean, P value) { throw new IllegalStateException("Not supported"); @@ -932,8 +912,14 @@ public BeanIntrospection getDeclaringBean() { } @Override - public P get(B bean) { - throw new IllegalStateException("Not supported"); + public B withValue(@NonNull B bean, @Nullable P value) { + setUnsafe(bean, value); + return bean; + } + + @Override + public void set(@NonNull B bean, @Nullable P value) { + setUnsafe(bean, value); } @Override diff --git a/serde-support/src/main/java/io/micronaut/serde/support/deserializers/SpecificObjectDeserializer.java b/serde-support/src/main/java/io/micronaut/serde/support/deserializers/SpecificObjectDeserializer.java index b62ad55a5..a8924a1cc 100644 --- a/serde-support/src/main/java/io/micronaut/serde/support/deserializers/SpecificObjectDeserializer.java +++ b/serde-support/src/main/java/io/micronaut/serde/support/deserializers/SpecificObjectDeserializer.java @@ -273,7 +273,7 @@ private static void deserializeAndSetPropertyValue(DecoderContext decoderContext decoderContext.pushManagedRef( new PropertyReference<>( derProperty.managedRef, - derProperty.instrospection, + derProperty.introspection, derProperty.argument, instance ) @@ -314,10 +314,10 @@ private static Object deserializeValue(DecoderContext decoderContext, */ private static final class AnyValuesDeserializer { - private final DeserBean.AnySetter anySetter; + private final DeserBean.AnySetter anySetter; private Map values; - AnyValuesDeserializer(DeserBean.AnySetter anySetter) { + AnyValuesDeserializer(DeserBean.AnySetter anySetter) { this.anySetter = anySetter; } @@ -425,7 +425,7 @@ void injectProperties(Object instance, DecoderContext decoderContext) throws IOE final PropertyReference ref = decoderContext.resolveReference( new PropertyReference<>( property.backRef, - property.instrospection, + property.introspection, property.argument, null ) @@ -521,7 +521,7 @@ boolean tryConsumeAndSet(String propertyName, Decoder decoder, DecoderContext de final PropertyReference ref = decoderContext.resolveReference( new PropertyReference<>( property.backRef, - property.instrospection, + property.introspection, property.argument, instance ) @@ -677,7 +677,7 @@ boolean tryConsume(String propertyName, Decoder decoder, DecoderContext decoderC final PropertyReference ref = decoderContext.resolveReference( new PropertyReference<>( property.backRef, - property.instrospection, + property.introspection, property.argument, null ) @@ -749,7 +749,7 @@ Object[] getValues(DecoderContext decoderContext) throws IOException { final PropertyReference ref = decoderContext.resolveReference( new PropertyReference<>( property.backRef, - property.instrospection, + property.introspection, property.argument, null ) diff --git a/serde-support/src/main/java/io/micronaut/serde/support/serializers/SerBean.java b/serde-support/src/main/java/io/micronaut/serde/support/serializers/SerBean.java index 97d369412..c722eb13f 100644 --- a/serde-support/src/main/java/io/micronaut/serde/support/serializers/SerBean.java +++ b/serde-support/src/main/java/io/micronaut/serde/support/serializers/SerBean.java @@ -24,8 +24,8 @@ import io.micronaut.core.annotation.Order; import io.micronaut.core.beans.BeanIntrospection; import io.micronaut.core.beans.BeanMethod; -import io.micronaut.core.beans.BeanProperty; -import io.micronaut.core.beans.UnsafeBeanProperty; +import io.micronaut.core.beans.BeanReadProperty; +import io.micronaut.core.beans.UnsafeBeanReadProperty; import io.micronaut.core.beans.exceptions.IntrospectionException; import io.micronaut.core.naming.NameUtils; import io.micronaut.core.order.OrderUtil; @@ -62,7 +62,7 @@ @Internal final class SerBean { - private static final Comparator> BEAN_PROPERTY_COMPARATOR = (o1, o2) -> OrderUtil.COMPARATOR.compare( + private static final Comparator> BEAN_PROPERTY_COMPARATOR = (o1, o2) -> OrderUtil.COMPARATOR.compare( new Ordered() { @Override public int getOrder() { @@ -122,15 +122,15 @@ public int getOrder() { Predicate argumentPropertyPredicate = serdeArgumentConf == null ? null : serdeArgumentConf.resolveAllowPropertyPredicate(allowIgnoredProperties); PropertyNamingStrategy entityPropertyNamingStrategy = getPropertyNamingStrategy(introspection, encoderContext, null); - final Collection, AnnotationMetadata>> properties = - introspection.getBeanProperties().stream() + final Collection, AnnotationMetadata>> properties = + introspection.getBeanReadProperties().stream() .filter(this::filterProperty) - .sorted(getPropertyComparator()) + .sorted(BEAN_PROPERTY_COMPARATOR) .map(beanProperty -> { Optional> constructorArgument = Arrays.stream(introspection.getConstructor().getArguments()) .filter(a -> a.getName().equals(beanProperty.getName()) && a.getType().equals(beanProperty.getType())) .findFirst(); - return constructorArgument., AnnotationMetadata>>map(argument -> new AbstractMap.SimpleEntry<>( + return constructorArgument., AnnotationMetadata>>map(argument -> new AbstractMap.SimpleEntry<>( beanProperty, new AnnotationMetadataHierarchy(argument.getAnnotationMetadata(), beanProperty.getAnnotationMetadata()) )).orElseGet(() -> new AbstractMap.SimpleEntry<>( @@ -139,12 +139,12 @@ public int getOrder() { )); }) .toList(); - final Map.Entry, AnnotationMetadata> serPropEntry = properties.stream() + final Map.Entry, AnnotationMetadata> serPropEntry = properties.stream() .filter(bp -> bp.getValue().hasAnnotation(SerdeConfig.SerValue.class) || bp.getValue().hasAnnotation(JACKSON_VALUE)) .findFirst().orElse(null); if (serPropEntry != null) { wrapperProperty = null; - BeanProperty beanProperty = serPropEntry.getKey(); + BeanReadProperty beanProperty = serPropEntry.getKey(); final Argument serType = beanProperty.asArgument(); AnnotationMetadata propertyAnnotationMetadata = serPropEntry.getValue(); jsonValue = new PropSerProperty<>( @@ -213,8 +213,8 @@ public int getOrder() { } }); } - for (Map.Entry, AnnotationMetadata> propWithAnnotations : properties) { - final BeanProperty property = propWithAnnotations.getKey(); + for (Map.Entry, AnnotationMetadata> propWithAnnotations : properties) { + final BeanReadProperty property = propWithAnnotations.getKey(); final Argument argument = property.asArgument(); final AnnotationMetadata propertyAnnotationMetadata = propWithAnnotations.getValue(); PropertyNamingStrategy propertyNamingStrategy = getPropertyNamingStrategy(property.getAnnotationMetadata(), encoderContext, entityPropertyNamingStrategy); @@ -440,10 +440,6 @@ private PropertyNamingStrategy getPropertyNamingStrategy(AnnotationMetadata anno return namingStrategyClass == null ? defaultNamingStrategy : encoderContext.findNamingStrategy(namingStrategyClass); } - private Comparator> getPropertyComparator() { - return BEAN_PROPERTY_COMPARATOR; - } - private String resolveName(AnnotationMetadata propertyAnnotationMetadata, String name, @Nullable @@ -485,20 +481,19 @@ private PropertyFilter getPropertyFilterIfPresent(@Nullable BeanContext beanCont return null; } - private boolean filterProperty(BeanProperty property) { - return !property.isWriteOnly() - && !property.booleanValue(SerdeConfig.class, SerdeConfig.IGNORED).orElse(false) + private boolean filterProperty(BeanReadProperty property) { + return !property.booleanValue(SerdeConfig.class, SerdeConfig.IGNORED).orElse(false) && !property.booleanValue(SerdeConfig.class, SerdeConfig.IGNORED_SERIALIZATION).orElse(false) && !property.booleanValue(SerdeConfig.class, SerdeConfig.WRITE_ONLY).orElse(false); } static final class PropSerProperty extends SerProperty { - private final UnsafeBeanProperty beanProperty; + private final UnsafeBeanReadProperty beanProperty; - public PropSerProperty(SerBean bean, String name, String originalName, Argument

argument, AnnotationMetadata annotationMetadata, BeanProperty beanProperty) { + public PropSerProperty(SerBean bean, String name, String originalName, Argument

argument, AnnotationMetadata annotationMetadata, BeanReadProperty beanProperty) { super(bean, name, originalName, argument, annotationMetadata); - this.beanProperty = (UnsafeBeanProperty) beanProperty; + this.beanProperty = (UnsafeBeanReadProperty) beanProperty; } @Override diff --git a/serde-tck/src/main/groovy/io/micronaut/serde/MockSerdeIntrospections.groovy b/serde-tck/src/main/groovy/io/micronaut/serde/MockSerdeIntrospections.groovy index eaea28379..33494d2b5 100644 --- a/serde-tck/src/main/groovy/io/micronaut/serde/MockSerdeIntrospections.groovy +++ b/serde-tck/src/main/groovy/io/micronaut/serde/MockSerdeIntrospections.groovy @@ -48,7 +48,7 @@ class MockSerdeIntrospections extends DefaultSerdeIntrospections { f.setAccessible(true) def files = f.get(classLoader) def resolvedTypes = files.findAll({ JavaFileObject jfo -> - jfo.name.contains('$IntrospectionRef') + jfo.name.contains('$Introspection') }).collect( { JavaFileObject jfo -> String className = jfo.name.substring(14, jfo.name.length() - 6).replace('/', '.') try { @@ -108,7 +108,7 @@ class MockSerdeIntrospections extends DefaultSerdeIntrospections { f.setAccessible(true) def files = f.get(classLoader) def resolvedTypes = files.findAll({ JavaFileObject jfo -> - jfo.name.endsWith('$IntrospectionRef.class') + jfo.name.endsWith('$Introspection.class') }).collect( { JavaFileObject jfo -> String className = jfo.name.substring(14, jfo.name.length() - 6).replace('/', '.') classLoader.loadClass(className)