You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "Sharad Agarwal (JIRA)" <ji...@apache.org> on 2009/07/15 05:12:14 UTC

[jira] Created: (AVRO-78) 'reflect' implementation works only with public fields

'reflect' implementation works only with public fields
------------------------------------------------------

                 Key: AVRO-78
                 URL: https://issues.apache.org/jira/browse/AVRO-78
             Project: Avro
          Issue Type: Bug
          Components: java
            Reporter: Sharad Agarwal


As per the documentation 'reflect' implementation should work for Class#getDeclaredFields() 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (AVRO-78) 'reflect' implementation works only with public fields

Posted by "Doug Cutting (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/AVRO-78?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Doug Cutting updated AVRO-78:
-----------------------------

    Resolution: Fixed
        Status: Resolved  (was: Patch Available)

I just committed this.

> 'reflect' implementation works only with public fields
> ------------------------------------------------------
>
>                 Key: AVRO-78
>                 URL: https://issues.apache.org/jira/browse/AVRO-78
>             Project: Avro
>          Issue Type: Bug
>          Components: java
>    Affects Versions: 1.0.0
>            Reporter: Sharad Agarwal
>            Assignee: Doug Cutting
>             Fix For: 1.0.1
>
>         Attachments: AVRO-78.patch
>
>
> As per the documentation 'reflect' implementation should work for Class#getDeclaredFields() 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (AVRO-78) 'reflect' implementation works only with public fields

Posted by "Sharad Agarwal (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/AVRO-78?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12731261#action_12731261 ] 

Sharad Agarwal commented on AVRO-78:
------------------------------------

Testcase:
{code}
class TestReflect {
....

@Test
  public void testRefRecord() throws IOException {
    Schema schm = ReflectData.getSchema(RefRecord.class);
    Class<?> clazz = RefRecord.class;
    String prefix =  
      ((clazz.getEnclosingClass() == null 
          || "null".equals(clazz.getEnclosingClass())) ? 
            clazz.getPackage().getName() + "." 
            : (clazz.getEnclosingClass().getName() + "$"));
    ReflectDatumWriter writer = new ReflectDatumWriter(schm);
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    RefRecord rec = new RefRecord();
    rec.x = 5;
    rec.y = 10;
    writer.write(rec, new BinaryEncoder(out));
    ReflectDatumReader reader = new ReflectDatumReader(schm, prefix);
    Object decoded =
      reader.read(null, new BinaryDecoder(
          new ByteArrayInputStream(out.toByteArray())));
    assertEquals(rec, decoded);
  }

  public static class RefRecord {
    public int x = 1;
    private int y = 2;

    public int hashCode() {
      return x + y;
    }

    public boolean equals(Object obj) {
      if (this == obj)
        return true;
      if (obj == null)
        return false;
      if (getClass() != obj.getClass())
        return false;
      final RefRecord other = (RefRecord) obj;
      if (x != other.x)
        return false;
      if (y != other.y)
        return false;
      return true;
    }
}
{code}

> 'reflect' implementation works only with public fields
> ------------------------------------------------------
>
>                 Key: AVRO-78
>                 URL: https://issues.apache.org/jira/browse/AVRO-78
>             Project: Avro
>          Issue Type: Bug
>          Components: java
>            Reporter: Sharad Agarwal
>
> As per the documentation 'reflect' implementation should work for Class#getDeclaredFields() 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (AVRO-78) 'reflect' implementation works only with public fields

Posted by "Doug Cutting (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/AVRO-78?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Doug Cutting updated AVRO-78:
-----------------------------

        Fix Version/s: 1.0.1
             Assignee: Doug Cutting
    Affects Version/s: 1.0.0
               Status: Patch Available  (was: Open)

> 'reflect' implementation works only with public fields
> ------------------------------------------------------
>
>                 Key: AVRO-78
>                 URL: https://issues.apache.org/jira/browse/AVRO-78
>             Project: Avro
>          Issue Type: Bug
>          Components: java
>    Affects Versions: 1.0.0
>            Reporter: Sharad Agarwal
>            Assignee: Doug Cutting
>             Fix For: 1.0.1
>
>         Attachments: AVRO-78.patch
>
>
> As per the documentation 'reflect' implementation should work for Class#getDeclaredFields() 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (AVRO-78) 'reflect' implementation works only with public fields

Posted by "Sharad Agarwal (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/AVRO-78?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12731890#action_12731890 ] 

Sharad Agarwal commented on AVRO-78:
------------------------------------

+1 for the patch

> 'reflect' implementation works only with public fields
> ------------------------------------------------------
>
>                 Key: AVRO-78
>                 URL: https://issues.apache.org/jira/browse/AVRO-78
>             Project: Avro
>          Issue Type: Bug
>          Components: java
>    Affects Versions: 1.0.0
>            Reporter: Sharad Agarwal
>            Assignee: Doug Cutting
>             Fix For: 1.0.1
>
>         Attachments: AVRO-78.patch
>
>
> As per the documentation 'reflect' implementation should work for Class#getDeclaredFields() 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (AVRO-78) 'reflect' implementation works only with public fields

Posted by "Doug Cutting (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/AVRO-78?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Doug Cutting updated AVRO-78:
-----------------------------

    Attachment: AVRO-78.patch

Thanks for the test case.  Here's a patch that fixes this.

> 'reflect' implementation works only with public fields
> ------------------------------------------------------
>
>                 Key: AVRO-78
>                 URL: https://issues.apache.org/jira/browse/AVRO-78
>             Project: Avro
>          Issue Type: Bug
>          Components: java
>    Affects Versions: 1.0.0
>            Reporter: Sharad Agarwal
>             Fix For: 1.0.1
>
>         Attachments: AVRO-78.patch
>
>
> As per the documentation 'reflect' implementation should work for Class#getDeclaredFields() 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.