Source:
<code><START> private boolean addToResources(OffHeapResourceIdentifier identifier, long capacityInBytes) { <END> boolean added = resources.putIfAbsent(identifier, createOffheapResource(identifier, capacityInBytes)) == null; if (added) { updateConfiguredOffheap(capacityInBytes); } return added; }</code><technical_language>suggestion private boolean addToResources(OffHeapResourceIdentifier identifier, long capacityInBytes) { AtomicBoolean status = new AtomicBoolean(); resources.computeIfAbsent(identifier, (k) -> { status.compareAndSet(false, true); OffHeapResourceImpl offHeapResource = new OffHeapResourceImpl( identifier.getName(), capacityInBytes, (res, update) -> { for (EntityManagementRegistry registry : registries) { Map<String, String> attrs = new HashMap<>(); attrs.put("oldThreshold", String.valueOf(update.old)); attrs.put("threshold", String.valueOf(update.now)); attrs.put("capacity", String.valueOf(res.capacity())); attrs.put("available", String.valueOf(res.available())); registry.pushServerEntityNotification(res.getManagementBinding(), "OFFHEAP_RESOURCE_THRESHOLD_REACHED", attrs); } }, (res, oldCapacity, newCapacity) -> { updateConfiguredOffheap(newCapacity - oldCapacity); for (EntityManagementRegistry registry : registries) { Map<String, String> attrs = new HashMap<>(); attrs.put("oldCapacity", Long.toString(oldCapacity)); attrs.put("newCapacity", Long.toString(newCapacity)); registry.pushServerEntityNotification(res.getManagementBinding(), "OFFHEAP_RESOURCE_CAPACITY_CHANGED", attrs); } } ); Map<String, Object> properties = new HashMap<>(); properties.put("discriminator", "OffHeapResource"); properties.put("offHeapResourceIdentifier", identifier.getName()); StatisticsManager.createPassThroughStatistic( offHeapResource, "allocatedMemory", new HashSet<>(Arrays.asList("OffHeapResource", "tier")), properties, StatisticType.GAUGE, () -> offHeapResource.capacity() - offHeapResource.available() ); updateConfiguredOffheap(capacityInBytes); return offHeapResource; }); return status.get(); }</technical_language>

Target:
private boolean addToResources(OffHeapResourceIdentifier identifier, long capacityInBytes) { AtomicBoolean status = new AtomicBoolean(); resources.computeIfAbsent(identifier, (id) -> { status.compareAndSet(false, true); OffHeapResourceImpl offHeapResource = new OffHeapResourceImpl( identifier.getName(), capacityInBytes, (res, update) -> { for (EntityManagementRegistry registry : registries) { Map<String, String> attrs = new HashMap<>(); attrs.put("oldThreshold", String.valueOf(update.old)); attrs.put("threshold", String.valueOf(update.now)); attrs.put("capacity", String.valueOf(res.capacity())); attrs.put("available", String.valueOf(res.available())); registry.pushServerEntityNotification(res.getManagementBinding(), "OFFHEAP_RESOURCE_THRESHOLD_REACHED", attrs); } }, (res, oldCapacity, newCapacity) -> { updateConfiguredOffheap(newCapacity - oldCapacity); for (EntityManagementRegistry registry : registries) { Map<String, String> attrs = new HashMap<>(); attrs.put("oldCapacity", Long.toString(oldCapacity)); attrs.put("newCapacity", Long.toString(newCapacity)); registry.pushServerEntityNotification(res.getManagementBinding(), "OFFHEAP_RESOURCE_CAPACITY_CHANGED", attrs); } } ); Map<String, Object> properties = new HashMap<>(); properties.put("discriminator", "OffHeapResource"); properties.put("offHeapResourceIdentifier", identifier.getName()); StatisticsManager.createPassThroughStatistic( offHeapResource, "allocatedMemory", new HashSet<>(Arrays.asList("OffHeapResource", "tier")), properties, StatisticType.GAUGE, () -> offHeapResource.capacity() - offHeapResource.available() ); updateConfiguredOffheap(capacityInBytes); return offHeapResource; }); return status.get(); }