Skip to content

Problem Using static member in Data #12

Description

@hiteshvpatel256

At this moment getData() returns static Data object

private static Data instance = null;
private HashMap<String, Object> map;
public static Data add(String key, Object value) {
if (instance == null) {
instance = new Data();
}
instance.map.put(key, value);
return instance;
}

The difficulty with this is, when user will try to send message for multiple times.
The hashmap will add new entries each time if key,value pair is not same.

To solve the problem:

  1. either user will call clear method on the Data object each time before new send.
  2. or avoid using static fields, and getting new hashmap each time before send..

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions