Bug 479778 - [DI] Exceptions with concurrent user sessions
Keeping and restoring the original accessible state breaks the
thread safety of the Requestor classes. Adding synchronization would
affect performance, since method / constructor calls would be
serialized. As a workaround, we no longer restore the
accessible state.
Change-Id: Ibf11e6080395327107490a645ca19766dc8ac5cf
Signed-off-by: Ralf Sternberg <rsternberg@eclipsesource.com>
diff --git a/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/internal/di/ConstructorRequestor.java b/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/internal/di/ConstructorRequestor.java
index 7f2ddc9..8ff6be1 100644
--- a/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/internal/di/ConstructorRequestor.java
+++ b/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/internal/di/ConstructorRequestor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2015 IBM Corporation and others.
+ * Copyright (c) 2010, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -28,10 +28,8 @@
@Override
public Object execute() throws InjectionException {
Object result = null;
- boolean wasAccessible = true;
if (!location.isAccessible()) {
location.setAccessible(true);
- wasAccessible = false;
}
boolean pausedRecording = false;
if ((primarySupplier != null)) {
@@ -53,8 +51,6 @@
}
throw new InjectionException((originalException != null) ? originalException : e);
} finally {
- if (!wasAccessible)
- location.setAccessible(false);
if (pausedRecording)
primarySupplier.resumeRecording();
clearResolvedArgs();
diff --git a/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/internal/di/FieldRequestor.java b/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/internal/di/FieldRequestor.java
index ed83aad..dc6de82 100644
--- a/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/internal/di/FieldRequestor.java
+++ b/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/internal/di/FieldRequestor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2015 IBM Corporation and others.
+ * Copyright (c) 2010, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -41,18 +41,13 @@
Object userObject = getRequestingObject();
if (userObject == null)
return false;
- boolean wasAccessible = true;
if (!field.isAccessible()) {
field.setAccessible(true);
- wasAccessible = false;
}
try {
field.set(userObject, value);
} catch (IllegalArgumentException | IllegalAccessException e) {
throw new InjectionException(e);
- } finally {
- if (!wasAccessible)
- field.setAccessible(false);
}
return true;
}
diff --git a/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/internal/di/MethodRequestor.java b/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/internal/di/MethodRequestor.java
index 98ab42d..28b2895 100644
--- a/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/internal/di/MethodRequestor.java
+++ b/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/internal/di/MethodRequestor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2015 IBM Corporation and others.
+ * Copyright (c) 2010, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -42,10 +42,8 @@
if (userObject == null)
return null;
Object result = null;
- boolean wasAccessible = true;
if (!location.isAccessible()) {
location.setAccessible(true);
- wasAccessible = false;
}
boolean pausedRecording = false;
if ((primarySupplier != null)) {
@@ -65,8 +63,6 @@
}
throw new InjectionException((originalException != null) ? originalException : e);
} finally {
- if (!wasAccessible)
- location.setAccessible(false);
if (pausedRecording)
primarySupplier.resumeRecording();
clearResolvedArgs();