Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,7 @@ public enum Mode {
public static void initialize(String prefix, Mode mode, Set<String> allowedFiles) {
System.setProperty("counting.security.disabled", "true");

if (System.getSecurityManager() instanceof CountingSecurityManager) {
// ok
} else {
System.setSecurityManager(new CountingSecurityManager());
}
System.setSecurityManager(new CountingSecurityManager());
setCnt(0);
msgs = new StringWriter();
pw = new PrintWriter(msgs);
Expand All @@ -79,7 +75,6 @@ public static void initialize(String prefix, Mode mode, Set<String> allowedFiles

static void assertReflection(int maxCount, String whitelist) {
System.setProperty("counting.reflection.whitelist", whitelist);
System.getSecurityManager().checkPermission(new MaxCountPerm(maxCount));
System.getProperties().remove("counting.reflection.whitelist");
}

Expand Down Expand Up @@ -124,7 +119,7 @@ public Integer call() throws Exception {
}

public static boolean isEnabled() {
return System.getSecurityManager() instanceof Callable<?>;
return false;
}

public static void assertCounts(String msg, int expectedCnt) throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,10 @@ public static void register() {
public static void initialize(String prefix) {
Assert.assertNotNull(prefix);

if (! (System.getSecurityManager() instanceof CountingSecurityManager)) {
setAllowedReplace(true);
System.setSecurityManager(new CountingSecurityManager());
setAllowedReplace(false);
}
setAllowedReplace(true);
System.setSecurityManager(new CountingSecurityManager());
setAllowedReplace(false);

if (!System.getSecurityManager().getClass().getName().equals(CountingSecurityManager.class.getName())) {
throw new IllegalStateException("Wrong security manager: " + System.getSecurityManager());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,7 @@ public enum Mode {
public static void initialize(String prefix, Mode mode, Set<String> allowedFiles) {
System.setProperty("counting.security.disabled", "true");

if (System.getSecurityManager() instanceof CountingSecurityManager) {
// ok
} else {
System.setSecurityManager(new CountingSecurityManager());
}
System.setSecurityManager(new CountingSecurityManager());
setCnt(0);
msgs = new StringWriter();
pw = new PrintWriter(msgs);
Expand All @@ -113,7 +109,6 @@ public static void initialize(String prefix, Mode mode, Set<String> allowedFiles
static void assertReflection(int maxCount, String whitelist) {
System.setProperty("counting.reflection.whitelist", whitelist);
RuntimePermission checkMemberAccessPermission = new RuntimePermission("accessDeclaredMembers");
System.getSecurityManager().checkPermission(checkMemberAccessPermission);
System.getProperties().remove("counting.reflection.whitelist");
}

Expand All @@ -127,7 +122,7 @@ public Integer call() throws Exception {
}

public static boolean isEnabled() {
return System.getSecurityManager() instanceof Callable<?>;
return false;
}

public static void assertCounts(String msg, int expectedCnt) throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,11 @@ public CheckBoxRenderrer () {

private Border getNoFocusBorder () {
Border border = UIManager.getBorder("List.cellNoFocusBorder");
if (System.getSecurityManager () != null) {
if (border != null) {
return border;
}
return SAFE_NO_FOCUS_BORDER;
} else {
if (border != null &&
(noFocusBorder == null ||
noFocusBorder == DEFAULT_NO_FOCUS_BORDER)) {
return border;
}
return noFocusBorder;
if (border != null &&
(noFocusBorder == null || noFocusBorder == DEFAULT_NO_FOCUS_BORDER)) {
return border;
}
return noFocusBorder;
}

public Component getListCellRendererComponent (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,11 @@ public CheckBoxRenderrer () {

private Border getNoFocusBorder () {
Border border = UIManager.getBorder("List.cellNoFocusBorder");
if (System.getSecurityManager () != null) {
if (border != null) {
return border;
}
return SAFE_NO_FOCUS_BORDER;
} else {
if (border != null &&
(noFocusBorder == null ||
noFocusBorder == DEFAULT_NO_FOCUS_BORDER)) {
return border;
}
return noFocusBorder;
if (border != null &&
(noFocusBorder == null || noFocusBorder == DEFAULT_NO_FOCUS_BORDER)) {
return border;
}
return noFocusBorder;
}

public Component getListCellRendererComponent (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ public class GetOwnerTest extends NbTestCase {

protected File dataRootDir;
private StatFiles accessMonitor;
private SecurityManager defaultSecurityManager;
protected File versionedFolder;
protected File unversionedFolder;

Expand Down Expand Up @@ -69,9 +68,6 @@ protected void setUp() throws Exception {
userdir.mkdirs();
System.setProperty("netbeans.user", userdir.getAbsolutePath());
if(accessMonitor != null) {
if(defaultSecurityManager == null) {
defaultSecurityManager = System.getSecurityManager();
}
System.setSecurityManager(accessMonitor);
}
}
Expand All @@ -80,7 +76,8 @@ protected void setUp() throws Exception {
protected void tearDown() throws Exception {
super.tearDown();
if(accessMonitor != null) {
System.setSecurityManager(defaultSecurityManager);
// FIXME - throws UnsupportedOperationException unconditionally, regardless of arg.
System.setSecurityManager(null);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,11 @@ public AnalyserCellRenderer () {

private Border getNoFocusBorder() {
Border border = UIManager.getBorder("List.cellNoFocusBorder");
if (System.getSecurityManager() != null) {
if (border != null) return border;
return SAFE_NO_FOCUS_BORDER;
} else {
if (border != null &&
(noFocusBorder == null ||
noFocusBorder == DEFAULT_NO_FOCUS_BORDER)) {
return border;
}
return noFocusBorder;
if (border != null &&
(noFocusBorder == null || noFocusBorder == DEFAULT_NO_FOCUS_BORDER)) {
return border;
}
return noFocusBorder;
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,10 @@ public static void register() {
public static void initialize(String prefix) {
Assert.assertNotNull(prefix);

if (! (System.getSecurityManager() instanceof CountingSecurityManager)) {
setAllowedReplace(true);
System.setSecurityManager(new CountingSecurityManager());
setAllowedReplace(false);
}
if (!System.getSecurityManager().getClass().getName().equals(CountingSecurityManager.class.getName())) {
throw new IllegalStateException("Wrong security manager: " + System.getSecurityManager());
}
setAllowedReplace(true);
System.setSecurityManager(new CountingSecurityManager());
setAllowedReplace(false);

cnt = 0;
msgs = new StringWriter();
pw = new PrintWriter(msgs);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,7 @@ public enum Mode {
public static void initialize(String prefix, PerfCountingSecurityManager.Mode mode, Set<String> allowedFiles) {
System.setProperty("counting.security.disabled", "true");

if (System.getSecurityManager() instanceof PerfCountingSecurityManager) {
// ok
} else {
System.setSecurityManager(new PerfCountingSecurityManager());
}
System.setSecurityManager(new PerfCountingSecurityManager());
setCnt(0);
msgs = new StringWriter();
pw = new PrintWriter(msgs);
Expand All @@ -113,7 +109,6 @@ public static void initialize(String prefix, PerfCountingSecurityManager.Mode mo

static void assertReflection(int maxCount, String whitelist) {
System.setProperty("counting.reflection.whitelist", whitelist);
System.getSecurityManager().checkPermission( SecurityConstants.CHECK_MEMBER_ACCESS_PERMISSION);
System.getProperties().remove("counting.reflection.whitelist");
}

Expand All @@ -127,7 +122,7 @@ public Integer call() throws Exception {
}

public static boolean isEnabled() {
return System.getSecurityManager() instanceof Callable<?>;
return false;
}

public static void assertCounts(String msg, int expectedCnt) throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,10 @@ public static void register() {
public static void initialize(String prefix) {
Assert.assertNotNull(prefix);

if (! (System.getSecurityManager() instanceof CountingSecurityManager)) {
setAllowedReplace(true);
System.setSecurityManager(new CountingSecurityManager());
setAllowedReplace(false);
}
if (!System.getSecurityManager().getClass().getName().equals(CountingSecurityManager.class.getName())) {
throw new IllegalStateException("Wrong security manager: " + System.getSecurityManager());
}
setAllowedReplace(true);
System.setSecurityManager(new CountingSecurityManager());
setAllowedReplace(false);

cnt = 0;
msgs = new StringWriter();
pw = new PrintWriter(msgs);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,7 @@ final class CountingSecurityManager extends SecurityManager {
private static String prefix;

public static void initialize(String prefix) {
if (System.getSecurityManager() instanceof CountingSecurityManager) {
// ok
} else {
System.setSecurityManager(new CountingSecurityManager());
}
System.setSecurityManager(new CountingSecurityManager());
cnt = 0;
msgs = new StringWriter();
pw = new PrintWriter(msgs);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ public class IsDirCntSecurityManager extends SecurityManager {
private static StringBuffer sb;

public static void initialize() {
if (!(System.getSecurityManager() instanceof IsDirCntSecurityManager)) {
System.setSecurityManager(new IsDirCntSecurityManager());
}
System.setSecurityManager(new IsDirCntSecurityManager());
cnt = 0;
sb = new StringBuffer();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,7 @@ public static void initialize(String prefix, Mode mode, Set<String> allowedFiles
System.setProperty("counting.security.disabled", "true");
inSubtree("", "");

if (System.getSecurityManager() instanceof CountingSecurityManager) {
// ok
} else {
System.setSecurityManager(new CountingSecurityManager());
}
System.setSecurityManager(new CountingSecurityManager());
setCnt(0);
msgs = new StringWriter();
pw = new PrintWriter(msgs);
Expand All @@ -86,7 +82,6 @@ public static void initialize(String prefix, Mode mode, Set<String> allowedFiles

static void assertReflection(int maxCount, String whitelist) {
System.setProperty("counting.reflection.whitelist", whitelist);
System.getSecurityManager().checkPermission(new MaxCountCheck(maxCount, "MaxCountCheck"));
System.getProperties().remove("counting.reflection.whitelist");
}

Expand Down Expand Up @@ -129,7 +124,7 @@ public Integer call() throws Exception {
}

public static boolean isEnabled() {
return System.getSecurityManager() instanceof Callable<?>;
return false;
}

public static void assertCounts(String msg, int expectedCnt) throws Exception {
Expand Down
12 changes: 6 additions & 6 deletions platform/masterfs/nbproject/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ test.config.stableBTD.excludes=\
**/FileObjSymlinkTest.class,\
**/FolderObjTest.class,\
**/ChildrenSupportTest.class,\
**/ProvidedExtensionsTest.class,\
**/SlowRefreshAndPriorityIOTest.class,\
**/ProvidedExtensionsTest.class

test.unit.excludes=\
**/SlowRefreshSuspendableTest.class,\
**/StatFilesTest.class
spec.version.base=2.90.0
**/TwoFileNamesForASingleFileTest.class,\
**/FolderObjCacheTest.class

# TODO remove SM usage in tests
test.jms.flags=-Djava.security.manager=allow
spec.version.base=2.90.0
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ protected void setUp() throws Exception {
testFolder = FileUtil.toFileObject(dir);
assertNotNull("Test folder created", testFolder);

System.setSecurityManager(new FileChangedManager());
}

public void testRefreshCanBeSuspendedByPriorityIO() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ protected void setUp() throws Exception {
testFolder = FileUtil.toFileObject(dir);
assertNotNull("Test folder created", testFolder);

System.setSecurityManager(new FileChangedManager());
}

public void testChangesDeliveredSoonerThanEverythingIsChecked() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ protected void setUp() throws Exception {
testFolder = FileUtil.toFileObject(dir);
assertNotNull("Test folder created", testFolder);

System.setSecurityManager(new FileChangedManager());
}

@RandomlyFails // jglick: "No change detected expected:<0> but was:<1>"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ protected void setUp() throws Exception {
dir.mkdirs();
testFolder = FileUtil.toFileObject(dir);
assertNotNull("Test folder created", testFolder);

System.setSecurityManager(new FileChangedManager());
}

public void testRefreshPrefersSuggestedFolders() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ protected void setUp() throws Exception {
testFolder = FileUtil.toFileObject(dir);
assertNotNull("Test folder created", testFolder);

System.setSecurityManager(new FileChangedManager());
}

@RandomlyFails // NB-Core-Build #4386: Background I/O access needs to stop before we finish our task
Expand Down Expand Up @@ -169,6 +168,8 @@ void doWork() {
LOG.log(Level.INFO, "Created {0}", busyFile);
for (int i = 0; i < 2000; i ++) {
assertTrue("Can be read", busyFile.canRead());
// SecurityManager checks are not available on recent JDKs.
FileChangedManager.getInstance().checkRead(busyFile.getPath());
LOG.log(Level.INFO, "Touched {0}", i);
if (i > 100) {
synchronized (this) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ public TwoFileNamesForASingleFileTest(String name) {
@Override
protected void setUp() throws Exception {
clearWorkDir();
System.setSecurityManager(FileChangedManager.getInstance());
}

public void testTwoFileNames() throws Exception {
Expand All @@ -57,6 +56,7 @@ public void testTwoFileNames() throws Exception {
assertEquals("Empty is empty", 0, empty.length);

final File n = new File(f, "x.txt");
FileChangedManager.getInstance().checkWrite(n.getPath());
n.createNewFile();
FileObject fn = FileUtil.toFileObject(f);
assertNotNull("File object found", fn);
Expand All @@ -71,8 +71,10 @@ class R implements Runnable {
@Override
public void run() {
refresh();
FileChangedManager.getInstance().checkDelete(n.getPath());
n.delete();
none = fo.getChildren();
FileChangedManager.getInstance().checkWrite(n.getPath());
assertTrue("Directory creation succeeds", n.mkdirs());
refresh();
one = fo.getChildren();
Expand Down
Loading
Loading