Revert "Remove need for AtomicInteger"

This reverts commit 2f7cff63c2.
This commit is contained in:
Nico Mexis 2021-09-16 13:55:28 +02:00
parent c8af835fb5
commit 0597ac33dd
No known key found for this signature in database
GPG key ID: 27D6E17CE092AB78

View file

@ -5,6 +5,7 @@ import java.io.FileDescriptor;
import java.io.IOException; import java.io.IOException;
import java.net.InetAddress; import java.net.InetAddress;
import java.security.Permission; import java.security.Permission;
import java.util.concurrent.atomic.AtomicInteger;
import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.BytecodeViewer;
import the.bytecode.club.bytecodeviewer.Configuration; import the.bytecode.club.bytecodeviewer.Configuration;
import the.bytecode.club.bytecodeviewer.Constants; import the.bytecode.club.bytecodeviewer.Constants;
@ -44,12 +45,12 @@ import the.bytecode.club.bytecodeviewer.resources.ExternalResources;
public class SecurityMan extends SecurityManager public class SecurityMan extends SecurityManager
{ {
private volatile boolean silentExec = true; private final AtomicInteger silentExec = new AtomicInteger(1);
private boolean printing = false; private boolean printing = false;
private boolean printingPackage = false; private boolean printingPackage = false;
public void silenceExec(boolean b) { public void silenceExec(boolean b) {
silentExec = b; silentExec.addAndGet(b ? 1 : -1);
} }
public void setPrinting(boolean printing) public void setPrinting(boolean printing)
@ -160,7 +161,7 @@ public class SecurityMan extends SecurityManager
//log exec if allowed //log exec if allowed
if (allow && validClassCall && !blocked) if (allow && validClassCall && !blocked)
{ {
if(silentExec) if(silentExec.get() >= 1)
System.err.println("Allowing exec: " + cmd); System.err.println("Allowing exec: " + cmd);
} //throw exception stopping execution } //throw exception stopping execution
else throw new SecurityException("BCV is awesome! Blocking exec: " + cmd); else throw new SecurityException("BCV is awesome! Blocking exec: " + cmd);