Skip to content

Commit 2f7cff6

Browse files
committed
Remove need for AtomicInteger
1 parent a86623c commit 2f7cff6

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

src/main/java/the/bytecode/club/bytecodeviewer/util/SecurityMan.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import java.io.IOException;
66
import java.net.InetAddress;
77
import java.security.Permission;
8-
import java.util.concurrent.atomic.AtomicInteger;
98
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
109
import the.bytecode.club.bytecodeviewer.Configuration;
1110
import the.bytecode.club.bytecodeviewer.Constants;
@@ -45,12 +44,12 @@
4544

4645
public class SecurityMan extends SecurityManager
4746
{
48-
private final AtomicInteger silentExec = new AtomicInteger(1);
47+
private volatile boolean silentExec = true;
4948
private boolean printing = false;
5049
private boolean printingPackage = false;
5150

5251
public void silenceExec(boolean b) {
53-
silentExec.addAndGet(b ? 1 : -1);
52+
silentExec = b;
5453
}
5554

5655
public void setPrinting(boolean printing)
@@ -161,7 +160,7 @@ else if(canClassExecute(Thread.currentThread().getStackTrace()[7].getClassName()
161160
//log exec if allowed
162161
if (allow && validClassCall && !blocked)
163162
{
164-
if(silentExec.get() >= 1)
163+
if(silentExec)
165164
System.err.println("Allowing exec: " + cmd);
166165
} //throw exception stopping execution
167166
else throw new SecurityException("BCV is awesome! Blocking exec: " + cmd);

0 commit comments

Comments
 (0)