harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r374062 - in /incubator/harmony/enhanced/classlib/trunk/modules/luni/src: main/java/java/lang/SecurityManager.java test/java/org/apache/harmony/tests/java/lang/AllTests.java test/java/org/apache/harmony/tests/java/lang/SecurityManagerTest.java
Date Wed, 01 Feb 2006 13:29:54 GMT
Author: tellison
Date: Wed Feb  1 05:29:45 2006
New Revision: 374062

URL: http://svn.apache.org/viewcvs?rev=374062&view=rev
Log:
Fix for HARMONY-66 (java.lang.SecurityManager.checkAccess(Thread t) throws NullPointerException
for the dead thread.)

Added:
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/lang/SecurityManagerTest.java
Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/SecurityManager.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/lang/AllTests.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/SecurityManager.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/SecurityManager.java?rev=374062&r1=374061&r2=374062&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/SecurityManager.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/SecurityManager.java
Wed Feb  1 05:29:45 2006
@@ -88,8 +88,9 @@
 	 *            the thread we are attempting to modify
 	 */
 	public void checkAccess(Thread thread) {
-		// Only worry about system threads.
-		if (thread.getThreadGroup().parent == null)
+		// Only worry about system threads. Dead threads have a null group.
+		ThreadGroup group = thread.getThreadGroup();
+		if (group == null || group.parent == null)
 			checkPermission(RuntimePermission.permissionToModifyThread);
 	}
 

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/lang/AllTests.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/lang/AllTests.java?rev=374062&r1=374061&r2=374062&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/lang/AllTests.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/lang/AllTests.java
Wed Feb  1 05:29:45 2006
@@ -12,7 +12,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
- 
+
 package org.apache.harmony.tests.java.lang;
 
 import junit.framework.Test;
@@ -29,6 +29,7 @@
 				"Test for org.apache.harmony.tests.java.lang");
 		//$JUnit-BEGIN$
 		suite.addTestSuite(FloatTest.class);
+		suite.addTestSuite(SecurityManagerTest.class);
 		suite.addTestSuite(DoubleTest.class);
 		//$JUnit-END$
 		return suite;

Added: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/lang/SecurityManagerTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/lang/SecurityManagerTest.java?rev=374062&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/lang/SecurityManagerTest.java
(added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/lang/SecurityManagerTest.java
Wed Feb  1 05:29:45 2006
@@ -0,0 +1,40 @@
+/* Copyright 2006 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.harmony.tests.java.lang;
+
+import java.security.AccessControlException;
+
+import junit.framework.TestCase;
+
+public class SecurityManagerTest extends TestCase {
+
+	/**
+	 * @tests java.lang.SecurityManager#checkAccess(java.lang.Thread)
+	 */
+	public void test_checkAccessLjava_lang_Thread() throws InterruptedException {
+		// Regression for HARMONY-66
+		Thread t = new Thread() {
+			public void run() {	};
+		};
+		t.start();
+		t.join();
+		try {
+			new SecurityManager().checkAccess(t);
+		} catch (AccessControlException e) {
+			// expected
+		}
+	}
+}



Mime
View raw message