You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by mi...@apache.org on 2013/12/17 13:03:22 UTC

git commit: [OLINGO-84] Added ‘sync’ for field access.

Updated Branches:
  refs/heads/master 57b9bc276 -> ed3adbc75


[OLINGO-84] Added ‘sync’ for field access.


Project: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/commit/ed3adbc7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/tree/ed3adbc7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/diff/ed3adbc7

Branch: refs/heads/master
Commit: ed3adbc75f06a23e927a02fb42b1e8c1b22e8545
Parents: 57b9bc2
Author: Michael Bolz <mi...@apache.org>
Authored: Tue Dec 17 13:02:46 2013 +0100
Committer: Michael Bolz <mi...@apache.org>
Committed: Tue Dec 17 13:02:46 2013 +0100

----------------------------------------------------------------------
 .../core/annotation/util/ClassHelper.java       | 22 ++++++++++++--------
 1 file changed, 13 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/ed3adbc7/odata2-annotation-processor/annotation-processor-core/src/main/java/org/apache/olingo/odata2/core/annotation/util/ClassHelper.java
----------------------------------------------------------------------
diff --git a/odata2-annotation-processor/annotation-processor-core/src/main/java/org/apache/olingo/odata2/core/annotation/util/ClassHelper.java b/odata2-annotation-processor/annotation-processor-core/src/main/java/org/apache/olingo/odata2/core/annotation/util/ClassHelper.java
index 896d392..cca35ab 100644
--- a/odata2-annotation-processor/annotation-processor-core/src/main/java/org/apache/olingo/odata2/core/annotation/util/ClassHelper.java
+++ b/odata2-annotation-processor/annotation-processor-core/src/main/java/org/apache/olingo/odata2/core/annotation/util/ClassHelper.java
@@ -97,11 +97,13 @@ public class ClassHelper {
 
   public static Object getFieldValue(final Object instance, final Field field) {
     try {
-      boolean access = field.isAccessible();
-      field.setAccessible(true);
-      Object value = field.get(instance);
-      field.setAccessible(access);
-      return value;
+      synchronized (field) {
+        boolean access = field.isAccessible();
+        field.setAccessible(true);
+        Object value = field.get(instance);
+        field.setAccessible(access);
+        return value;
+      }
     } catch (IllegalArgumentException ex) { // should never happen
       throw new ODataRuntimeException(ex);
     } catch (IllegalAccessException ex) { // should never happen
@@ -111,10 +113,12 @@ public class ClassHelper {
 
   public static void setFieldValue(final Object instance, final Field field, final Object value) {
     try {
-      boolean access = field.isAccessible();
-      field.setAccessible(true);
-      field.set(instance, value);
-      field.setAccessible(access);
+      synchronized (field) {
+        boolean access = field.isAccessible();
+        field.setAccessible(true);
+        field.set(instance, value);
+        field.setAccessible(access);
+      }
     } catch (IllegalArgumentException ex) { // should never happen
       throw new ODataRuntimeException(ex);
     } catch (IllegalAccessException ex) { // should never happen