增加RedkaleException
This commit is contained in:
@@ -290,7 +290,7 @@ public final class Application {
|
||||
this.confPath = confFile.toURI();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
throw new RedkaleException(e);
|
||||
}
|
||||
{ //设置系统变量
|
||||
AnyValue propertiesConf = this.config.getAnyValue("properties");
|
||||
@@ -450,7 +450,7 @@ public final class Application {
|
||||
try {
|
||||
loadResourceProperties();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
throw new RedkaleException(e);
|
||||
}
|
||||
//------------------------------------ 配置 <transport> 节点 ------------------------------------
|
||||
TransportStrategy strategy = null;
|
||||
@@ -533,7 +533,7 @@ public final class Application {
|
||||
AnyValue mqConf = mqConfs[i];
|
||||
String mqname = mqConf.getValue("name", "");
|
||||
if (mqnames.contains(mqname)) {
|
||||
throw new RuntimeException("mq.name(" + mqname + ") is repeat");
|
||||
throw new RedkaleException("mq.name(" + mqname + ") is repeat");
|
||||
}
|
||||
mqnames.add(mqname);
|
||||
String namex = mqConf.getValue("names");
|
||||
@@ -543,7 +543,7 @@ public final class Application {
|
||||
continue;
|
||||
}
|
||||
if (mqnames.contains(n.trim())) {
|
||||
throw new RuntimeException("mq.name(" + n.trim() + ") is repeat");
|
||||
throw new RedkaleException("mq.name(" + n.trim() + ") is repeat");
|
||||
}
|
||||
mqnames.add(n.trim());
|
||||
}
|
||||
@@ -1009,7 +1009,7 @@ public final class Application {
|
||||
}
|
||||
for (char ch : name.toCharArray()) {
|
||||
if (!((ch >= '0' && ch <= '9') || ch == '_' || ch == '.' || ch == '-' || (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z'))) { //不能含特殊字符
|
||||
throw new RuntimeException("name only 0-9 a-z A-Z _ - . cannot begin 0-9");
|
||||
throw new RedkaleException("name only 0-9 a-z A-Z _ - . cannot begin 0-9");
|
||||
}
|
||||
}
|
||||
return name;
|
||||
@@ -1335,7 +1335,7 @@ public final class Application {
|
||||
final String group = conf.getValue("name", "");
|
||||
final String protocol = conf.getValue("protocol", Transport.DEFAULT_NETPROTOCOL).toUpperCase();
|
||||
if (!"TCP".equalsIgnoreCase(protocol) && !"UDP".equalsIgnoreCase(protocol)) {
|
||||
throw new RuntimeException("Not supported Transport Protocol " + conf.getValue("protocol"));
|
||||
throw new RedkaleException("Not supported Transport Protocol " + conf.getValue("protocol"));
|
||||
}
|
||||
TransportGroupInfo ginfo = new TransportGroupInfo(group, protocol, new LinkedHashSet<>());
|
||||
for (AnyValue node : conf.getAnyValues("node")) {
|
||||
@@ -1576,7 +1576,7 @@ public final class Application {
|
||||
}
|
||||
}
|
||||
if (watchs.size() > 1) {
|
||||
throw new RuntimeException("Found one more WATCH Server");
|
||||
throw new RedkaleException("Found one more WATCH Server");
|
||||
}
|
||||
this.watching = !watchs.isEmpty();
|
||||
|
||||
@@ -1706,7 +1706,7 @@ public final class Application {
|
||||
}
|
||||
final Class<? extends NodeServer> old = nodeClasses.get(p);
|
||||
if (old != null && old != type) {
|
||||
throw new RuntimeException("Protocol(" + p + ") had NodeServer-Class(" + old.getName() + ") but repeat NodeServer-Class(" + type.getName() + ")");
|
||||
throw new RedkaleException("Protocol(" + p + ") had NodeServer-Class(" + old.getName() + ") but repeat NodeServer-Class(" + type.getName() + ")");
|
||||
}
|
||||
nodeClasses.put(p, type);
|
||||
}
|
||||
|
||||
@@ -612,7 +612,7 @@ public final class ClassFilter<T> {
|
||||
} else if (root.isDirectory()) {
|
||||
if (exclude != null && exclude.equals(root)) return;
|
||||
File[] lfs = root.listFiles();
|
||||
if (lfs == null) throw new RuntimeException("File(" + root + ") cannot listFiles()");
|
||||
if (lfs == null) throw new RedkaleException("File(" + root + ") cannot listFiles()");
|
||||
for (File f : lfs) {
|
||||
loadClassFiles(exclude, f, files);
|
||||
}
|
||||
|
||||
@@ -153,12 +153,12 @@ public class LoggingSearchHandler extends LoggingBaseHandler {
|
||||
String cname = getClass().getName();
|
||||
this.sourceResourceName = manager.getProperty(cname + ".source");
|
||||
if (this.sourceResourceName == null || this.sourceResourceName.isEmpty()) {
|
||||
throw new RuntimeException("not found logging.property " + cname + ".source");
|
||||
throw new RedkaleException("not found logging.property " + cname + ".source");
|
||||
}
|
||||
String tagstr = manager.getProperty(cname + ".tag");
|
||||
if (tagstr != null && !tagstr.isEmpty()) {
|
||||
if (!checkTagName(tagstr.replaceAll("\\$\\{.+\\}", ""))) {
|
||||
throw new RuntimeException("found illegal logging.property " + cname + ".tag = " + tagstr);
|
||||
throw new RedkaleException("found illegal logging.property " + cname + ".tag = " + tagstr);
|
||||
}
|
||||
this.tag = tagstr.replace("${" + RESNAME_APP_NAME + "}", System.getProperty(RESNAME_APP_NAME, ""));
|
||||
if (this.tag.contains("%")) {
|
||||
|
||||
@@ -364,7 +364,7 @@ public class NodeHttpServer extends NodeServer {
|
||||
if (mqname != null) {
|
||||
agent0 = application.getMessageAgent(mqname);
|
||||
if (agent0 == null) {
|
||||
throw new RuntimeException("not found " + MessageAgent.class.getSimpleName() + " config for (name=" + mqname + ")");
|
||||
throw new RedkaleException("not found " + MessageAgent.class.getSimpleName() + " config for (name=" + mqname + ")");
|
||||
}
|
||||
}
|
||||
final MessageAgent messageAgent = agent0;
|
||||
|
||||
@@ -120,7 +120,7 @@ public abstract class NodeServer {
|
||||
RedkaleClassLoader.putReflectionDeclaredConstructors(clazz, clazz.getName(), Application.class, AnyValue.class);
|
||||
return clazz.getDeclaredConstructor(Application.class, AnyValue.class).newInstance(application, serconf);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
throw new RedkaleException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ public abstract class NodeServer {
|
||||
this.sncpAddress = new InetSocketAddress(host.isEmpty() ? application.localAddress.getAddress().getHostAddress() : host, this.serverConf.getIntValue("port"));
|
||||
this.sncpGroup = application.getSncpTransportFactory().findGroupName(this.sncpAddress);
|
||||
//单向SNCP服务不需要对等group
|
||||
//if (this.sncpGroup == null) throw new RuntimeException("Server (" + String.valueOf(config).replaceAll("\\s+", " ") + ") not found <group> info");
|
||||
//if (this.sncpGroup == null) throw new RedkaleException("Server (" + String.valueOf(config).replaceAll("\\s+", " ") + ") not found <group> info");
|
||||
}
|
||||
//单点服务不会有 sncpAddress、sncpGroup
|
||||
if (this.sncpAddress != null) {
|
||||
@@ -340,7 +340,7 @@ public abstract class NodeServer {
|
||||
return null; //远程模式不需要注入 CacheSource
|
||||
}
|
||||
if (!(srcObj instanceof Service)) {
|
||||
throw new RuntimeException("CacheSource must be inject in Service, cannot in " + srcObj);
|
||||
throw new RedkaleException("CacheSource must be inject in Service, cannot in " + srcObj);
|
||||
}
|
||||
final Service srcService = (Service) srcObj;
|
||||
SncpOldClient client = Sncp.getSncpOldClient(srcService);
|
||||
@@ -467,7 +467,7 @@ public abstract class NodeServer {
|
||||
}
|
||||
}
|
||||
if (entry.getName().contains("$")) {
|
||||
throw new RuntimeException("<name> value cannot contains '$' in " + entry.getProperty());
|
||||
throw new RedkaleException("<name> value cannot contains '$' in " + entry.getProperty());
|
||||
}
|
||||
Service oldother = resourceFactory.find(entry.getName(), serviceImplClass);
|
||||
if (oldother != null) { //Server加载Service时需要判断是否已经加载过了。
|
||||
@@ -523,7 +523,7 @@ public abstract class NodeServer {
|
||||
if (rf.find(resourceName, restype) == null) {
|
||||
regFactory.register(resourceName, restype, service);
|
||||
} else if (isSNCP() && !entry.isAutoload()) {
|
||||
throw new RuntimeException(restype.getSimpleName() + "(class:" + serviceImplClass.getName() + ", name:" + resourceName + ", group:" + groups + ") is repeat.");
|
||||
throw new RedkaleException(restype.getSimpleName() + "(class:" + serviceImplClass.getName() + ", name:" + resourceName + ", group:" + groups + ") is repeat.");
|
||||
}
|
||||
if (Sncp.isRemote(service)) {
|
||||
remoteServices.add(service);
|
||||
@@ -545,7 +545,7 @@ public abstract class NodeServer {
|
||||
} catch (RuntimeException ex) {
|
||||
throw ex;
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
throw new RedkaleException(e);
|
||||
}
|
||||
};
|
||||
if (entry.isExpect()) {
|
||||
|
||||
@@ -241,7 +241,7 @@ public class CacheClusterAgent extends ClusterAgent implements Resourcable {
|
||||
@Override
|
||||
public void register(Application application) {
|
||||
if (isApplicationHealth()) {
|
||||
throw new RuntimeException("application.nodeid=" + nodeid + " exists in cluster");
|
||||
throw new RedkaleException("application.nodeid=" + nodeid + " exists in cluster");
|
||||
}
|
||||
deregister(application);
|
||||
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
*/
|
||||
package org.redkale.convert;
|
||||
|
||||
import org.redkale.util.RedkaleException;
|
||||
|
||||
/**
|
||||
* 序列化自定义异常类
|
||||
*
|
||||
@@ -12,7 +14,7 @@ package org.redkale.convert;
|
||||
*
|
||||
* @author zhangjx
|
||||
*/
|
||||
public class ConvertException extends RuntimeException {
|
||||
public class ConvertException extends RedkaleException {
|
||||
|
||||
public ConvertException() {
|
||||
super();
|
||||
|
||||
@@ -62,7 +62,7 @@ public final class EnumSimpledCoder<R extends Reader, W extends Writer, E extend
|
||||
this.enumToValues = map1;
|
||||
this.valueToEnums = map2;
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
throw new ConvertException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ public final class IntSimpledCoder<R extends Reader, W extends Writer> extends S
|
||||
out.writeSmallString("0x0");
|
||||
} else {
|
||||
if (value < 0) {
|
||||
throw new NumberFormatException("Negative values (" + value + ") are not supported");
|
||||
throw new ConvertException("Negative values (" + value + ") are not supported");
|
||||
}
|
||||
out.writeSmallString("0x" + Integer.toHexString(value));
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ public final class LongSimpledCoder<R extends Reader, W extends Writer> extends
|
||||
out.writeSmallString("0x0");
|
||||
} else {
|
||||
if (value < 0) {
|
||||
throw new NumberFormatException("Negative values (" + value + ") are not supported");
|
||||
throw new ConvertException("Negative values (" + value + ") are not supported");
|
||||
}
|
||||
out.writeSmallString("0x" + Long.toHexString(value));
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ public class JsonByteBufferReader extends JsonReader {
|
||||
}
|
||||
return Character.lowSurrogate(uc);
|
||||
} else {
|
||||
throw new RuntimeException(new UnmappableCharacterException(4));
|
||||
throw new ConvertException(new UnmappableCharacterException(4));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ import org.redkale.boot.*;
|
||||
import org.redkale.convert.Convert;
|
||||
import org.redkale.convert.json.JsonConvert;
|
||||
import org.redkale.net.http.*;
|
||||
import org.redkale.util.RedkaleException;
|
||||
|
||||
/**
|
||||
* 没有配置MQ且也没有ClusterAgent的情况下实现的默认HttpMessageClient实例
|
||||
@@ -159,7 +160,7 @@ public class HttpMessageLocalClient extends HttpMessageClient {
|
||||
try {
|
||||
servlet.execute(req, resp);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
throw new RedkaleException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ public abstract class MessageAgent implements Resourcable {
|
||||
} catch (RuntimeException ex) {
|
||||
throw ex;
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
throw new RedkaleException(e);
|
||||
}
|
||||
}
|
||||
// application (it doesn't execute completion handlers).
|
||||
@@ -214,11 +214,11 @@ public abstract class MessageAgent implements Resourcable {
|
||||
return name;
|
||||
}
|
||||
if (name.charAt(0) >= '0' && name.charAt(0) <= '9') {
|
||||
throw new RuntimeException("name only 0-9 a-z A-Z _ cannot begin 0-9");
|
||||
throw new RedkaleException("name only 0-9 a-z A-Z _ cannot begin 0-9");
|
||||
}
|
||||
for (char ch : name.toCharArray()) {
|
||||
if (!((ch >= '0' && ch <= '9') || ch == '_' || (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z'))) { //不能含特殊字符
|
||||
throw new RuntimeException("name only 0-9 a-z A-Z _ cannot begin 0-9");
|
||||
throw new RedkaleException("name only 0-9 a-z A-Z _ cannot begin 0-9");
|
||||
}
|
||||
}
|
||||
return name;
|
||||
@@ -313,7 +313,7 @@ public abstract class MessageAgent implements Resourcable {
|
||||
httpNodesLock.lock();
|
||||
try {
|
||||
if (messageNodes.containsKey(consumerid)) {
|
||||
throw new RuntimeException("consumerid(" + consumerid + ") is repeat");
|
||||
throw new RedkaleException("consumerid(" + consumerid + ") is repeat");
|
||||
}
|
||||
HttpMessageProcessor processor = new HttpMessageProcessor(this.logger, httpMessageClient, getHttpProducer(), ns, service, servlet);
|
||||
this.messageNodes.put(consumerid, new MessageConsumerNode(ns, service, servlet, processor, createConsumer(topics, consumerid, processor)));
|
||||
@@ -336,7 +336,7 @@ public abstract class MessageAgent implements Resourcable {
|
||||
sncpNodesLock.lock();
|
||||
try {
|
||||
if (messageNodes.containsKey(consumerid)) {
|
||||
throw new RuntimeException("consumerid(" + consumerid + ") is repeat");
|
||||
throw new RedkaleException("consumerid(" + consumerid + ") is repeat");
|
||||
}
|
||||
SncpMessageProcessor processor = new SncpMessageProcessor(this.logger, sncpMessageClient, getSncpProducer(), ns, service, servlet);
|
||||
this.messageNodes.put(consumerid, new MessageConsumerNode(ns, service, servlet, processor, createConsumer(new String[]{topic}, consumerid, processor)));
|
||||
|
||||
@@ -455,7 +455,7 @@ public abstract class AsyncConnection implements ChannelContext, Channel, AutoCl
|
||||
|
||||
public void setReadBuffer(ByteBuffer buffer) {
|
||||
if (this.readBuffer != null) {
|
||||
throw new RuntimeException("repeat AsyncConnection.setReadBuffer");
|
||||
throw new RedkaleException("repeat AsyncConnection.setReadBuffer");
|
||||
}
|
||||
this.readBuffer = buffer;
|
||||
}
|
||||
@@ -684,7 +684,7 @@ public abstract class AsyncConnection implements ChannelContext, Channel, AutoCl
|
||||
|
||||
protected void setReadSSLBuffer(ByteBuffer buffer) {
|
||||
if (this.readSSLHalfBuffer != null) {
|
||||
throw new RuntimeException("repeat AsyncConnection.setReadSSLBuffer");
|
||||
throw new RedkaleException("repeat AsyncConnection.setReadSSLBuffer");
|
||||
}
|
||||
this.readSSLHalfBuffer = buffer;
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ public class AsyncIOGroup extends AsyncGroup {
|
||||
this.connectThread = null;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
throw new RedkaleException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ public class AsyncIOGroup extends AsyncGroup {
|
||||
return this;
|
||||
}
|
||||
if (closed.get()) {
|
||||
throw new RuntimeException("group is closed");
|
||||
throw new RedkaleException("group is closed");
|
||||
}
|
||||
for (int i = 0; i < this.ioReadThreads.length; i++) {
|
||||
this.ioReadThreads[i].start();
|
||||
@@ -214,7 +214,7 @@ public class AsyncIOGroup extends AsyncGroup {
|
||||
try {
|
||||
return newTCPClientConnection(null);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
throw new RedkaleException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -302,7 +302,7 @@ public class AsyncIOGroup extends AsyncGroup {
|
||||
try {
|
||||
return newUDPClientConnection(null);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
throw new RedkaleException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ public class AsyncIOThread extends WorkThread {
|
||||
return;
|
||||
}
|
||||
if (key.selector() != selector) {
|
||||
throw new RuntimeException("NioThread.selector not the same to SelectionKey.selector");
|
||||
throw new RedkaleException("NioThread.selector not the same to SelectionKey.selector");
|
||||
}
|
||||
if ((key.interestOps() & opt) != 0) {
|
||||
return;
|
||||
|
||||
@@ -188,7 +188,7 @@ class AsyncNioTcpProtocolServer extends ProtocolServer {
|
||||
} else if (t instanceof RuntimeException) {
|
||||
throw (RuntimeException) t;
|
||||
} else {
|
||||
throw new RuntimeException(t);
|
||||
throw new RedkaleException(t);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -181,7 +181,7 @@ class AsyncNioUdpProtocolServer extends ProtocolServer {
|
||||
} else if (t instanceof RuntimeException) {
|
||||
throw (RuntimeException) t;
|
||||
} else {
|
||||
throw new RuntimeException(t);
|
||||
throw new RedkaleException(t);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import java.net.*;
|
||||
import java.util.Set;
|
||||
import org.redkale.annotation.Resource;
|
||||
import org.redkale.boot.Application;
|
||||
import org.redkale.util.AnyValue;
|
||||
import org.redkale.util.*;
|
||||
|
||||
/**
|
||||
* 协议底层Server
|
||||
@@ -56,7 +56,7 @@ public abstract class ProtocolServer {
|
||||
} else if ("UDP".equalsIgnoreCase(protocol)) {
|
||||
return new AsyncNioUdpProtocolServer(context);
|
||||
} else {
|
||||
throw new RuntimeException(ProtocolServer.class.getSimpleName() + " not support protocol " + protocol);
|
||||
throw new RedkaleException(ProtocolServer.class.getSimpleName() + " not support protocol " + protocol);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -134,7 +134,7 @@ public abstract class Server<K extends Serializable, C extends Context, R extend
|
||||
this.responsePoolSize = config.getIntValue("responsePoolSize", 1024);
|
||||
this.name = config.getValue("name", "Server-" + config.getValue("protocol", netprotocol).replaceFirst("\\..+", "").toUpperCase() + "-" + this.address.getPort());
|
||||
if (!this.name.matches("^[a-zA-Z][\\w_-]{1,64}$")) {
|
||||
throw new RuntimeException("server.name (" + this.name + ") is illegal");
|
||||
throw new RedkaleException("server.name (" + this.name + ") is illegal");
|
||||
}
|
||||
AnyValue sslConf = config.getAnyValue("ssl");
|
||||
if (sslConf != null) {
|
||||
@@ -544,7 +544,7 @@ public abstract class Server<K extends Serializable, C extends Context, R extend
|
||||
if (root.isDirectory()) {
|
||||
File[] lfs = root.listFiles();
|
||||
if (lfs == null) {
|
||||
throw new RuntimeException("File(" + root + ") cannot listFiles()");
|
||||
throw new RedkaleException("File(" + root + ") cannot listFiles()");
|
||||
}
|
||||
for (File f : lfs) {
|
||||
set.add(f.toURI().toURL());
|
||||
@@ -558,7 +558,7 @@ public abstract class Server<K extends Serializable, C extends Context, R extend
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
throw new RedkaleException(e);
|
||||
}
|
||||
if (set.isEmpty()) {
|
||||
return new URL[0];
|
||||
|
||||
@@ -20,7 +20,7 @@ import javax.net.ssl.SSLContext;
|
||||
import org.redkale.annotation.ConstructorParameters;
|
||||
import org.redkale.convert.ConvertDisabled;
|
||||
import org.redkale.convert.json.JsonConvert;
|
||||
import org.redkale.util.Utility;
|
||||
import org.redkale.util.*;
|
||||
|
||||
/**
|
||||
* 传输客户端
|
||||
@@ -268,7 +268,7 @@ public final class Transport {
|
||||
final SocketAddress addr = addr0;
|
||||
final boolean rand = addr == null; //是否随机取地址
|
||||
if (rand && nodes.length < 1) {
|
||||
throw new RuntimeException("Transport (" + this.name + ") have no remoteAddress list");
|
||||
throw new RedkaleException("Transport (" + this.name + ") have no remoteAddress list");
|
||||
}
|
||||
try {
|
||||
if (!tcp) { // UDP
|
||||
@@ -315,7 +315,7 @@ public final class Transport {
|
||||
}
|
||||
return pollConnection0(nodes, null, now);
|
||||
} catch (Exception ex) {
|
||||
throw new RuntimeException("transport address = " + addr, ex);
|
||||
throw new RedkaleException("transport address = " + addr, ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -209,21 +209,21 @@ public class TransportFactory {
|
||||
|
||||
public boolean addGroupInfo(TransportGroupInfo info) {
|
||||
if (info == null) {
|
||||
throw new RuntimeException("TransportGroupInfo can not null");
|
||||
throw new RedkaleException("TransportGroupInfo can not null");
|
||||
}
|
||||
if (info.addresses == null) {
|
||||
throw new RuntimeException("TransportGroupInfo.addresses can not null");
|
||||
throw new RedkaleException("TransportGroupInfo.addresses can not null");
|
||||
}
|
||||
if (!checkName(info.name)) {
|
||||
throw new RuntimeException("Transport.group.name only 0-9 a-z A-Z _ cannot begin 0-9");
|
||||
throw new RedkaleException("Transport.group.name only 0-9 a-z A-Z _ cannot begin 0-9");
|
||||
}
|
||||
TransportGroupInfo old = groupInfos.get(info.name);
|
||||
if (old != null && !old.protocol.equals(info.protocol)) {
|
||||
throw new RuntimeException("Transport.group.name repeat but protocol is different");
|
||||
throw new RedkaleException("Transport.group.name repeat but protocol is different");
|
||||
}
|
||||
for (InetSocketAddress addr : info.addresses) {
|
||||
if (!groupAddrs.getOrDefault(addr, info.name).equals(info.name)) {
|
||||
throw new RuntimeException(addr + " repeat but different group.name");
|
||||
throw new RedkaleException(addr + " repeat but different group.name");
|
||||
}
|
||||
}
|
||||
if (old == null) {
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
*/
|
||||
package org.redkale.net.http;
|
||||
|
||||
import org.redkale.util.RedkaleException;
|
||||
|
||||
/**
|
||||
* Http自定义异常类
|
||||
*
|
||||
@@ -13,7 +15,7 @@ package org.redkale.net.http;
|
||||
*
|
||||
* @since 2.8.0
|
||||
*/
|
||||
public class HttpException extends RuntimeException {
|
||||
public class HttpException extends RedkaleException {
|
||||
|
||||
public HttpException() {
|
||||
super();
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
*/
|
||||
package org.redkale.net.sncp;
|
||||
|
||||
import org.redkale.util.RedkaleException;
|
||||
|
||||
/**
|
||||
* Sncp自定义异常类
|
||||
*
|
||||
@@ -13,7 +15,7 @@ package org.redkale.net.sncp;
|
||||
*
|
||||
* @since 2.8.0
|
||||
*/
|
||||
public class SncpException extends RuntimeException {
|
||||
public class SncpException extends RedkaleException {
|
||||
|
||||
public SncpException() {
|
||||
super();
|
||||
|
||||
@@ -145,9 +145,9 @@ public class RetResult<T> implements Serializable {
|
||||
try {
|
||||
return future.get(timeout, unit);
|
||||
} catch (ExecutionException ex) {
|
||||
throw new RuntimeException(ex.getCause());
|
||||
throw new RedkaleException(ex.getCause());
|
||||
} catch (Exception ex) {
|
||||
throw new RuntimeException(ex);
|
||||
throw new RedkaleException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
*/
|
||||
package org.redkale.service;
|
||||
|
||||
import org.redkale.util.RedkaleException;
|
||||
|
||||
/**
|
||||
* 供RPC协议使用
|
||||
*
|
||||
@@ -13,7 +15,7 @@ package org.redkale.service;
|
||||
*
|
||||
* @author zhangjx
|
||||
*/
|
||||
public class RpcRemoteException extends RuntimeException {
|
||||
public class RpcRemoteException extends RedkaleException {
|
||||
|
||||
public RpcRemoteException() {
|
||||
super();
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
*/
|
||||
package org.redkale.source;
|
||||
|
||||
import org.redkale.util.RedkaleException;
|
||||
|
||||
/**
|
||||
* 数据源自定义异常类
|
||||
*
|
||||
@@ -13,7 +15,7 @@ package org.redkale.source;
|
||||
*
|
||||
* @since 2.8.0
|
||||
*/
|
||||
public class SourceException extends RuntimeException {
|
||||
public class SourceException extends RedkaleException {
|
||||
|
||||
public SourceException() {
|
||||
super();
|
||||
|
||||
@@ -225,7 +225,7 @@ public interface Attribute<T, F> {
|
||||
try {
|
||||
return create(clazz, fieldName, (Class) null, clazz.getDeclaredField(fieldName), (java.lang.reflect.Method) null, (java.lang.reflect.Method) null, null);
|
||||
} catch (NoSuchFieldException | SecurityException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
throw new RedkaleException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -244,7 +244,7 @@ public interface Attribute<T, F> {
|
||||
try {
|
||||
return create(clazz, fieldName, (Class) null, clazz.getDeclaredField(fieldName), (java.lang.reflect.Method) null, (java.lang.reflect.Method) null, attach);
|
||||
} catch (NoSuchFieldException | SecurityException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
throw new RedkaleException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -753,7 +753,7 @@ public interface Attribute<T, F> {
|
||||
fieldkey = (fieldAlias == null ? "" : ("0_" + fieldAlias + "_")) + "2_" + setter.getName();
|
||||
}
|
||||
if (fieldAlias == null && fieldType == null && tgetter == null && tsetter == null && tfield == null) {
|
||||
throw new RuntimeException("[" + clazz + "]have no public field or setter or getter");
|
||||
throw new RedkaleException("[" + clazz + "]have no public field or setter or getter");
|
||||
}
|
||||
final String fieldName = fieldAlias;
|
||||
Class column = fieldType;
|
||||
@@ -768,9 +768,9 @@ public interface Attribute<T, F> {
|
||||
column = tsetter.getParameterTypes()[0];
|
||||
generictype = tsetter.getGenericParameterTypes()[0];
|
||||
} else if (fieldType == null) {
|
||||
throw new RuntimeException("[" + clazz + "]have no public field or setter or getter");
|
||||
throw new RedkaleException("[" + clazz + "]have no public field or setter or getter");
|
||||
} else if (column == null) {
|
||||
throw new RuntimeException("[" + clazz + "]have no field type");
|
||||
throw new RedkaleException("[" + clazz + "]have no field type");
|
||||
}
|
||||
boolean checkCast = false;
|
||||
if (generictype instanceof java.lang.reflect.TypeVariable) {
|
||||
@@ -966,7 +966,7 @@ public interface Attribute<T, F> {
|
||||
mv.visitMethodInsn(INVOKEVIRTUAL, columnName, pm.getName(), Type.getMethodDescriptor(pm), false);
|
||||
m = 3;
|
||||
} catch (Exception ex) {
|
||||
throw new RuntimeException(ex); //不可能会发生
|
||||
throw new RedkaleException(ex); //不可能会发生
|
||||
}
|
||||
}
|
||||
if (!tfield.getType().isPrimitive() && tfield.getGenericType() instanceof TypeVariable) {
|
||||
@@ -984,7 +984,7 @@ public interface Attribute<T, F> {
|
||||
mv.visitMethodInsn(INVOKEVIRTUAL, columnName, pm.getName(), Type.getMethodDescriptor(pm), false);
|
||||
m = 3;
|
||||
} catch (Exception ex) {
|
||||
throw new RuntimeException(ex); //不可能会发生
|
||||
throw new RedkaleException(ex); //不可能会发生
|
||||
}
|
||||
}
|
||||
mv.visitMethodInsn(INVOKEVIRTUAL, interName, tsetter.getName(), Type.getMethodDescriptor(tsetter), false);
|
||||
@@ -1045,7 +1045,7 @@ public interface Attribute<T, F> {
|
||||
RedkaleClassLoader.putReflectionField(newDynName.replace('/', '.'), _attach);
|
||||
return rs;
|
||||
} catch (Exception ex) {
|
||||
throw new RuntimeException(ex);
|
||||
throw new RedkaleException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -205,7 +205,7 @@ public interface Creator<T> {
|
||||
return creator;
|
||||
}
|
||||
if (clazz.isInterface() || Modifier.isAbstract(clazz.getModifiers())) {
|
||||
throw new RuntimeException("[" + clazz + "] is a interface or abstract class, cannot create it's Creator.");
|
||||
throw new RedkaleException("[" + clazz + "] is a interface or abstract class, cannot create it's Creator.");
|
||||
}
|
||||
for (final Method method : clazz.getDeclaredMethods()) { //查找类中是否存在提供创建Creator实例的静态方法
|
||||
if (!Modifier.isStatic(method.getModifiers())) {
|
||||
@@ -226,7 +226,7 @@ public interface Creator<T> {
|
||||
return c;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
throw new RedkaleException(e);
|
||||
}
|
||||
}
|
||||
final String supDynName = Creator.class.getName().replace('.', '/');
|
||||
@@ -336,7 +336,7 @@ public interface Creator<T> {
|
||||
final Constructor<T> constructor = constructor0;
|
||||
final SimpleEntry<String, Class>[] constructorParameters = constructorParameters0;
|
||||
if (constructor == null || constructorParameters == null) {
|
||||
throw new RuntimeException("[" + clazz + "] have no public or ConstructorParameters-Annotation constructor.");
|
||||
throw new RedkaleException("[" + clazz + "] have no public or ConstructorParameters-Annotation constructor.");
|
||||
}
|
||||
final int[] iconsts = {ICONST_0, ICONST_1, ICONST_2, ICONST_3, ICONST_4, ICONST_5};
|
||||
//-------------------------------------------------------------
|
||||
@@ -497,7 +497,7 @@ public interface Creator<T> {
|
||||
Method pm = bigct.getMethod(ct.getSimpleName() + "Value");
|
||||
mv.visitMethodInsn(INVOKEVIRTUAL, bigct.getName().replace('.', '/'), pm.getName(), Type.getMethodDescriptor(pm), false);
|
||||
} catch (Exception ex) {
|
||||
throw new RuntimeException(ex); //不可能会发生
|
||||
throw new RedkaleException(ex); //不可能会发生
|
||||
}
|
||||
} else {
|
||||
mv.visitTypeInsn(CHECKCAST, ct.getName().replace('.', '/'));
|
||||
@@ -550,7 +550,7 @@ public interface Creator<T> {
|
||||
}
|
||||
}
|
||||
if (!ispub && resultClazz == null) {
|
||||
throw new RuntimeException("[" + clazz + "] have no public or ConstructorParameters-Annotation constructor.");
|
||||
throw new RedkaleException("[" + clazz + "] have no public or ConstructorParameters-Annotation constructor.");
|
||||
}
|
||||
try {
|
||||
if (resultClazz == null) {
|
||||
@@ -564,7 +564,7 @@ public interface Creator<T> {
|
||||
RedkaleClassLoader.putReflectionDeclaredConstructors(resultClazz, newDynName.replace('/', '.'));
|
||||
return (Creator) resultClazz.getDeclaredConstructor().newInstance();
|
||||
} catch (Exception ex) {
|
||||
throw new RuntimeException(ex);
|
||||
throw new RedkaleException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -804,7 +804,7 @@ public interface Creator<T> {
|
||||
RedkaleClassLoader.putDynClass(newDynName.replace('/', '.'), bytes, resultClazz);
|
||||
RedkaleClassLoader.putReflectionDeclaredConstructors(resultClazz, newDynName.replace('/', '.'));
|
||||
return (IntFunction<T[]>) resultClazz.getDeclaredConstructor().newInstance();
|
||||
} catch (Exception ex) {
|
||||
} catch (Throwable ex) {
|
||||
//ex.printStackTrace(); //一般不会发生, native-image在没有预编译情况下会报错
|
||||
return t -> (T[]) Array.newInstance(clazz, t);
|
||||
}
|
||||
|
||||
@@ -59,7 +59,9 @@ public class Environment implements java.io.Serializable {
|
||||
|
||||
public boolean getBooleanProperty(String key, boolean defaultValue) {
|
||||
String val = properties.getProperty(key);
|
||||
if (val == null || val.isEmpty()) return defaultValue;
|
||||
if (val == null || val.isEmpty()) {
|
||||
return defaultValue;
|
||||
}
|
||||
return "true".equalsIgnoreCase(val) || "1".equalsIgnoreCase(val);
|
||||
}
|
||||
|
||||
@@ -69,7 +71,9 @@ public class Environment implements java.io.Serializable {
|
||||
|
||||
public short getShortProperty(String key, short defaultValue) {
|
||||
String val = properties.getProperty(key);
|
||||
if (val == null || val.isEmpty()) return defaultValue;
|
||||
if (val == null || val.isEmpty()) {
|
||||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
return Short.parseShort(val);
|
||||
} catch (Exception e) {
|
||||
@@ -83,7 +87,9 @@ public class Environment implements java.io.Serializable {
|
||||
|
||||
public int getIntProperty(String key, int defaultValue) {
|
||||
String val = properties.getProperty(key);
|
||||
if (val == null || val.isEmpty()) return defaultValue;
|
||||
if (val == null || val.isEmpty()) {
|
||||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
return Integer.parseInt(val);
|
||||
} catch (Exception e) {
|
||||
@@ -91,13 +97,31 @@ public class Environment implements java.io.Serializable {
|
||||
}
|
||||
}
|
||||
|
||||
public float getFloatProperty(String key) {
|
||||
return Float.parseFloat(properties.getProperty(key));
|
||||
}
|
||||
|
||||
public float getFloatProperty(String key, float defaultValue) {
|
||||
String val = properties.getProperty(key);
|
||||
if (val == null || val.isEmpty()) {
|
||||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
return Float.parseFloat(val);
|
||||
} catch (Exception e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
public long getLongProperty(String key) {
|
||||
return Long.parseLong(properties.getProperty(key));
|
||||
}
|
||||
|
||||
public long getLongProperty(String key, long defaultValue) {
|
||||
String val = properties.getProperty(key);
|
||||
if (val == null || val.isEmpty()) return defaultValue;
|
||||
if (val == null || val.isEmpty()) {
|
||||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
return Long.parseLong(val);
|
||||
} catch (Exception e) {
|
||||
@@ -105,6 +129,22 @@ public class Environment implements java.io.Serializable {
|
||||
}
|
||||
}
|
||||
|
||||
public double getDoubleProperty(String key) {
|
||||
return Double.parseDouble(properties.getProperty(key));
|
||||
}
|
||||
|
||||
public double getDoubleProperty(String key, double defaultValue) {
|
||||
String val = properties.getProperty(key);
|
||||
if (val == null || val.isEmpty()) {
|
||||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
return Double.parseDouble(val);
|
||||
} catch (Exception e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return properties.toString();
|
||||
|
||||
@@ -108,7 +108,7 @@ public abstract class Flows {
|
||||
reactorMonoClass0 = Thread.currentThread().getContextClassLoader().loadClass("reactor.core.publisher.Mono");
|
||||
Class<Function<Object, CompletableFuture>> monoFuncClass = null;
|
||||
try {
|
||||
monoFuncClass = (Class) Thread.currentThread().getContextClassLoader().loadClass("org.re" + "dkale.util.AnonymousMonoFutureFunction");
|
||||
monoFuncClass = (Class) Thread.currentThread().getContextClassLoader().loadClass("org.redkale.util.AnonymousMonoFutureFunction");
|
||||
} catch (Throwable t) {
|
||||
}
|
||||
if (monoFuncClass == null) {
|
||||
@@ -117,7 +117,7 @@ public abstract class Flows {
|
||||
public final Class<?> loadClass(String name, byte[] b) {
|
||||
return defineClass(name, b, 0, b.length);
|
||||
}
|
||||
}.loadClass("org.re" + "dkale.util.AnonymousMonoFutureFunction", classBytes);
|
||||
}.loadClass("org.redkale.util.AnonymousMonoFutureFunction", classBytes);
|
||||
RedkaleClassLoader.putDynClass(monoFuncClass.getName(), classBytes, monoFuncClass);
|
||||
}
|
||||
RedkaleClassLoader.putReflectionDeclaredConstructors(monoFuncClass, monoFuncClass.getName());
|
||||
@@ -126,7 +126,7 @@ public abstract class Flows {
|
||||
reactorFluxClass0 = Thread.currentThread().getContextClassLoader().loadClass("reactor.core.publisher.Flux");
|
||||
Class<Function<Object, CompletableFuture>> fluxFuncClass = null;
|
||||
try {
|
||||
fluxFuncClass = (Class) Thread.currentThread().getContextClassLoader().loadClass("org.re" + "dkale.util.AnonymousFluxFutureFunction");
|
||||
fluxFuncClass = (Class) Thread.currentThread().getContextClassLoader().loadClass("org.redkale.util.AnonymousFluxFutureFunction");
|
||||
} catch (Throwable t) {
|
||||
}
|
||||
if (fluxFuncClass == null) {
|
||||
@@ -135,7 +135,7 @@ public abstract class Flows {
|
||||
public final Class<?> loadClass(String name, byte[] b) {
|
||||
return defineClass(name, b, 0, b.length);
|
||||
}
|
||||
}.loadClass("org.re" + "dkale.util.AnonymousFluxFutureFunction", classBytes);
|
||||
}.loadClass("org.redkale.util.AnonymousFluxFutureFunction", classBytes);
|
||||
RedkaleClassLoader.putDynClass(fluxFuncClass.getName(), classBytes, fluxFuncClass);
|
||||
}
|
||||
RedkaleClassLoader.putReflectionDeclaredConstructors(fluxFuncClass, fluxFuncClass.getName());
|
||||
|
||||
@@ -39,7 +39,7 @@ public interface Invoker<OBJECT_TYPE, RETURN_TYPE> {
|
||||
try {
|
||||
method = clazz.getMethod(methodName, paramTypes);
|
||||
} catch (Exception ex) {
|
||||
throw new RuntimeException(ex);
|
||||
throw new RedkaleException(ex);
|
||||
}
|
||||
return create(clazz, method);
|
||||
}
|
||||
@@ -221,7 +221,7 @@ public interface Invoker<OBJECT_TYPE, RETURN_TYPE> {
|
||||
RedkaleClassLoader.putReflectionDeclaredConstructors(resultClazz, newDynName.replace('/', '.'));
|
||||
return (Invoker<C, T>) resultClazz.getDeclaredConstructor().newInstance();
|
||||
} catch (Exception ex) {
|
||||
throw new RuntimeException(ex);
|
||||
throw new RedkaleException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -96,7 +96,7 @@ public class RedkaleClassLoader extends URLClassLoader {
|
||||
try {
|
||||
return new FileInputStream(f);
|
||||
} catch (FileNotFoundException e) { //几乎不会发生
|
||||
throw new RuntimeException(e);
|
||||
throw new RedkaleException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
31
src/main/java/org/redkale/util/RedkaleException.java
Normal file
31
src/main/java/org/redkale/util/RedkaleException.java
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
*
|
||||
*/
|
||||
package org.redkale.util;
|
||||
|
||||
/**
|
||||
* redkale的异常基础类 <br>
|
||||
* <p>
|
||||
* 详情见: https://redkale.org
|
||||
*
|
||||
* @author zhangjx
|
||||
* @since 2.8.0
|
||||
*/
|
||||
public class RedkaleException extends RuntimeException {
|
||||
|
||||
public RedkaleException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public RedkaleException(String s) {
|
||||
super(s);
|
||||
}
|
||||
|
||||
public RedkaleException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public RedkaleException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
}
|
||||
@@ -3,9 +3,9 @@ package org.redkale.util;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.Map;
|
||||
import java.util.function.*;
|
||||
import static org.redkale.asm.Opcodes.*;
|
||||
import org.redkale.asm.*;
|
||||
import static org.redkale.asm.ClassWriter.COMPUTE_FRAMES;
|
||||
import org.redkale.asm.*;
|
||||
import static org.redkale.asm.Opcodes.*;
|
||||
|
||||
/**
|
||||
* JavaBean类对象的拷贝,相同的字段名会被拷贝 <br>
|
||||
@@ -186,7 +186,7 @@ public interface Reproduce<D, S> extends BiFunction<D, S, D> {
|
||||
try {
|
||||
return (Reproduce) newClazz.getDeclaredConstructor().newInstance();
|
||||
} catch (Exception ex) {
|
||||
throw new RuntimeException(ex);
|
||||
throw new RedkaleException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -542,7 +542,7 @@ public final class ResourceFactory {
|
||||
checkResourceName(name);
|
||||
Class clz = TypeToken.typeToClass(clazz);
|
||||
if (clz != null && !clz.isPrimitive() && val != null && !clz.isAssignableFrom(val.getClass())) {
|
||||
throw new RuntimeException(clz + "not isAssignableFrom (" + val + ") class " + val.getClass());
|
||||
throw new RedkaleException(clz + "not isAssignableFrom (" + val + ") class " + val.getClass());
|
||||
}
|
||||
ConcurrentHashMap<String, ResourceEntry> map = this.store.computeIfAbsent(clazz, k -> new ConcurrentHashMap());
|
||||
ResourceEntry re = map.get(name);
|
||||
@@ -1023,7 +1023,7 @@ public final class ResourceFactory {
|
||||
return it == null ? findRegxTypeLoader(ft, field) : it;
|
||||
}
|
||||
|
||||
private static class ResourceInjectException extends RuntimeException {
|
||||
private static class ResourceInjectException extends RedkaleException {
|
||||
|
||||
public ResourceInjectException() {
|
||||
super();
|
||||
@@ -1273,7 +1273,7 @@ public final class ResourceFactory {
|
||||
// } catch (RuntimeException ex) {
|
||||
// throw ex;
|
||||
// } catch (Exception e) {
|
||||
// throw new RuntimeException(e);
|
||||
// throw new RedkaleException(e);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
@@ -9,9 +9,9 @@ package org.redkale.util;
|
||||
*
|
||||
* @author zhangjx
|
||||
*/
|
||||
public class RetcodeException extends RuntimeException {
|
||||
public class RetcodeException extends RedkaleException {
|
||||
|
||||
private int retcode;
|
||||
protected int retcode;
|
||||
|
||||
public RetcodeException(int retcode) {
|
||||
this.retcode = retcode;
|
||||
|
||||
@@ -649,7 +649,7 @@ public abstract class TypeToken<T> {
|
||||
try {
|
||||
return newClazz.getField("field").getGenericType();
|
||||
} catch (Exception ex) {
|
||||
throw new RuntimeException(ex);
|
||||
throw new RedkaleException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -189,7 +189,7 @@ public final class Utility {
|
||||
// }
|
||||
// }}, null);
|
||||
// } catch (Exception e) {
|
||||
// throw new RuntimeException(e); //不会发生
|
||||
// throw new RedkaleException(e); //不会发生
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -2850,7 +2850,7 @@ public final class Utility {
|
||||
try {
|
||||
md5 = MessageDigest.getInstance("MD5");
|
||||
} catch (NoSuchAlgorithmException ex) {
|
||||
throw new RuntimeException("Couldn't find a MD5 provider", ex);
|
||||
throw new RedkaleException("Couldn't find a MD5 provider", ex);
|
||||
}
|
||||
return md5.digest(str.getBytes(StandardCharsets.UTF_8));
|
||||
}
|
||||
@@ -2870,7 +2870,7 @@ public final class Utility {
|
||||
try {
|
||||
md5 = MessageDigest.getInstance("MD5");
|
||||
} catch (NoSuchAlgorithmException ex) {
|
||||
throw new RuntimeException("Couldn't find a MD5 provider", ex);
|
||||
throw new RedkaleException("Couldn't find a MD5 provider", ex);
|
||||
}
|
||||
return md5.digest(input);
|
||||
}
|
||||
@@ -2894,7 +2894,7 @@ public final class Utility {
|
||||
md5.update(input, offset, len);
|
||||
return md5.digest();
|
||||
} catch (NoSuchAlgorithmException ex) {
|
||||
throw new RuntimeException("Couldn't find a MD5 provider", ex);
|
||||
throw new RedkaleException("Couldn't find a MD5 provider", ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2972,7 +2972,7 @@ public final class Utility {
|
||||
try {
|
||||
digester = MessageDigest.getInstance("SHA-256");
|
||||
} catch (NoSuchAlgorithmException ex) {
|
||||
throw new RuntimeException("Couldn't find a SHA-256 provider", ex);
|
||||
throw new RedkaleException("Couldn't find a SHA-256 provider", ex);
|
||||
}
|
||||
return digester.digest(str.getBytes(StandardCharsets.UTF_8));
|
||||
}
|
||||
@@ -2992,7 +2992,7 @@ public final class Utility {
|
||||
try {
|
||||
digester = MessageDigest.getInstance("SHA-256");
|
||||
} catch (NoSuchAlgorithmException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
throw new RedkaleException(ex);
|
||||
}
|
||||
return digester.digest(input);
|
||||
}
|
||||
@@ -3016,7 +3016,7 @@ public final class Utility {
|
||||
digester.update(input, offset, len);
|
||||
return digester.digest();
|
||||
} catch (Exception ex) {
|
||||
throw new RuntimeException(ex);
|
||||
throw new RedkaleException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3127,7 +3127,7 @@ public final class Utility {
|
||||
mac.init(new SecretKeySpec(key, "HmacSHA1"));
|
||||
return mac.doFinal(input);
|
||||
} catch (InvalidKeyException | NoSuchAlgorithmException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
throw new RedkaleException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3151,7 +3151,7 @@ public final class Utility {
|
||||
mac.update(input, offset, len);
|
||||
return mac.doFinal();
|
||||
} catch (InvalidKeyException | NoSuchAlgorithmException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
throw new RedkaleException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3262,7 +3262,7 @@ public final class Utility {
|
||||
mac.init(new SecretKeySpec(key, "HmacSHA256"));
|
||||
return mac.doFinal(input);
|
||||
} catch (InvalidKeyException | NoSuchAlgorithmException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
throw new RedkaleException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3286,7 +3286,7 @@ public final class Utility {
|
||||
mac.update(input, offset, len);
|
||||
return mac.doFinal();
|
||||
} catch (InvalidKeyException | NoSuchAlgorithmException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
throw new RedkaleException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3398,7 +3398,7 @@ public final class Utility {
|
||||
mac.init(sk);
|
||||
return mac.doFinal(input);
|
||||
} catch (InvalidKeyException | NoSuchAlgorithmException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
throw new RedkaleException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3423,7 +3423,7 @@ public final class Utility {
|
||||
mac.update(input, offset, len);
|
||||
return mac.doFinal();
|
||||
} catch (InvalidKeyException | NoSuchAlgorithmException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
throw new RedkaleException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3440,7 +3440,7 @@ public final class Utility {
|
||||
MessageDigest digest = MessageDigest.getInstance(algorithm.toUpperCase());
|
||||
return digest.digest(input);
|
||||
} catch (NoSuchAlgorithmException ex) {
|
||||
throw new RuntimeException("Couldn't find a " + algorithm + " provider", ex);
|
||||
throw new RedkaleException("Couldn't find a " + algorithm + " provider", ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3460,7 +3460,7 @@ public final class Utility {
|
||||
digest.update(input, offset, length);
|
||||
return digest.digest();
|
||||
} catch (NoSuchAlgorithmException ex) {
|
||||
throw new RuntimeException("Couldn't find a " + algorithm + " provider", ex);
|
||||
throw new RedkaleException("Couldn't find a " + algorithm + " provider", ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user