[jboss-svn-commits] JBoss Common SVN: r3875 - common-core/trunk/src/main/java/org/jboss/util/collection.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue Dec 22 22:38:12 EST 2009
Author: jason.greene at jboss.com
Date: 2009-12-22 22:38:11 -0500 (Tue, 22 Dec 2009)
New Revision: 3875
Modified:
common-core/trunk/src/main/java/org/jboss/util/collection/ConcurrentSkipListMap.java
Log:
Fix JBCOMMON-100 - Use privileged blocks to workaround security checking bugs in AtomicReferenceFieldUpdater
Modified: common-core/trunk/src/main/java/org/jboss/util/collection/ConcurrentSkipListMap.java
===================================================================
--- common-core/trunk/src/main/java/org/jboss/util/collection/ConcurrentSkipListMap.java 2009-12-22 16:53:10 UTC (rev 3874)
+++ common-core/trunk/src/main/java/org/jboss/util/collection/ConcurrentSkipListMap.java 2009-12-23 03:38:11 UTC (rev 3875)
@@ -6,6 +6,8 @@
package org.jboss.util.collection;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
import java.util.AbstractCollection;
import java.util.AbstractMap;
import java.util.AbstractSet;
@@ -308,7 +310,7 @@
/**
* The topmost head index of the skiplist.
*/
- private transient volatile HeadIndex<K,V> head;
+ transient volatile HeadIndex<K,V> head;
/**
* The Comparator used to maintain order in this Map, or null
@@ -351,10 +353,12 @@
}
/** Updater for casHead */
- private static final
- AtomicReferenceFieldUpdater<ConcurrentSkipListMap, HeadIndex>
- headUpdater = AtomicReferenceFieldUpdater.newUpdater
- (ConcurrentSkipListMap.class, HeadIndex.class, "head");
+ private static final AtomicReferenceFieldUpdater<ConcurrentSkipListMap, HeadIndex> headUpdater = AccessController.doPrivileged(
+ new PrivilegedAction<AtomicReferenceFieldUpdater<ConcurrentSkipListMap, HeadIndex>>() {
+ public AtomicReferenceFieldUpdater<ConcurrentSkipListMap, HeadIndex> run() {
+ return AtomicReferenceFieldUpdater.newUpdater(ConcurrentSkipListMap.class, HeadIndex.class, "head");
+ }
+ });
/**
* compareAndSet head node
@@ -401,13 +405,18 @@
/** Updater for casNext */
static final AtomicReferenceFieldUpdater<Node, Node>
- nextUpdater = AtomicReferenceFieldUpdater.newUpdater
- (Node.class, Node.class, "next");
+ nextUpdater = AccessController.doPrivileged(new PrivilegedAction<AtomicReferenceFieldUpdater<Node, Node>>() {
+ public AtomicReferenceFieldUpdater<Node, Node> run() {
+ return AtomicReferenceFieldUpdater.newUpdater(Node.class, Node.class, "next");
+ }
+ });
- /** Updater for casValue */
static final AtomicReferenceFieldUpdater<Node, Object>
- valueUpdater = AtomicReferenceFieldUpdater.newUpdater
- (Node.class, Object.class, "value");
+ valueUpdater = AccessController.doPrivileged(new PrivilegedAction<AtomicReferenceFieldUpdater<Node, Object>>() {
+ public AtomicReferenceFieldUpdater<Node, Object> run() {
+ return AtomicReferenceFieldUpdater.newUpdater(Node.class, Object.class, "value");
+ }
+ });
/**
* compareAndSet value field
@@ -528,8 +537,11 @@
/** Updater for casRight */
static final AtomicReferenceFieldUpdater<Index, Index>
- rightUpdater = AtomicReferenceFieldUpdater.newUpdater
- (Index.class, Index.class, "right");
+ rightUpdater = AccessController.doPrivileged(new PrivilegedAction<AtomicReferenceFieldUpdater<Index, Index>>() {
+ public AtomicReferenceFieldUpdater<Index, Index> run() {
+ return AtomicReferenceFieldUpdater.newUpdater(Index.class, Index.class, "right");
+ }
+ });
/**
* compareAndSet right field
More information about the jboss-svn-commits
mailing list