You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by "ptupitsyn (via GitHub)" <gi...@apache.org> on 2023/12/08 10:15:02 UTC

[PR] IGNITE-20952 Ignore static and transient fields in marshaller [ignite-3]

ptupitsyn opened a new pull request, #2935:
URL: https://github.com/apache/ignite-3/pull/2935

   (no comment)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-20952 Ignore static and transient fields in MapperBuilder [ignite-3]

Posted by "AMashenkov (via GitHub)" <gi...@apache.org>.
AMashenkov commented on code in PR #2935:
URL: https://github.com/apache/ignite-3/pull/2935#discussion_r1420356488


##########
modules/schema/src/main/java/org/apache/ignite/internal/schema/marshaller/asm/ObjectMarshallerCodeGenerator.java:
##########
@@ -57,15 +57,22 @@ class ObjectMarshallerCodeGenerator implements MarshallerCodeGenerator {
 
     ObjectMarshallerCodeGenerator(
             MarshallerColumn[] marshallerColumns,
-            Class<?> targetClass,
+            PojoMapper<?> mapper,
             int firstColIdx
     ) {
         this.columns = marshallerColumns;
-        this.targetClass = targetClass;
+        this.targetClass = mapper.targetType();
         columnAccessors = new ColumnAccessCodeGenerator[columns.length];
 
-        Map<String, Field> flds = Arrays.stream(targetClass.getDeclaredFields())
-                .collect(Collectors.toMap(f -> f.getName().toUpperCase(), Function.identity()));
+        Map<String, Field> flds = new HashMap<>();
+        for (String fieldName : mapper.fields()) {
+            try {
+                Field field = mapper.targetType().getDeclaredField(fieldName);
+                flds.put(fieldName.toUpperCase(), field);
+            } catch (NoSuchFieldException e) {
+                throw new RuntimeException(e);

Review Comment:
   Let's throw an IgniteException here.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-20952 Ignore static and transient fields in MapperBuilder [ignite-3]

Posted by "ptupitsyn (via GitHub)" <gi...@apache.org>.
ptupitsyn commented on code in PR #2935:
URL: https://github.com/apache/ignite-3/pull/2935#discussion_r1420406203


##########
modules/schema/src/main/java/org/apache/ignite/internal/schema/marshaller/asm/ObjectMarshallerCodeGenerator.java:
##########
@@ -57,15 +57,22 @@ class ObjectMarshallerCodeGenerator implements MarshallerCodeGenerator {
 
     ObjectMarshallerCodeGenerator(
             MarshallerColumn[] marshallerColumns,
-            Class<?> targetClass,
+            PojoMapper<?> mapper,
             int firstColIdx
     ) {
         this.columns = marshallerColumns;
-        this.targetClass = targetClass;
+        this.targetClass = mapper.targetType();
         columnAccessors = new ColumnAccessCodeGenerator[columns.length];
 
-        Map<String, Field> flds = Arrays.stream(targetClass.getDeclaredFields())
-                .collect(Collectors.toMap(f -> f.getName().toUpperCase(), Function.identity()));
+        Map<String, Field> flds = new HashMap<>();
+        for (String fieldName : mapper.fields()) {
+            try {
+                Field field = mapper.targetType().getDeclaredField(fieldName);
+                flds.put(fieldName.toUpperCase(), field);
+            } catch (NoSuchFieldException e) {
+                throw new RuntimeException(e);

Review Comment:
   We don't have an error code for this, and I'm not sure if we need one.
   
   Replaced with `IllegalArgumentException` to match the behavior in other places in this class, added an explanation.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-20952 Ignore static and transient fields in MapperBuilder [ignite-3]

Posted by "ptupitsyn (via GitHub)" <gi...@apache.org>.
ptupitsyn merged PR #2935:
URL: https://github.com/apache/ignite-3/pull/2935


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org