Merge pull request #1153 from sbt/security-manager-avoid-file-permission

Override certain SecurityManager methods to avoid filesystem performance hit
This commit is contained in:
Josh Suereth 2014-03-06 08:13:46 -05:00
commit 0e2d789290
1 changed files with 9 additions and 0 deletions

View File

@ -413,6 +413,15 @@ private final class TrapExit(delegateManager: SecurityManager) extends SecurityM
private def isRealExit(element: StackTraceElement): Boolean =
element.getClassName == "java.lang.Runtime" && element.getMethodName == "exit"
// These are overridden to do nothing because there is a substantial filesystem performance penalty
// when there is a SecurityManager defined. The default implementations of these construct a
// FilePermission, and its initialization involves canonicalization, which is expensive.
override def checkRead(file: String) {}
override def checkRead(file: String, context: AnyRef) {}
override def checkWrite(file: String) {}
override def checkDelete(file: String) {}
override def checkExec(cmd: String) {}
override def checkPermission(perm: Permission)
{
if(delegateManager ne null)