Skip to content

Commit 2a99002

Browse files
committed
simplify thread.interrupt() logic
1 parent 352f811 commit 2a99002

File tree

1 file changed

+27
-31
lines changed

1 file changed

+27
-31
lines changed

src/aces/webctrl/dev/Initializer.java

Lines changed: 27 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -15,46 +15,42 @@ public class Initializer implements ServletContextListener {
1515
addons = info.getPrivateDir().toPath().getParent().getParent().getParent().getParent().getParent().resolve("addons").normalize();
1616
thread = new Thread(){
1717
@Override public void run(){
18-
try{
19-
String addonName;
20-
Path addon;
21-
while (go){
22-
try{
23-
try(
24-
DirectoryStream<Path> stream = Files.newDirectoryStream(addons);
25-
){
26-
for (Path p:stream){
27-
try{
28-
addonName = p.getFileName().toString();
29-
if (addonName.endsWith(".update")){
30-
addonName = addonName.substring(0,addonName.length()-7);
31-
if (!addonName.equals(name)){
32-
addon = addons.resolve(addonName+".addon");
33-
if (!Files.exists(addon) || HelperAPI.disableAddon(addonName)){
34-
try{
35-
Files.move(p,addon,StandardCopyOption.REPLACE_EXISTING);
36-
}catch(Throwable t){
37-
continue;
38-
}
39-
if (Files.exists(addon)){
40-
HelperAPI.enableAddon(addonName);
41-
HelperAPI.activateWebOperatorProvider(addon);
42-
}
18+
String addonName;
19+
Path addon;
20+
while (go){
21+
try{
22+
try(
23+
DirectoryStream<Path> stream = Files.newDirectoryStream(addons);
24+
){
25+
for (Path p:stream){
26+
try{
27+
addonName = p.getFileName().toString();
28+
if (addonName.endsWith(".update")){
29+
addonName = addonName.substring(0,addonName.length()-7);
30+
if (!addonName.equals(name)){
31+
addon = addons.resolve(addonName+".addon");
32+
if (!Files.exists(addon) || HelperAPI.disableAddon(addonName)){
33+
try{
34+
Files.move(p,addon,StandardCopyOption.REPLACE_EXISTING);
35+
}catch(Throwable t){
36+
continue;
37+
}
38+
if (Files.exists(addon)){
39+
HelperAPI.enableAddon(addonName);
40+
HelperAPI.activateWebOperatorProvider(addon);
4341
}
4442
}
4543
}
46-
}catch(Throwable t){
47-
t.printStackTrace();
4844
}
45+
}catch(Throwable t){
46+
t.printStackTrace();
4947
}
5048
}
51-
}catch(Throwable t){
52-
t.printStackTrace();
5349
}
5450
Thread.sleep(3000);
51+
}catch(InterruptedException e){}catch(Throwable t){
52+
t.printStackTrace();
5553
}
56-
}catch(InterruptedException e){}catch(Throwable t){
57-
t.printStackTrace();
5854
}
5955
}
6056
};

0 commit comments

Comments
 (0)