Skip to content

optimize putIfAbsent method to computeIfAbsent which may reduce some creation of object #7542

@likemoongg

Description

@likemoongg
  • I have searched the issues of this repository and believe that this is not a duplicate.
  • I have checked the FAQ of this repository and believe that this is not a duplicate.

Environment

  • Dubbo version: 2.7.10
  • Operating System version: macOS
  • Java version: 1.8

Steps to reproduce this issue

When using method "putIfAbsent" of concurrentHashMap to produce singleton,It may create extra duplicate Object .It's better to use "computeIfAbsent" as is mentioned in java doc " The most common usage is to construct a new object serving as an initial mapped value or memoized result"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions