Skip to content

Commit

Permalink
Fix data race in the MonitoringService
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Pinčuk <alexander.v.pinchuk@gmail.com>
  • Loading branch information
avpinchuk committed Apr 28, 2023
1 parent 9e43c27 commit 9c60702
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Contributors to the Eclipse Foundation
* Copyright (c) 2023 Contributors to the Eclipse Foundation.
* Copyright (c) 2012, 2020 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
Expand All @@ -24,6 +24,7 @@
import java.beans.PropertyVetoException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.logging.Logger;
Expand Down Expand Up @@ -184,7 +185,7 @@ default String getMonitoringLevel(String moduleName) {
String methodName = itr.next();
if (name.equalsIgnoreCase(methodName.substring(3))) {
try {
Method mthd = ModuleMonitoringLevels.class.getMethod(methodName, (Class[]) null);
Method mthd = ModuleMonitoringLevels.class.getMethod(methodName, (Class<?>[]) null);
level = (String) mthd.invoke(getModuleMonitoringLevels(), (Object[]) null);
} catch (NoSuchMethodException nsme) {
Logger.getAnonymousLogger().log(Level.WARNING, nsme.getMessage(), nsme);
Expand Down Expand Up @@ -232,7 +233,7 @@ default boolean setMonitoringLevel(String moduleName, String level) throws Trans
String methodName = itr.next();
if (name.equalsIgnoreCase(methodName.substring(3))) {
try {
Method mthd = ModuleMonitoringLevels.class.getMethod(methodName, new Class[] { java.lang.String.class });
Method mthd = ModuleMonitoringLevels.class.getMethod(methodName, new Class<?>[] { java.lang.String.class });
Transaction tx = Transaction.getTransaction(this);
if (tx == null) {
throw new TransactionFailure(
Expand Down Expand Up @@ -270,7 +271,7 @@ default boolean isAnyModuleOn() {
ModuleMonitoringLevels mml = getModuleMonitoringLevels();
for (String methodName : Util.getMethods) {
try {
Method mthd = ModuleMonitoringLevels.class.getMethod(methodName, (Class[]) null);
Method mthd = ModuleMonitoringLevels.class.getMethod(methodName, (Class<?>[]) null);
String level = (String) mthd.invoke(mml, (Object[]) null);
rv = rv || !"OFF".equals(level);
} catch (NoSuchMethodException nsme) {
Expand All @@ -291,9 +292,9 @@ class Util {

private static final LocalStringManagerImpl localStrings = new LocalStringManagerImpl(MonitoringService.class);

private static final List<String> getMethods = new ArrayList<>();
private static final List<String> getMethods = Collections.synchronizedList(new ArrayList<>());

private static final List<String> setMethods = new ArrayList<>();
private static final List<String> setMethods = Collections.synchronizedList(new ArrayList<>());

private static void populateGetMethods() {
// We need to use reflection to compare the given name with the
Expand Down

0 comments on commit 9c60702

Please sign in to comment.