Skip to content

Commit 0597ac3

Browse files
committed
Revert "Remove need for AtomicInteger"
This reverts commit 2f7cff6.
1 parent c8af835 commit 0597ac3

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

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

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

4546
public class SecurityMan extends SecurityManager
4647
{
47-
private volatile boolean silentExec = true;
48+
private final AtomicInteger silentExec = new AtomicInteger(1);
4849
private boolean printing = false;
4950
private boolean printingPackage = false;
5051

5152
public void silenceExec(boolean b) {
52-
silentExec = b;
53+
silentExec.addAndGet(b ? 1 : -1);
5354
}
5455

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

0 commit comments

Comments
 (0)