Skip to content

Commit

Permalink
update log
Browse files Browse the repository at this point in the history
  • Loading branch information
sunwu51 committed Feb 18, 2024
1 parent 8301bf8 commit e07f17d
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<artifactId>tools</artifactId>
<version>1.8</version>
<scope>system</scope>
<systemPath>${JAVA_HOME}/lib/tools.jar</systemPath>
<systemPath>${JAVA8_HOME}/lib/tools.jar</systemPath>
</dependency>
<dependency>
<groupId>org.nanohttpd</groupId> <!-- <groupId>com.nanohttpd</groupId> for 2.1.0 and earlier -->
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/w/core/ExecBundle.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ public synchronized static void changeBodyAndInvoke(String body) throws Exceptio
});
Global.activeTransformers
.getOrDefault("w.Exec", new HashMap<>()).clear();
Swapper.getInstance().swap(message);
invoke();
if (Swapper.getInstance().swap(message)) {
invoke();
}
}
}
7 changes: 5 additions & 2 deletions src/main/java/w/core/Swapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public static Swapper getInstance() {
return INSTANCE;
}

public void swap(Message message) {
public boolean swap(Message message) {
BaseClassTransformer transformer = null;
try {
switch (message.getType()) {
Expand Down Expand Up @@ -49,7 +49,7 @@ public void swap(Message message) {
e.printStackTrace(pw);
String stackTraceString = sw.toString();
Global.error("build transform error:\n " + stackTraceString);
return;
return false;
}

Global.addTransformer(transformer);
Expand All @@ -65,8 +65,11 @@ public void swap(Message message) {
e.printStackTrace(pw);
String stackTraceString = sw.toString();
Global.error("re transform error:\n " + stackTraceString);
return false;
}
}

return true;
}
}

Expand Down
14 changes: 12 additions & 2 deletions src/main/java/w/web/Websocketd.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import fi.iki.elonen.NanoWSD;

import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.UUID;

/**
Expand Down Expand Up @@ -77,7 +79,11 @@ private void dispatch(String msg) {
try {
Global.deleteTransformer(UUID.fromString(deleteMessage.getUuid()));
} catch (Exception e) {
Global.error(e.getMessage());
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
String stackTraceString = sw.toString();
Global.error("delete error:\n " + stackTraceString);
}
}
break;
Expand All @@ -89,7 +95,11 @@ private void dispatch(String msg) {
e.printStackTrace();
Global.error("not a valid message");
} catch (Throwable e) {
e.printStackTrace();
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
String stackTraceString = sw.toString();
Global.error("error:\n " + stackTraceString);
} finally {
RequestUtils.clearRequestCtx();
}
Expand Down

0 comments on commit e07f17d

Please sign in to comment.