Skip to content

Commit f1a302d

Browse files
tnagao7dmatej
authored andcommitted
Fix monitoring data unavailability after updating configuration
Signed-off-by: Takahiro Nagao <[email protected]>
1 parent c4904d9 commit f1a302d

File tree

3 files changed

+12
-13
lines changed

3 files changed

+12
-13
lines changed

nucleus/flashlight/framework/src/main/java/org/glassfish/flashlight/impl/client/FlashlightProbeClientMediator.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/*
2+
* Copyright (c) 2025 Contributors to the Eclipse Foundation.
23
* Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
34
*
45
* This program and the accompanying materials are made available under the
@@ -135,8 +136,8 @@ private void registerJavaListener(
135136
ProbeClientMethodHandleImpl hi = new ProbeClientMethodHandleImpl(invoker.getId(), invoker, probe);
136137
pcms.add(hi);
137138

138-
if (probe.addInvoker(invoker))
139-
probesRequiringClassTransformation.add(probe);
139+
probe.addInvoker(invoker);
140+
probesRequiringClassTransformation.add(probe);
140141
}
141142
}
142143

@@ -155,8 +156,8 @@ private Object registerDTraceListener(
155156
ProbeClientMethodHandleImpl hi = new ProbeClientMethodHandleImpl(invoker.getId(), invoker, probe);
156157
pcms.add(hi);
157158

158-
if (probe.addInvoker(invoker))
159-
probesRequiringClassTransformation.add(probe);
159+
probe.addInvoker(invoker);
160+
probesRequiringClassTransformation.add(probe);
160161

161162
if (listener == null)
162163
listener = probe.getDTraceProviderImpl(); // all the probes in propro have the same "listener"

nucleus/flashlight/framework/src/main/java/org/glassfish/flashlight/impl/client/ProbeProviderClassFileTransformer.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2023, 2024 Contributors to the Eclipse Foundation.
2+
* Copyright (c) 2023, 2025 Contributors to the Eclipse Foundation.
33
* Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved.
44
*
55
* This program and the accompanying materials are made available under the
@@ -132,10 +132,12 @@ static void transform(Class aProviderClazz) {
132132

133133
synchronized void addProbe(FlashlightProbe probe) throws NoSuchMethodException {
134134
Method m = getMethod(probe);
135-
probes.put(probe.getProviderJavaMethodName() + "::" + Type.getMethodDescriptor(m), probe);
135+
FlashlightProbe existingProbe = probes.put(probe.getProviderJavaMethodName() + "::" + Type.getMethodDescriptor(m), probe);
136136

137137
// probes can be added piecemeal after the initial transformation is done, flagging when probes are added to detect that
138-
allProbesTransformed = false;
138+
if (existingProbe == null || existingProbe != probe) {
139+
allProbesTransformed = false;
140+
}
139141
}
140142

141143
final synchronized void transform() {

nucleus/flashlight/framework/src/main/java/org/glassfish/flashlight/provider/FlashlightProbe.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/*
2+
* Copyright (c) 2025 Contributors to the Eclipse Foundation.
23
* Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
34
*
45
* This program and the accompanying materials are made available under the
@@ -98,9 +99,7 @@ private boolean isMethodStatic() {
9899
}
99100
}
100101

101-
public synchronized boolean addInvoker(ProbeClientInvoker invoker) {
102-
boolean isFirst = (invokers.isEmpty() && firstTransform);
103-
102+
public synchronized void addInvoker(ProbeClientInvoker invoker) {
104103
if(invokers.putIfAbsent(invoker.getId(), invoker) != null) {
105104
if (logger.isLoggable(Level.FINE))
106105
logger.fine("Adding an invoker that already exists: " + invoker.getId() + " &&&&&&&&&&");
@@ -113,10 +112,8 @@ public synchronized boolean addInvoker(ProbeClientInvoker invoker) {
113112
logger.fine("Total invokers = " + invokers.size());
114113
}
115114
listenerEnabled.set(true);
116-
firstTransform = false;
117115

118116
initInvokerList();
119-
return isFirst;
120117
}
121118

122119
public synchronized boolean removeInvoker(ProbeClientInvoker invoker) {
@@ -401,7 +398,6 @@ public static final class ProbeInvokeState {
401398
private Method dtraceMethod;
402399
private boolean hasSelf;
403400
private boolean hidden;
404-
private boolean firstTransform = true;
405401
private ConcurrentMap<Integer, ProbeClientInvoker> invokers = new ConcurrentHashMap<Integer, ProbeClientInvoker>();
406402
private static final Logger logger = FlashlightLoggerInfo.getLogger();
407403
public final static LocalStringManagerImpl localStrings =

0 commit comments

Comments
 (0)