-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix the system.exit when generate java file
- Loading branch information
Showing
3 changed files
with
68 additions
and
35 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
src/main/java/com/webank/webase/front/base/config/MySecurityManagerConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.webank.webase.front.base.config; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
|
||
@Slf4j | ||
public class MySecurityManagerConfig { | ||
|
||
public static void forbidSystemExitCall() { | ||
// Set current security manager. | ||
// If the argument is null and no security manager has been established then no action is taken | ||
System.setSecurityManager(new NoExitSecurityManager()); | ||
} | ||
|
||
public static void enableSystemExitCall() { | ||
System.setSecurityManager( null ) ; | ||
} | ||
|
||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/com/webank/webase/front/base/config/NoExitSecurityManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.webank.webase.front.base.config; | ||
|
||
import java.security.Permission; | ||
|
||
public class NoExitSecurityManager extends SecurityManager { | ||
@Override | ||
public void checkExit(int status) { | ||
throw new SecurityException(); | ||
} | ||
|
||
@Override | ||
public void checkPermission( Permission permission ) { | ||
if( "exitVM".equals( permission.getName() ) ) { | ||
throw new SecurityException(); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters