sombhardwaj / asmack

Automatically exported from code.google.com/p/asmack
0 stars 0 forks source link

POJO ExtensionProviders don't work #10

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Extension providers which are plain objects (do not implement the
PacketExtensionProvider interface) cause an exception when a message
containing such extension is parsed.

How to reproduce:
1. Create an extension provider
class SomeObject {
    string preview;

    public String getPreview() {
        return preview;
    }

    public void setPreview(String preview) {
        this.preview = preview;
    }
}

2. Register it
ProviderManager.getInstance().addExtensionProvider("test", "ns:test",
SomeObject.class);

3. Connect and send an incoming message with such extension, e.g. here:
<message>
<test>
<preview>preview</preview>
</test>
</message>

Expected result:
An object of class SomeObject is created.

Actual result:
NoSuchMethodError: getPreview() isn't found.

"What version of aSmack / Android / Device do you use?"
asmack-2010.04.02.jar, Android SDK version 2.0.1 emulator.

"What server do you use? Is there a public server to reproduce the problem?"
A private server.

"What else might help us to reproduce and hunt down the problem?"
The exception occurs at PacketParserUtils.class:830, which reads:
Class propertyType = object.getClass().getClass().getMethod("get" +
Character.toUpperCase(name.charAt(0)) + name.substring(1)).getReturnType();
where the second getClass() will always return a Class Class. Typo?

Original issue reported on code.google.com by koterpil...@gmail.com on 3 May 2010 at 1:13

GoogleCodeExporter commented 8 years ago
Very clear typo, indeed. Pushed to github, will be added to the next release.

Original comment by rtreffer@gmail.com on 3 May 2010 at 7:26

GoogleCodeExporter commented 8 years ago
Latest 2010.05.03 version contains the altered code. Could you give it a try 
before
it gets featured?

TIA, Rene

Original comment by rtreffer@gmail.com on 3 May 2010 at 9:04

GoogleCodeExporter commented 8 years ago
2010.05.03 works as expected.

Original comment by koterpil...@gmail.com on 4 May 2010 at 4:41