Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

device.clean() should not set reportedProp to null #164

Closed
carocad opened this issue Oct 12, 2017 · 2 comments
Closed

device.clean() should not set reportedProp to null #164

carocad opened this issue Oct 12, 2017 · 2 comments
Assignees
Labels
bug fix checked in Fix checked into main or preview, but not yet released.

Comments

@carocad
Copy link

carocad commented Oct 12, 2017

OS and version used: MAC OS X 10.11.6

Java runtime used: Android JDK 1.7

SDK version used: iot-device-client:1.5.35

Description of the issue:

The abstract class Device in package com.microsoft.azure.sdk.iot.device.DeviceTwin; contains a method clean() which sets the reportedProp to null. However if a user calls setReportedProp afterwards, the code throws a NullPointerException because reportedProp was set to null instead of being clear

Code sample exhibiting the issue:

client = new DeviceClient(connString, protocol);
final Device homeKit = new Device() {
            @Override
            public void PropertyCall(String propertyKey, Object propertyValue, Object context) {
                Log.i(TAG, propertyKey + " changed to " + propertyValue);
                try {
                    this.setReportedProp(new Property(propertyKey, propertyValue));
                    client.sendReportedProperties(this.getReportedProp());
                    this.clean();
                    return;
                } catch (Exception e) {
                    // null pointer exception whenever a property is changed
                    e.printStackTrace();
                }
            }
        };
client.startDeviceTwin(new DeviceTwinStatusCallBack(), null, homeKit, null);
@timtay-microsoft
Copy link
Member

Sorry for the delay on this fix. The fix has been checked in as of b1b4a46

The fix will be in the next release. I will update this thread when that happens

@prmathur-microsoft prmathur-microsoft added the fix checked in Fix checked into main or preview, but not yet released. label Dec 21, 2017
@timtay-microsoft
Copy link
Member

It will take a few days for the release to propagate up to Maven central, but our latest release will fix this issue for you:

https://github.com/Azure/azure-iot-sdk-java/releases/tag/2018-1-23

I am closing this issue for now. Feel free to re-open if you still run into problems here.

SreeramGarlapati pushed a commit to SreeramGarlapati/azure-iot-sdk-java that referenced this issue Mar 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug fix checked in Fix checked into main or preview, but not yet released.
Projects
None yet
Development

No branches or pull requests

3 participants