{"action":"opened","issue":{"url":"https://api.github.com/repos/chrsmith/google-api-java-client/issues/253","labels_url":"https://api.github.com/repos/chrsmith/google-api-java-client/issues/253/labels{/name}","comments_url":"https://api.github.com/repos/chrsmith/google-api-java-client/issues/253/comments","events_url":"https://api.github.com/repos/chrsmith/google-api-java-client/issues/253/events","html_url":"https://github.com/chrsmith/google-api-java-client/issues/253","id":59522744,"number":253,"title":"FindBugs found: Synchronization issue in api.client.util.Data","user":{"login":"GoogleCodeExporter","id":9614759,"avatar_url":"https://avatars.githubusercontent.com/u/9614759?v=3","gravatar_id":"","url":"https://api.github.com/users/GoogleCodeExporter","html_url":"https://github.com/GoogleCodeExporter","followers_url":"https://api.github.com/users/GoogleCodeExporter/followers","following_url":"https://api.github.com/users/GoogleCodeExporter/following{/other_user}","gists_url":"https://api.github.com/users/GoogleCodeExporter/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleCodeExporter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleCodeExporter/subscriptions","organizations_url":"https://api.github.com/users/GoogleCodeExporter/orgs","repos_url":"https://api.github.com/users/GoogleCodeExporter/repos","events_url":"https://api.github.com/users/GoogleCodeExporter/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleCodeExporter/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/chrsmith/google-api-java-client/labels/auto-migrated","name":"auto-migrated","color":"ededed"},{"url":"https://api.github.com/repos/chrsmith/google-api-java-client/labels/Priority-Medium","name":"Priority-Medium","color":"ededed"},{"url":"https://api.github.com/repos/chrsmith/google-api-java-client/labels/Type-Defect","name":"Type-Defect","color":"ededed"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-03-02T18:27:42Z","updated_at":"2015-03-02T18:27:43Z","closed_at":"2015-03-02T18:27:43Z","body":"```\nThis class is synchronizing on the monitor of a ConcurrentHashMap instance. \nConcurrent objects have their own concurrency controls that are distinct form \nand incompatible with the keyword synchronized. The following function will not \nprevent other threads from making changes to NULL_CHANGE because it uses the \nNULL_CHANGE monitor, while other threads may be using the built-in concurrency \nprovided by the collection:\n\n  public static <T> T nullOf(Class<?> objClass) {\n    Object result = NULL_CACHE.get(objClass);\n    if (result == null) {\n      synchronized (NULL_CACHE) {\n        result = NULL_CACHE.get(objClass);\n        if (result == null) {\n          if (objClass.isArray()) {\n            // arrays are special because we need to compute both the dimension and component type\n            int dims = 0;\n            Class<?> componentType = objClass;\n            do {\n              componentType = componentType.getComponentType();\n              dims++;\n            } while (componentType.isArray());\n            result = Array.newInstance(componentType, new int[dims]);\n          } else if (objClass.isEnum()) {\n            // enum requires look for constant with @NullValue\n            FieldInfo fieldInfo = ClassInfo.of(objClass).getFieldInfo(null);\n            Preconditions.checkNotNull(\n                fieldInfo, \"enum missing constant with @NullValue annotation: %s\", objClass);\n            @SuppressWarnings({\"unchecked\", \"rawtypes\"})\n            Enum e = fieldInfo.<Enum>enumValue();\n            result = e;\n          } else {\n            // other classes are simpler\n            result = Types.newInstance(objClass);\n          }\n          NULL_CACHE.put(objClass, result);\n        }\n      }\n    }\n    @SuppressWarnings(\"unchecked\")\n    T tResult = (T) result;\n    return tResult;\n  }\n\n\nFindBugs Output:\n\nSynchronization performed on util.concurrent instance\nThis method performs synchronization an object that is an instance of a class \nfrom the java.util.concurrent package (or its subclasses). Instances of these \nclasses have there own concurrency control mechanisms that are distinct from \nand incompatible with the use of the keyword synchronized.\n\n```\n\nOriginal issue reported on code.google.com by `avall...@google.com` on 28 Jul 2011 at 2:55"}}