[ https://issues.apache.org/jira/browse/GEODE-7864?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17281411#comment-17281411 ]
ASF GitHub Bot commented on GEODE-7864: --------------------------------------- dschneider-pivotal commented on a change in pull request #6007: URL: https://github.com/apache/geode/pull/6007#discussion_r572406437 ########## File path: geode-core/src/main/java/org/apache/geode/internal/cache/control/InternalResourceManager.java ########## @@ -125,99 +123,99 @@ public static InternalResourceManager createResourceManager(final InternalCache private InternalResourceManager(InternalCache cache) { this.cache = cache; - this.resourceAdvisor = (ResourceAdvisor) cache.getDistributionAdvisor(); - this.stats = new ResourceManagerStats(cache.getDistributedSystem()); + resourceAdvisor = (ResourceAdvisor) cache.getDistributionAdvisor(); + stats = new ResourceManagerStats(cache.getDistributedSystem()); // Create a new executor that other classes may use for handling resource // related tasks - this.scheduledExecutor = LoggingExecutors + scheduledExecutor = LoggingExecutors .newScheduledThreadPool(MAX_RESOURCE_MANAGER_EXE_THREADS, "ResourceManagerRecoveryThread "); // Initialize the load probe try { - Class loadProbeClass = ClassPathLoader.getLatest().forName(PR_LOAD_PROBE_CLASS); - this.loadProbe = (LoadProbe) loadProbeClass.newInstance(); + Class<?> loadProbeClass = ClassPathLoader.getLatest().forName(PR_LOAD_PROBE_CLASS); + loadProbe = (LoadProbe) loadProbeClass.newInstance(); } catch (Exception e) { throw new InternalGemFireError("Unable to instantiate " + PR_LOAD_PROBE_CLASS, e); } // Create a new executor the resource manager and the monitors it creates // can use to handle dispatching of notifications. - this.notifyExecutor = + notifyExecutor = CoreLoggingExecutors.newSerialThreadPoolWithFeedStatistics(0, - this.stats.getResourceEventQueueStatHelper(), "Notification Handler", + stats.getResourceEventQueueStatHelper(), "Notification Handler", thread -> thread.setPriority(Thread.MAX_PRIORITY), null, - this.stats.getResourceEventPoolStatHelper(), getThreadMonitorObj()); + stats.getResourceEventPoolStatHelper(), getThreadMonitorObj()); // Create the monitors - Map<ResourceType, ResourceMonitor> tempMonitors = new HashMap<ResourceType, ResourceMonitor>(); - tempMonitors.put(ResourceType.HEAP_MEMORY, new HeapMemoryMonitor(this, cache, this.stats)); + Map<ResourceType, ResourceMonitor> tempMonitors = new HashMap<>(); + tempMonitors.put(ResourceType.HEAP_MEMORY, new HeapMemoryMonitor(this, cache, stats)); tempMonitors.put(ResourceType.OFFHEAP_MEMORY, - new OffHeapMemoryMonitor(this, cache, cache.getOffHeapStore(), this.stats)); - this.resourceMonitors = Collections.unmodifiableMap(tempMonitors); + new OffHeapMemoryMonitor(this, cache, cache.getOffHeapStore(), stats)); + resourceMonitors = Collections.unmodifiableMap(tempMonitors); // Initialize the listener sets so that it only needs to be done once for (ResourceType resourceType : new ResourceType[] {ResourceType.HEAP_MEMORY, ResourceType.OFFHEAP_MEMORY}) { - Set<ResourceListener> emptySet = new CopyOnWriteArraySet<ResourceListener>(); - this.listeners.put(resourceType, emptySet); + Set<ResourceListener<?>> emptySet = new CopyOnWriteArraySet<>(); + listeners.put(resourceType, emptySet); } - this.closed = false; + closed = false; Review comment: You got rid of "closed" being initialized to true so you should probably get rid of this line also. I think the old logic was: "start it at true and then at the end of the constructor set it to false (we must have had some code that allowed "this" to escape the constructor). We then set it to true in closed. But now its initial value is false so it does not make sense to reset it to false at the end of the constructor. We do pass "this" into the tempMonitors but those are just owned by this object so I don't see any real escape of "this". ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Code improvement refactoring > ---------------------------- > > Key: GEODE-7864 > URL: https://issues.apache.org/jira/browse/GEODE-7864 > Project: Geode > Issue Type: Improvement > Reporter: Nabarun Nag > Priority: Major > Labels: pull-request-available > Time Spent: 13h 10m > Remaining Estimate: 0h > > This is a placeholder ticket. > * this is used to do refactoring. > * this ticket number is used to number the commit message. > * this ticket will never be closed. > * it will be used to mark improvements like correcting spelling mistakes, > efficient java code, etc. -- This message was sent by Atlassian Jira (v8.3.4#803005)