Remove need for AtomicInteger

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

View file

@ -5,7 +5,6 @@ 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;
@ -45,12 +44,12 @@ import the.bytecode.club.bytecodeviewer.resources.ExternalResources;
public class SecurityMan extends SecurityManager public class SecurityMan extends SecurityManager
{ {
private final AtomicInteger silentExec = new AtomicInteger(1); private volatile boolean silentExec = true;
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.addAndGet(b ? 1 : -1); silentExec = b;
} }
public void setPrinting(boolean printing) public void setPrinting(boolean printing)
@ -161,7 +160,7 @@ public class SecurityMan extends SecurityManager
//log exec if allowed //log exec if allowed
if (allow && validClassCall && !blocked) if (allow && validClassCall && !blocked)
{ {
if(silentExec.get() >= 1) if(silentExec)
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);