You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
GatewayUtils does not detect http status code range #9
I found that GatewayUtils class does not detect http status code come from error class attribute code thrown, please make a new release version changed please.
public static final void sendError(WebResponse rsp, Throwable cause) {
try {
MoleculerError error = null;
Throwable err = cause;
while (err != null) {
if (err instanceof MoleculerError) {
error = (MoleculerError) err;
break;
}
if (err.getCause() == null) {
break;
}
err = err.getCause();
}
if (error == null) {
String msg = null;
String type = null;
if (err != null) {
msg = err.getMessage();
type = err.getClass().getName();
int i = type.lastIndexOf('.');
if (i > -1) {
type = type.substring(i + 1);
}
type = type.replaceAll("(.)(\p{Upper})", "$1_$2").toUpperCase();
}
if (msg == null || msg.isEmpty()) {
msg = "Unknown error occured!";
}
if (type == null || type.isEmpty()) {
type = "MOLECULER_ERROR";
}
error = new MoleculerError(msg, cause, "unknown", false, 500, type, null);
}
Tree json = error.toTree();
byte[] body = json.toBinary();
int statusCode = error.getCode();
if (statusCode < 100 || statusCode > 599) {
statusCode = 500;
}
rsp.setStatus(statusCode);
rsp.setHeader(CACHE_CONTROL, NO_CACHE);
rsp.setHeader(CONTENT_TYPE, CONTENT_TYPE_JSON);
rsp.setHeader(CONTENT_LENGTH, Integer.toString(body.length));
rsp.send(body);
} catch (Exception ignored) {
logger.debug("Unable to send error response!", ignored);
} finally {
rsp.end();
}
}
Hi tassun, thanks for reporting this! The issue with HTTP status code handling in GatewayUtils has been fixed, and the change will be available soon in moleculer-java-web v1.3.13 on Maven Central.
Activity
berkesa commentedon Apr 10, 2026
Hi tassun, thanks for reporting this! The issue with HTTP status code handling in GatewayUtils has been fixed, and the change will be available soon in moleculer-java-web v1.3.13 on Maven Central.