The setter (setParameter) is synchronized, since getParameter is not
atomic, it needs to to also be synchronized to avoid racy situations.
Change-Id: I1c7eb0a2fde364efd7e879a82411f91fae0deab2
Signed-off-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/83739
Reviewed-by: Hudson CI
Reviewed-by: Genevieve Bastien <gbastien+lttng@versatic.net>
- public @Nullable Object getParameter(String name) {
+ public @Nullable synchronized Object getParameter(String name) {
if (name.equals(PARAM_GRAPH)) {
return getGraph();
}
if (name.equals(PARAM_GRAPH)) {
return getGraph();
}
@Override
protected boolean executeAnalysis(final IProgressMonitor monitor) {
@Override
protected boolean executeAnalysis(final IProgressMonitor monitor) {
- if (getParameter(PARAM_TEST) == null) {
+ Object parameter = getParameter(PARAM_TEST);
+ if (!(parameter instanceof Integer)) {
throw new RuntimeException("The parameter should be set");
}
throw new RuntimeException("The parameter should be set");
}
+ int integer = ((Integer) parameter).intValue();
/* If PARAM_TEST is set to 0, simulate cancellation */
/* If PARAM_TEST is set to 0, simulate cancellation */
- if ((Integer) getParameter(PARAM_TEST) == 0) {
- fOutput = 0;
+ fOutput = integer;
+ if (integer == 0) {
- } else if ((Integer) getParameter(PARAM_TEST) == 999) {
+ } else if (integer == 999) {
/* just stay in an infinite loop until cancellation */
while (!monitor.isCanceled()) {
/* just stay in an infinite loop until cancellation */
while (!monitor.isCanceled()) {
+ try {
+ Thread.sleep(0);
+ } catch (InterruptedException e) {
+ break;
+ }
}
return !monitor.isCanceled();
}
}
return !monitor.isCanceled();
}
- Object obj = getParameter(PARAM_TEST);
- if (obj == null) {
- throw new IllegalStateException();
- }
- fOutput = (Integer) obj;
- public Object getParameter(String name) {
+ public synchronized Object getParameter(String name) {
Object value = super.getParameter(name);
if ((value != null) && name.equals(PARAM_TEST) && (value instanceof String)) {
return Integer.decode((String) value);
Object value = super.getParameter(name);
if ((value != null) && name.equals(PARAM_TEST) && (value instanceof String)) {
return Integer.decode((String) value);
- public @Nullable Object getParameter(String name) {
+ public @Nullable synchronized Object getParameter(String name) {
Object paramValue = fParameters.get(name);
/* The parameter is not set, maybe it can be provided by someone else */
if ((paramValue == null) && (fTrace != null)) {
Object paramValue = fParameters.get(name);
/* The parameter is not set, maybe it can be provided by someone else */
if ((paramValue == null) && (fTrace != null)) {