'Passing around ConcurrentHashMap

Is it a good practice to pass around a concurrent hashmap to other methods? So I have a lookup map which is a ConcurrentHashMap<String, Object> map = new ConcurrentHashMap<>() which I need to use in different methods within the class to look up whether it contains an object or not. Currently, I create this map and pass this to the functions for lookup purpose for eg, public Data getData(ConcurrentHashMap<String, Object> map). Is this a bad practice? If this is not ideal, can anyone suggest a safer/better way? That said, the module I am working on is something similar to a file upload, so multiple users can upload the file at the same time.

------- Follow up --> So when my method gets the call get(Resources r) I create a ConcurrentHashMap and put all the resources/objects that I create into this map, in order to look it up in other functions. For this reason, I pass ConcurrentHashMap<String, Object> map to another function createObj(ConcurrentHashMap<String, Object> map) and then from there I would again further pass this map to another function. Here is a small snippet to make the question clearer. Is it okay to do as below?

Class Data {

final ConcurrentHashMap<String, Object> map = new ConcurrentHashMap<>();
map.put("1", person);
map.put("2", person);

Address a = getAddress(map);

public Address getAddress(ConcurrentHashMap<String, Object> map){
Person p = map.get("1");
boolean isAlive = getPersonAbove50(map);
return p.getAddress();
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source