注释优化
This commit is contained in:
@@ -360,6 +360,7 @@ public class Type {
|
||||
break;
|
||||
} else if (car == 'L') {
|
||||
while (buf[off++] != ';') {
|
||||
//do nothing
|
||||
}
|
||||
++size;
|
||||
} else if (car != '[') {
|
||||
@@ -413,6 +414,7 @@ public class Type {
|
||||
return getType(buf, off);
|
||||
} else if (car == 'L') {
|
||||
while (buf[off++] != ';') {
|
||||
//do nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -453,6 +455,7 @@ public class Type {
|
||||
| (car == 'V' ? 0 : (car == 'D' || car == 'J' ? 2 : 1));
|
||||
} else if (car == 'L') {
|
||||
while (desc.charAt(c++) != ';') {
|
||||
//do nothing
|
||||
}
|
||||
n += 1;
|
||||
} else if (car == '[') {
|
||||
|
||||
@@ -687,6 +687,7 @@ public final class ApiDocCommand {
|
||||
Type valType = pt.getActualTypeArguments()[0];
|
||||
return formatExample(factory, example, valType instanceof ParameterizedType ? (Class) ((ParameterizedType) valType).getRawType() : ((Class) valType), valType);
|
||||
} catch (Throwable t) {
|
||||
//do nothing
|
||||
}
|
||||
}
|
||||
} else if (Sheet.class.isAssignableFrom(type)) { //要在Collection前面
|
||||
@@ -698,6 +699,7 @@ public final class ApiDocCommand {
|
||||
Object val = formatExample(factory, example, valClass, valType);
|
||||
return new StringWrapper(jsonFactory.getConvert().convertTo(jsonFactory.getConvert().convertFrom(genericType, "{'rows':[" + val + "," + val + "]}")));
|
||||
} catch (Throwable t) {
|
||||
//do nothing
|
||||
}
|
||||
}
|
||||
} else if (type.isArray()) {
|
||||
@@ -705,6 +707,7 @@ public final class ApiDocCommand {
|
||||
Object val = formatExample(factory, example, type.getComponentType(), type.getComponentType());
|
||||
return new StringWrapper(jsonFactory.getConvert().convertTo(jsonFactory.getConvert().convertFrom(genericType, "[" + val + "," + val + "]")));
|
||||
} catch (Throwable t) {
|
||||
//do nothing
|
||||
}
|
||||
} else if (Collection.class.isAssignableFrom(type)) {
|
||||
if (genericType instanceof ParameterizedType) {
|
||||
@@ -715,6 +718,7 @@ public final class ApiDocCommand {
|
||||
Object val = formatExample(factory, example, valClass, valType);
|
||||
return new StringWrapper(jsonFactory.getConvert().convertTo(jsonFactory.getConvert().convertFrom(genericType, "[" + val + "," + val + "]")));
|
||||
} catch (Throwable t) {
|
||||
//do nothing
|
||||
}
|
||||
}
|
||||
} else if (type == RetResult.class) {
|
||||
@@ -726,6 +730,7 @@ public final class ApiDocCommand {
|
||||
Object val = formatExample(factory, example, valClass, valType);
|
||||
return new StringWrapper(jsonFactory.getConvert().convertTo(jsonFactory.getConvert().convertFrom(genericType, "{'result':" + val + "}")));
|
||||
} catch (Throwable t) {
|
||||
//do nothing
|
||||
}
|
||||
}
|
||||
} else if (type != void.class) {
|
||||
@@ -752,6 +757,7 @@ public final class ApiDocCommand {
|
||||
Creator creator = Creator.create(type);
|
||||
return new StringWrapper(jsonFactory.getConvert().convertTo(creator.create()));
|
||||
} catch (Throwable t) {
|
||||
//do nothing
|
||||
}
|
||||
}
|
||||
return example;
|
||||
|
||||
@@ -375,6 +375,7 @@ public final class Application {
|
||||
in.close();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
//do nothing
|
||||
}
|
||||
}
|
||||
if (cacheClasses == null) {
|
||||
|
||||
@@ -131,6 +131,7 @@ public abstract class LoggingBaseHandler extends Handler {
|
||||
ps.println(handlerName + ".formatter = " + LoggingFormater.class.getName());
|
||||
LogManager.getLogManager().readConfiguration(new ByteArrayInputStream(out.toByteArray()));
|
||||
} catch (Exception e) {
|
||||
//do nothing
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -57,6 +57,7 @@ public class LoggingFileHandler extends LoggingBaseHandler {
|
||||
this.denyRegx = Pattern.compile(denyregxstr);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
//do nothing
|
||||
}
|
||||
}
|
||||
|
||||
@@ -267,6 +268,7 @@ public class LoggingFileHandler extends LoggingBaseHandler {
|
||||
this.limit = ls;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
//do nothing
|
||||
}
|
||||
String countstr = manager.getProperty(cname + ".count");
|
||||
try {
|
||||
@@ -274,6 +276,7 @@ public class LoggingFileHandler extends LoggingBaseHandler {
|
||||
this.count = Math.max(1, Math.abs(Integer.decode(countstr)));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
//do nothing
|
||||
}
|
||||
String appendstr = manager.getProperty(cname + ".append");
|
||||
try {
|
||||
@@ -281,6 +284,7 @@ public class LoggingFileHandler extends LoggingBaseHandler {
|
||||
this.append = "true".equalsIgnoreCase(appendstr) || "1".equals(appendstr);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
//do nothing
|
||||
}
|
||||
String levelstr = manager.getProperty(cname + ".level");
|
||||
try {
|
||||
@@ -289,6 +293,7 @@ public class LoggingFileHandler extends LoggingBaseHandler {
|
||||
setLevel(l != null ? l : Level.ALL);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
//do nothing
|
||||
}
|
||||
String filterstr = manager.getProperty(cname + ".filter");
|
||||
try {
|
||||
@@ -298,6 +303,7 @@ public class LoggingFileHandler extends LoggingBaseHandler {
|
||||
setFilter((Filter) clz.getDeclaredConstructor().newInstance());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
//do nothing
|
||||
}
|
||||
String formatterstr = manager.getProperty(cname + ".formatter");
|
||||
try {
|
||||
@@ -307,6 +313,7 @@ public class LoggingFileHandler extends LoggingBaseHandler {
|
||||
setFormatter((Formatter) clz.getDeclaredConstructor().newInstance());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
//do nothing
|
||||
}
|
||||
if (getFormatter() == null) {
|
||||
setFormatter(new SimpleFormatter());
|
||||
@@ -318,6 +325,7 @@ public class LoggingFileHandler extends LoggingBaseHandler {
|
||||
setEncoding(encodingstr);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
//do nothing
|
||||
}
|
||||
|
||||
String denyregxstr = manager.getProperty(cname + ".denyregx");
|
||||
@@ -326,6 +334,7 @@ public class LoggingFileHandler extends LoggingBaseHandler {
|
||||
denyregx = Pattern.compile(denyregxstr);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
//do nothing
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -174,6 +174,7 @@ public class LoggingSearchHandler extends LoggingBaseHandler {
|
||||
setLevel(l != null ? l : Level.ALL);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
//do nothing
|
||||
}
|
||||
String filterstr = manager.getProperty(cname + ".filter");
|
||||
try {
|
||||
@@ -183,6 +184,7 @@ public class LoggingSearchHandler extends LoggingBaseHandler {
|
||||
setFilter((Filter) clz.getDeclaredConstructor().newInstance());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
//do nothing
|
||||
}
|
||||
String formatterstr = manager.getProperty(cname + ".formatter");
|
||||
try {
|
||||
@@ -192,6 +194,7 @@ public class LoggingSearchHandler extends LoggingBaseHandler {
|
||||
setFormatter((Formatter) clz.getDeclaredConstructor().newInstance());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
//do nothing
|
||||
}
|
||||
if (getFormatter() == null) {
|
||||
setFormatter(new SimpleFormatter());
|
||||
@@ -203,6 +206,7 @@ public class LoggingSearchHandler extends LoggingBaseHandler {
|
||||
setEncoding(encodingstr);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
//do nothing
|
||||
}
|
||||
|
||||
String denyregxstr = manager.getProperty(cname + ".denyregx");
|
||||
@@ -211,6 +215,7 @@ public class LoggingSearchHandler extends LoggingBaseHandler {
|
||||
denyRegx = Pattern.compile(denyregxstr);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
//do nothing
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -131,6 +131,7 @@ public class PrepareCompiler {
|
||||
try {
|
||||
FilterNodeBean.load(clz);
|
||||
} catch (Exception e) {
|
||||
//do nothing
|
||||
}
|
||||
}
|
||||
for (ApplicationListener listener : application.listeners) {
|
||||
|
||||
@@ -213,6 +213,7 @@ public abstract class ClusterAgent {
|
||||
try {
|
||||
Thread.sleep(s * 1000);
|
||||
} catch (InterruptedException ex) {
|
||||
//do nothing
|
||||
}
|
||||
logger.info(this.getClass().getSimpleName() + " wait for " + s * 1000 + "ms after deregister");
|
||||
}
|
||||
|
||||
@@ -200,6 +200,7 @@ public abstract class ConvertFactory<R extends Reader, W extends Writer> {
|
||||
|
||||
});
|
||||
} catch (Throwable t) {
|
||||
//do nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -707,6 +708,7 @@ public abstract class ConvertFactory<R extends Reader, W extends Writer> {
|
||||
encoder = (Encodeable) instanceField.get(null);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
//do nothing
|
||||
}
|
||||
if (encoder == null) {
|
||||
Creator<? extends Encodeable> creator = Creator.create(enClazz);
|
||||
@@ -774,6 +776,7 @@ public abstract class ConvertFactory<R extends Reader, W extends Writer> {
|
||||
decoder = (Decodeable) instanceField.get(null);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
//do nothing
|
||||
}
|
||||
if (decoder == null) {
|
||||
Creator<? extends Decodeable> creator = Creator.create(deClazz);
|
||||
@@ -947,6 +950,7 @@ public abstract class ConvertFactory<R extends Reader, W extends Writer> {
|
||||
try {
|
||||
field = type.getDeclaredField(column);
|
||||
} catch (Exception e) {
|
||||
//do nothing
|
||||
}
|
||||
String get = "get";
|
||||
if (field != null && (field.getType() == boolean.class || field.getType() == Boolean.class)) {
|
||||
@@ -962,13 +966,16 @@ public abstract class ConvertFactory<R extends Reader, W extends Writer> {
|
||||
try {
|
||||
register(type.getMethod("is" + bigColumn), entry);
|
||||
} catch (Exception ex) {
|
||||
//do nothing
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
//do nothing
|
||||
}
|
||||
try {
|
||||
register(type.getMethod("set" + bigColumn, field.getType()), entry);
|
||||
} catch (Exception ex) {
|
||||
//do nothing
|
||||
}
|
||||
return field == null ? true : register(field, entry);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
*/
|
||||
package org.redkale.convert;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.Type;
|
||||
import org.redkale.convert.json.JsonConvert;
|
||||
|
||||
@@ -17,7 +16,7 @@ import org.redkale.convert.json.JsonConvert;
|
||||
*
|
||||
* @author zhangjx
|
||||
*/
|
||||
public class ConvertField implements Serializable {
|
||||
public class ConvertField {
|
||||
|
||||
protected String name;
|
||||
|
||||
|
||||
@@ -105,6 +105,7 @@ public class MapDecoder<K, V> implements Decodeable<Reader, Map<K, V>> {
|
||||
try {
|
||||
condition.await();
|
||||
} catch (Exception e) {
|
||||
//do nothing
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
|
||||
@@ -83,6 +83,7 @@ public class MapEncoder<K, V> implements Encodeable<Writer, Map<K, V>> {
|
||||
try {
|
||||
condition.await();
|
||||
} catch (Exception e) {
|
||||
//do nothing
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
|
||||
@@ -407,6 +407,7 @@ public class ObjectEncoder<W extends Writer, T> implements Encodeable<W, T> {
|
||||
try {
|
||||
ref = factory.findRef(clazz, clazz.getDeclaredField(mfieldname));
|
||||
} catch (Exception e) {
|
||||
//do nothing
|
||||
}
|
||||
}
|
||||
fieldalias = ref == null || ref.name().isEmpty() ? mfieldname : ref.name();
|
||||
@@ -417,6 +418,7 @@ public class ObjectEncoder<W extends Writer, T> implements Encodeable<W, T> {
|
||||
try {
|
||||
ref = factory.findRef(clazz, clazz.getDeclaredField(mfieldname));
|
||||
} catch (Exception e) {
|
||||
//do nothing
|
||||
}
|
||||
}
|
||||
fieldalias = ref == null || ref.name().isEmpty() ? mfieldname : ref.name();
|
||||
|
||||
@@ -85,6 +85,7 @@ public class OptionalCoder<R extends Reader, W extends Writer, T> extends Simple
|
||||
try {
|
||||
condition.await();
|
||||
} catch (Exception e) {
|
||||
//do nothing
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
@@ -101,6 +102,7 @@ public class OptionalCoder<R extends Reader, W extends Writer, T> extends Simple
|
||||
try {
|
||||
condition.await();
|
||||
} catch (Exception e) {
|
||||
//do nothing
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
|
||||
@@ -66,7 +66,9 @@ public class StreamDecoder<T> implements Decodeable<Reader, Stream<T>> {
|
||||
byte[] typevals = new byte[1];
|
||||
int len = in.readArrayB(member, typevals, this.componentDecoder);
|
||||
int contentLength = -1;
|
||||
if (len == Reader.SIGN_NULL) return null;
|
||||
if (len == Reader.SIGN_NULL) {
|
||||
return null;
|
||||
}
|
||||
if (len == Reader.SIGN_NOLENBUTBYTES) {
|
||||
contentLength = in.readMemberContentLength(member, this.componentDecoder);
|
||||
len = Reader.SIGN_NOLENGTH;
|
||||
@@ -77,6 +79,7 @@ public class StreamDecoder<T> implements Decodeable<Reader, Stream<T>> {
|
||||
try {
|
||||
condition.await();
|
||||
} catch (Exception e) {
|
||||
//do nothing
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
@@ -89,7 +92,9 @@ public class StreamDecoder<T> implements Decodeable<Reader, Stream<T>> {
|
||||
int startPosition = in.position();
|
||||
while (hasNext(in, member, startPosition, contentLength, first)) {
|
||||
Reader itemReader = getItemReader(in, member, first);
|
||||
if (itemReader == null) break;
|
||||
if (itemReader == null) {
|
||||
break;
|
||||
}
|
||||
result.add(readMemberValue(itemReader, member, localdecoder, first));
|
||||
first = false;
|
||||
}
|
||||
|
||||
@@ -78,6 +78,7 @@ public class StreamEncoder<T> implements Encodeable<Writer, Stream<T>> {
|
||||
try {
|
||||
condition.await();
|
||||
} catch (Exception e) {
|
||||
//do nothing
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ import org.redkale.util.*;
|
||||
*/
|
||||
public class BsonWriter extends Writer implements ByteTuple {
|
||||
|
||||
private static final int defaultSize = Integer.getInteger("redkale.convert.bson.writer.buffer.defsize", Integer.getInteger("redkale.convert.writer.buffer.defsize", 1024));
|
||||
private static final int DEFAULT_SIZE = Integer.getInteger("redkale.convert.bson.writer.buffer.defsize", Integer.getInteger("redkale.convert.writer.buffer.defsize", 1024));
|
||||
|
||||
private byte[] content;
|
||||
|
||||
@@ -81,7 +81,7 @@ public class BsonWriter extends Writer implements ByteTuple {
|
||||
}
|
||||
|
||||
public BsonWriter() {
|
||||
this(defaultSize);
|
||||
this(DEFAULT_SIZE);
|
||||
this.features = BsonFactory.root().getFeatures();
|
||||
}
|
||||
|
||||
@@ -144,8 +144,8 @@ public class BsonWriter extends Writer implements ByteTuple {
|
||||
super.recycle();
|
||||
this.count = 0;
|
||||
this.specificObjectType = null;
|
||||
if (this.content != null && this.content.length > defaultSize) {
|
||||
this.content = new byte[defaultSize];
|
||||
if (this.content != null && this.content.length > DEFAULT_SIZE) {
|
||||
this.content = new byte[DEFAULT_SIZE];
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -135,6 +135,7 @@ public class JsonByteBufferReader extends JsonReader {
|
||||
try {
|
||||
while ((one = nextChar()) != 0) sb.append(one);
|
||||
} catch (Exception e) {
|
||||
//do nothing
|
||||
}
|
||||
throw new ConvertException("a json object text must begin with '{' (position = " + pos + ") but '" + ch + "' in (" + sb + ")");
|
||||
}
|
||||
@@ -167,6 +168,7 @@ public class JsonByteBufferReader extends JsonReader {
|
||||
try {
|
||||
while ((one = nextChar()) != 0) sb.append(one);
|
||||
} catch (Exception e) {
|
||||
//do nothing
|
||||
}
|
||||
throw new ConvertException("a json array text must begin with '[' (position = " + pos + ") but '" + ch + "' in (" + sb + ")");
|
||||
}
|
||||
@@ -187,6 +189,7 @@ public class JsonByteBufferReader extends JsonReader {
|
||||
try {
|
||||
while ((one = nextChar()) != 0) sb.append(one);
|
||||
} catch (Exception e) {
|
||||
//do nothing
|
||||
}
|
||||
throw new ConvertException("expected a ':' but '" + ch + "'(position = " + pos + ") in (" + sb + ")");
|
||||
}
|
||||
|
||||
@@ -8,8 +8,8 @@ package org.redkale.convert.json;
|
||||
import java.lang.reflect.*;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.*;
|
||||
import static org.redkale.asm.ClassWriter.COMPUTE_FRAMES;
|
||||
import org.redkale.asm.*;
|
||||
import static org.redkale.asm.ClassWriter.COMPUTE_FRAMES;
|
||||
import static org.redkale.asm.Opcodes.*;
|
||||
import org.redkale.convert.*;
|
||||
import org.redkale.convert.ext.*;
|
||||
@@ -315,6 +315,7 @@ public abstract class JsonDynEncoder<T> implements Encodeable<JsonWriter, T> {
|
||||
small = f.getAnnotation(ConvertSmallString.class);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
//do nothing
|
||||
}
|
||||
}
|
||||
return small;
|
||||
@@ -403,6 +404,7 @@ public abstract class JsonDynEncoder<T> implements Encodeable<JsonWriter, T> {
|
||||
}
|
||||
return resultEncoder;
|
||||
} catch (Throwable ex) {
|
||||
//do nothing
|
||||
}
|
||||
// ------------------------------------------------------------------------------
|
||||
ClassWriter cw = new ClassWriter(COMPUTE_FRAMES);
|
||||
|
||||
@@ -20,7 +20,7 @@ import org.redkale.util.*;
|
||||
*/
|
||||
public class ProtobufWriter extends Writer implements ByteTuple {
|
||||
|
||||
private static final int defaultSize = Integer.getInteger("redkale.convert.protobuf.writer.buffer.defsize", Integer.getInteger("redkale.convert.writer.buffer.defsize", 1024));
|
||||
private static final int DEFAULT_SIZE = Integer.getInteger("redkale.convert.protobuf.writer.buffer.defsize", Integer.getInteger("redkale.convert.writer.buffer.defsize", 1024));
|
||||
|
||||
private byte[] content;
|
||||
|
||||
@@ -68,7 +68,7 @@ public class ProtobufWriter extends Writer implements ByteTuple {
|
||||
}
|
||||
|
||||
public ProtobufWriter() {
|
||||
this(defaultSize);
|
||||
this(DEFAULT_SIZE);
|
||||
}
|
||||
|
||||
public ProtobufWriter(int size) {
|
||||
@@ -85,8 +85,8 @@ public class ProtobufWriter extends Writer implements ByteTuple {
|
||||
super.recycle();
|
||||
this.count = 0;
|
||||
this.initOffset = 0;
|
||||
if (this.content.length > defaultSize) {
|
||||
this.content = new byte[defaultSize];
|
||||
if (this.content.length > DEFAULT_SIZE) {
|
||||
this.content = new byte[DEFAULT_SIZE];
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -195,6 +195,7 @@ public class ProtobufWriter extends Writer implements ByteTuple {
|
||||
|
||||
@Override
|
||||
public void writeNull() {
|
||||
//do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -204,6 +205,7 @@ public class ProtobufWriter extends Writer implements ByteTuple {
|
||||
|
||||
@Override
|
||||
public void writeClassName(String clazz) {
|
||||
//do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -380,10 +382,12 @@ public class ProtobufWriter extends Writer implements ByteTuple {
|
||||
|
||||
@Override
|
||||
public void writeArrayMark() {
|
||||
//do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeArrayE() {
|
||||
//do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -393,10 +397,12 @@ public class ProtobufWriter extends Writer implements ByteTuple {
|
||||
|
||||
@Override
|
||||
public void writeMapMark() {
|
||||
//do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeMapE() {
|
||||
//do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -227,7 +227,6 @@ public abstract class AsyncConnection implements Channel, AutoCloseable {
|
||||
// public abstract <A> AsyncConnection fastHandler(CompletionHandler<Integer, ? super A> handler);
|
||||
//
|
||||
// public abstract <A> void fastWrite(byte[] data);
|
||||
|
||||
protected abstract void readRegisterImpl(CompletionHandler<Integer, ByteBuffer> handler);
|
||||
|
||||
protected abstract void readImpl(CompletionHandler<Integer, ByteBuffer> handler);
|
||||
@@ -804,6 +803,7 @@ public abstract class AsyncConnection implements Channel, AutoCloseable {
|
||||
try {
|
||||
this.close();
|
||||
} catch (IOException io) {
|
||||
//do nothing
|
||||
}
|
||||
}
|
||||
|
||||
@@ -827,6 +827,7 @@ public abstract class AsyncConnection implements Channel, AutoCloseable {
|
||||
sslEngine.closeInbound();
|
||||
sslEngine.closeOutbound();
|
||||
} catch (SSLException e) {
|
||||
//do nothing
|
||||
}
|
||||
sslEngine = null;
|
||||
}
|
||||
@@ -834,6 +835,7 @@ public abstract class AsyncConnection implements Channel, AutoCloseable {
|
||||
try {
|
||||
beforeCloseListener.accept(this);
|
||||
} catch (Exception io) {
|
||||
//do nothing
|
||||
}
|
||||
}
|
||||
if (this.readBuffer != null && Thread.currentThread() == this.ioReadThread) {
|
||||
@@ -853,6 +855,7 @@ public abstract class AsyncConnection implements Channel, AutoCloseable {
|
||||
}
|
||||
attributes.clear();
|
||||
} catch (Exception io) {
|
||||
//do nothing
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -165,7 +165,7 @@ public abstract class Request<C extends Context> {
|
||||
@Deprecated(since = "2.7.0") //replace by getCreateTime()
|
||||
@ConvertDisabled
|
||||
public long getCreatetime() {
|
||||
return createTime;
|
||||
return getCreateTime();
|
||||
}
|
||||
|
||||
public long getCreateTime() {
|
||||
|
||||
@@ -458,6 +458,7 @@ public abstract class Server<K extends Serializable, C extends Context, R extend
|
||||
try {
|
||||
this.serverChannel.close();
|
||||
} catch (Exception e) {
|
||||
//do nothing
|
||||
}
|
||||
logger.info(this.getClass().getSimpleName() + "-" + this.netprotocol + " shutdow prepare servlet");
|
||||
this.dispatcher.destroy(this.context, config);
|
||||
|
||||
@@ -169,6 +169,7 @@ public abstract class Client<C extends ClientConnection<R, P>, R extends ClientR
|
||||
conn.writeChannel(req).thenAccept(p -> handlePingResult((C) conn, p));
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
//do nothing
|
||||
}
|
||||
}, pingIntervalSeconds(), pingIntervalSeconds(), TimeUnit.SECONDS);
|
||||
}
|
||||
@@ -213,6 +214,7 @@ public abstract class Client<C extends ClientConnection<R, P>, R extends ClientR
|
||||
try {
|
||||
conn.writeChannel(closeReq).get(1, TimeUnit.SECONDS);
|
||||
} catch (Exception e) {
|
||||
//do nothing
|
||||
}
|
||||
conn.dispose(null);
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@ import org.redkale.annotation.ConstructorParameters;
|
||||
import org.redkale.asm.*;
|
||||
import static org.redkale.asm.Opcodes.*;
|
||||
import org.redkale.net.*;
|
||||
import org.redkale.net.Context;
|
||||
import org.redkale.net.Context.ContextConfig;
|
||||
import org.redkale.util.*;
|
||||
|
||||
@@ -117,6 +116,7 @@ public class HttpContext extends Context {
|
||||
Class newHandlerClazz = clz == null ? Thread.currentThread().getContextClassLoader().loadClass(newDynName.replace('/', '.')) : clz;
|
||||
return Creator.create(newHandlerClazz);
|
||||
} catch (Throwable ex) {
|
||||
//do nothing
|
||||
}
|
||||
// ------------------------------------------------------------------------------
|
||||
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES);
|
||||
|
||||
@@ -6,11 +6,10 @@
|
||||
package org.redkale.net.http;
|
||||
|
||||
import java.io.*;
|
||||
import static java.nio.file.StandardWatchEventKinds.*;
|
||||
import java.nio.file.*;
|
||||
import static java.nio.file.StandardWatchEventKinds.*;
|
||||
import java.util.AbstractMap.SimpleEntry;
|
||||
import java.util.*;
|
||||
import java.util.AbstractMap.SimpleEntry;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.atomic.LongAdder;
|
||||
import java.util.logging.*;
|
||||
@@ -84,6 +83,7 @@ public class HttpResourceServlet extends HttpServlet {
|
||||
key.reset();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
//do nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,9 +59,9 @@ public class HttpResponse extends Response<HttpContext, HttpRequest> {
|
||||
|
||||
protected static final byte[] connectAliveBytes = "none".equalsIgnoreCase(System.getProperty("redkale.http.response.header.connection")) ? new byte[0] : "Connection: keep-alive\r\n".getBytes();
|
||||
|
||||
protected static final String contentTypeHtmlUTF8 = "text/html; charset=utf-8";
|
||||
protected static final String CONTENT_TYPE_HTML_UTF8 = "text/html; charset=utf-8";
|
||||
|
||||
private static final int cacheMaxContentLength = 1000;
|
||||
private static final int CACHE_MAX_CONTENT_LENGTH = 1000;
|
||||
|
||||
private static final byte[] status200_server_live_Bytes = append(append(status200Bytes, serverNameBytes), connectAliveBytes);
|
||||
|
||||
@@ -71,7 +71,7 @@ public class HttpResponse extends Response<HttpContext, HttpRequest> {
|
||||
|
||||
private static final Map<Integer, String> httpCodes = new HashMap<>();
|
||||
|
||||
private static final byte[][] contentLengthArray = new byte[cacheMaxContentLength][];
|
||||
private static final byte[][] contentLengthArray = new byte[CACHE_MAX_CONTENT_LENGTH][];
|
||||
|
||||
private static final JsonConvert jsonRootConvert = JsonConvert.root();
|
||||
|
||||
@@ -122,7 +122,7 @@ public class HttpResponse extends Response<HttpContext, HttpRequest> {
|
||||
httpCodes.put(504, "Gateway Timeout");
|
||||
httpCodes.put(505, "HTTP Version Not Supported");
|
||||
|
||||
for (int i = 0; i < cacheMaxContentLength; i++) {
|
||||
for (int i = 0; i < CACHE_MAX_CONTENT_LENGTH; i++) {
|
||||
contentLengthArray[i] = ("Content-Length: " + i + "\r\n").getBytes();
|
||||
}
|
||||
}
|
||||
@@ -729,7 +729,7 @@ public class HttpResponse extends Response<HttpContext, HttpRequest> {
|
||||
return;
|
||||
}
|
||||
if (httpRender != null) {
|
||||
setContentType(contentTypeHtmlUTF8);
|
||||
setContentType(CONTENT_TYPE_HTML_UTF8);
|
||||
if (result.getHeaders() != null) {
|
||||
addHeader(result.getHeaders());
|
||||
}
|
||||
@@ -1301,6 +1301,7 @@ public class HttpResponse extends Response<HttpContext, HttpRequest> {
|
||||
try {
|
||||
fileChannel.close();
|
||||
} catch (IOException ie) {
|
||||
//do nothing
|
||||
}
|
||||
completeFinishBytes(result, attachment);
|
||||
return;
|
||||
@@ -1333,6 +1334,7 @@ public class HttpResponse extends Response<HttpContext, HttpRequest> {
|
||||
try {
|
||||
fileChannel.close();
|
||||
} catch (IOException ie) {
|
||||
//do nothing
|
||||
}
|
||||
}
|
||||
failed(e, attachment);
|
||||
@@ -1638,13 +1640,13 @@ public class HttpResponse extends Response<HttpContext, HttpRequest> {
|
||||
|
||||
public AnyValue renderConfig;
|
||||
|
||||
public final byte[][] plainLiveContentLengthArray = new byte[cacheMaxContentLength][];
|
||||
public final byte[][] plainLiveContentLengthArray = new byte[CACHE_MAX_CONTENT_LENGTH][];
|
||||
|
||||
public final byte[][] jsonLiveContentLengthArray = new byte[cacheMaxContentLength][];
|
||||
public final byte[][] jsonLiveContentLengthArray = new byte[CACHE_MAX_CONTENT_LENGTH][];
|
||||
|
||||
public final byte[][] plainCloseContentLengthArray = new byte[cacheMaxContentLength][];
|
||||
public final byte[][] plainCloseContentLengthArray = new byte[CACHE_MAX_CONTENT_LENGTH][];
|
||||
|
||||
public final byte[][] jsonCloseContentLengthArray = new byte[cacheMaxContentLength][];
|
||||
public final byte[][] jsonCloseContentLengthArray = new byte[CACHE_MAX_CONTENT_LENGTH][];
|
||||
|
||||
public HttpResponseConfig init(AnyValue config) {
|
||||
if (this.plainContentTypeBytes == null) {
|
||||
@@ -1654,7 +1656,7 @@ public class HttpResponse extends Response<HttpContext, HttpRequest> {
|
||||
this.jsonContentType = jsonct;
|
||||
this.plainContentTypeBytes = ("Content-Type: " + plainct + "\r\n").getBytes();
|
||||
this.jsonContentTypeBytes = ("Content-Type: " + jsonct + "\r\n").getBytes();
|
||||
for (int i = 0; i < cacheMaxContentLength; i++) {
|
||||
for (int i = 0; i < CACHE_MAX_CONTENT_LENGTH; i++) {
|
||||
byte[] lenbytes = ("Content-Length: " + i + "\r\n").getBytes();
|
||||
plainLiveContentLengthArray[i] = append(append(status200_server_live_Bytes, plainContentTypeBytes), lenbytes);
|
||||
plainCloseContentLengthArray[i] = append(append(status200_server_close_Bytes, plainContentTypeBytes), lenbytes);
|
||||
|
||||
@@ -512,6 +512,7 @@ public class HttpServlet extends Servlet<HttpContext, HttpRequest, HttpResponse>
|
||||
instance.getClass().getField("_factServlet").set(instance, this);
|
||||
return instance;
|
||||
} catch (Throwable ex) {
|
||||
//do nothing
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
ClassWriter cw = new ClassWriter(COMPUTE_FRAMES);
|
||||
|
||||
@@ -111,7 +111,7 @@ public final class MultiPart {
|
||||
*/
|
||||
@Deprecated(since = "2.8.0")
|
||||
public String getFilename() {
|
||||
return fileName;
|
||||
return getFileName();
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
|
||||
@@ -427,6 +427,7 @@ public final class Rest {
|
||||
}
|
||||
namePresent = m0 == null ? true : m0.getParameters()[0].isNamePresent();
|
||||
} catch (Exception e) {
|
||||
//do nothing
|
||||
}
|
||||
final Map<String, List<String>> asmParamMap = namePresent ? null : MethodParamClassVisitor.getMethodParamNames(new HashMap<>(), webSocketType);
|
||||
final Set<String> messageNames = new HashSet<>();
|
||||
@@ -518,6 +519,7 @@ public final class Rest {
|
||||
}
|
||||
return servlet;
|
||||
} catch (Throwable e) {
|
||||
//do nothing
|
||||
}
|
||||
|
||||
final List<Field> resourcesFields = new ArrayList<>(resourcesFieldSet);
|
||||
@@ -1390,8 +1392,11 @@ public final class Rest {
|
||||
} else if (pname != null && pname.charAt(0) == '#') { //从request.getRequstURIPath 中去参数
|
||||
} else if ("&".equals(pname) && ptype == userType) { //当前用户对象的类名
|
||||
} else if (ptype.isPrimitive()) {
|
||||
//do nothing
|
||||
} else if (ptype == String.class) {
|
||||
//do nothing
|
||||
} else if (ptype == Flipper.class) {
|
||||
//do nothing
|
||||
} else { //其他Json对象
|
||||
//构建 RestHeader、RestCookie、RestAddress 等赋值操作
|
||||
Class loop = ptype;
|
||||
@@ -1476,20 +1481,31 @@ public final class Rest {
|
||||
if (en.getKey().contains("_header_")) {
|
||||
String headerkey = en.getValue()[0].toString();
|
||||
if ("Host".equalsIgnoreCase(headerkey)) {
|
||||
//do nothing
|
||||
} else if ("Content-Type".equalsIgnoreCase(headerkey)) {
|
||||
//do nothing
|
||||
} else if ("Connection".equalsIgnoreCase(headerkey)) {
|
||||
//do nothing
|
||||
} else if ("Method".equalsIgnoreCase(headerkey)) {
|
||||
//do nothing
|
||||
} else if (en.getKey().contains("_header_json_")) {
|
||||
String typefieldname = "_redkale_body_jsontype_" + bodyTypes.size();
|
||||
bodyTypes.put(typefieldname, (java.lang.reflect.Type) en.getValue()[2]);
|
||||
}
|
||||
} else if (en.getKey().contains("_cookie_")) {
|
||||
//do nothing
|
||||
} else if (en.getKey().contains("_sessionid_")) {
|
||||
//do nothing
|
||||
} else if (en.getKey().contains("_address_")) {
|
||||
//do nothing
|
||||
} else if (en.getKey().contains("_locale_")) {
|
||||
//do nothing
|
||||
} else if (en.getKey().contains("_uri_")) {
|
||||
//do nothing
|
||||
} else if (en.getKey().contains("_bodystring_")) {
|
||||
//do nothing
|
||||
} else if (en.getKey().contains("_bodybytes_")) {
|
||||
//do nothing
|
||||
} else if (en.getKey().contains("_bodyjson_")) {//JavaBean 转 Json
|
||||
String typefieldname = "_redkale_body_jsontype_" + bodyTypes.size();
|
||||
bodyTypes.put(typefieldname, (java.lang.reflect.Type) en.getValue()[2]);
|
||||
@@ -1870,6 +1886,7 @@ public final class Rest {
|
||||
}
|
||||
namePresent = m0 == null ? true : m0.getParameters()[0].isNamePresent();
|
||||
} catch (Exception e) {
|
||||
//do nothing
|
||||
}
|
||||
final Map<String, List<String>> asmParamMap = namePresent ? null : MethodParamClassVisitor.getMethodParamNames(new HashMap<>(), serviceType);
|
||||
|
||||
|
||||
@@ -100,18 +100,18 @@ public class WebSocketEngine {
|
||||
if (conf != null && conf.getAnyValue("properties") != null) {
|
||||
props = conf.getAnyValue("properties");
|
||||
}
|
||||
this.liveInterval = props == null ? (liveInterval < 0 ? DEFAILT_LIVEINTERVAL : liveInterval) : props.getIntValue(WEBPARAM__LIVEINTERVAL, (liveInterval < 0 ? DEFAILT_LIVEINTERVAL : liveInterval));
|
||||
this.liveInterval = props == null ? (liveInterval < 0 ? DEFAILT_LIVEINTERVAL : liveInterval) : props.getIntValue(WEBPARAM_LIVEINTERVAL, (liveInterval < 0 ? DEFAILT_LIVEINTERVAL : liveInterval));
|
||||
if (liveInterval <= 0) {
|
||||
return;
|
||||
}
|
||||
if (props != null) {
|
||||
this.wsMaxConns = props.getIntValue(WEBPARAM__WSMAXCONNS, this.wsMaxConns);
|
||||
this.wsMaxConns = props.getIntValue(WEBPARAM_WSMAXCONNS, this.wsMaxConns);
|
||||
}
|
||||
if (props != null) {
|
||||
this.wsThreads = props.getIntValue(WEBPARAM__WSTHREADS, this.wsThreads);
|
||||
this.wsThreads = props.getIntValue(WEBPARAM_WSTHREADS, this.wsThreads);
|
||||
}
|
||||
if (props != null) {
|
||||
this.wsMaxBody = props.getIntValue(WEBPARAM__WSMAXBODY, this.wsMaxBody);
|
||||
this.wsMaxBody = props.getIntValue(WEBPARAM_WSMAXBODY, this.wsMaxBody);
|
||||
}
|
||||
if (scheduler != null) {
|
||||
return;
|
||||
|
||||
@@ -49,19 +49,19 @@ import org.redkale.util.*;
|
||||
public abstract class WebSocketServlet extends HttpServlet implements Resourcable {
|
||||
|
||||
@Comment("WebScoket服务器给客户端进行ping操作的间隔时间, 单位: 秒")
|
||||
public static final String WEBPARAM__LIVEINTERVAL = "liveinterval";
|
||||
public static final String WEBPARAM_LIVEINTERVAL = "liveinterval";
|
||||
|
||||
@Comment("WebScoket服务器最大连接数,为0表示无限制")
|
||||
public static final String WEBPARAM__WSMAXCONNS = "wsmaxconns";
|
||||
public static final String WEBPARAM_WSMAXCONNS = "wsmaxconns";
|
||||
|
||||
@Comment("WebScoket服务器操作WebSocketNode对应CacheSource并发数, 为-1表示无限制,为0表示系统默认值(CPU*8)")
|
||||
public static final String WEBPARAM__WSTHREADS = "wsthreads";
|
||||
public static final String WEBPARAM_WSTHREADS = "wsthreads";
|
||||
|
||||
@Comment("最大消息体长度, 小于1表示无限制")
|
||||
public static final String WEBPARAM__WSMAXBODY = "wsmaxbody";
|
||||
public static final String WEBPARAM_WSMAXBODY = "wsmaxbody";
|
||||
|
||||
@Comment("加密解密器")
|
||||
public static final String WEBPARAM__CRYPTOR = "cryptor";
|
||||
public static final String WEBPARAM_CRYPTOR = "cryptor";
|
||||
|
||||
@Comment("WebScoket服务器给客户端进行ping操作的默认间隔时间, 单位: 秒")
|
||||
public static final int DEFAILT_LIVEINTERVAL = 15;
|
||||
@@ -173,7 +173,7 @@ public abstract class WebSocketServlet extends HttpServlet implements Resourcabl
|
||||
props = conf.getAnyValue("properties");
|
||||
}
|
||||
if (props != null) {
|
||||
String cryptorClass = props.getValue(WEBPARAM__CRYPTOR);
|
||||
String cryptorClass = props.getValue(WEBPARAM_CRYPTOR);
|
||||
if (cryptorClass != null && !cryptorClass.isEmpty()) {
|
||||
try {
|
||||
Class clazz = Thread.currentThread().getContextClassLoader().loadClass(cryptorClass);
|
||||
|
||||
@@ -95,6 +95,7 @@ public class WebSocketWriteHandler implements CompletionHandler<Integer, Void> {
|
||||
}
|
||||
respList.clear();
|
||||
} catch (Exception e) {
|
||||
//do nothing
|
||||
}
|
||||
webSocket.kill(RETCODE_SENDEXCEPTION, "websocket send message failed on CompletionHandler");
|
||||
if (exc != null && context.getLogger().isLoggable(Level.FINER)) {
|
||||
|
||||
@@ -65,6 +65,59 @@ public abstract class Sncp {
|
||||
Class type(); //serviceType
|
||||
|
||||
int index() default 0; //排列顺序, 主要用于Method
|
||||
|
||||
}
|
||||
|
||||
public static class SchedulingEntry {
|
||||
|
||||
private Class serviceType;
|
||||
|
||||
private String methodName;
|
||||
|
||||
private Scheduled schedule;
|
||||
|
||||
private Runnable task;
|
||||
|
||||
public SchedulingEntry(Class serviceType, String methodName, Scheduled schedule, Runnable task) {
|
||||
Objects.requireNonNull(serviceType);
|
||||
Objects.requireNonNull(methodName);
|
||||
Objects.requireNonNull(schedule);
|
||||
Objects.requireNonNull(task);
|
||||
this.serviceType = serviceType;
|
||||
this.methodName = methodName;
|
||||
this.schedule = schedule;
|
||||
this.task = task;
|
||||
}
|
||||
|
||||
public Class getServiceType() {
|
||||
return serviceType;
|
||||
}
|
||||
|
||||
public String getMethodName() {
|
||||
return methodName;
|
||||
}
|
||||
|
||||
public Scheduled getSchedule() {
|
||||
return schedule;
|
||||
}
|
||||
|
||||
public Runnable getTask() {
|
||||
return task;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getClass().getSimpleName() + "{"
|
||||
+ "serviceType=" + serviceType
|
||||
+ ", methodName=" + methodName
|
||||
+ ", schedule.cron=" + schedule.cron()
|
||||
+ ", schedule.zone=" + schedule.zone()
|
||||
+ ", schedule.fixedDelay=" + schedule.fixedDelay()
|
||||
+ ", schedule.fixedRate=" + schedule.fixedRate()
|
||||
+ ", schedule.initialDelay=" + schedule.initialDelay()
|
||||
+ ", schedule.timeUnit=" + schedule.timeUnit()
|
||||
+ '}';
|
||||
}
|
||||
}
|
||||
|
||||
private Sncp() {
|
||||
@@ -492,6 +545,7 @@ public abstract class Sncp {
|
||||
Class clz = RedkaleClassLoader.findDynClass(newDynName.replace('/', '.'));
|
||||
return (Class<T>) (clz == null ? loader.loadClass(newDynName.replace('/', '.')) : clz);
|
||||
} catch (ClassNotFoundException e) {
|
||||
//do nothing
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
}
|
||||
@@ -562,6 +616,7 @@ public abstract class Sncp {
|
||||
c = newClazz.getDeclaredField(FIELDPREFIX + "_mq");
|
||||
RedkaleClassLoader.putReflectionField(newDynName.replace('/', '.'), c);
|
||||
} catch (Exception e) {
|
||||
//do nothing
|
||||
}
|
||||
return (Class<T>) newClazz;
|
||||
}
|
||||
@@ -771,6 +826,7 @@ public abstract class Sncp {
|
||||
}
|
||||
return service;
|
||||
} catch (Throwable ex) {
|
||||
//do nothing
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
ClassWriter cw = new ClassWriter(COMPUTE_FRAMES);
|
||||
|
||||
@@ -58,6 +58,7 @@ public interface SncpAsyncHandler<V, A> extends CompletionHandler<V, A> {
|
||||
Class newHandlerClazz = clz == null ? Thread.currentThread().getContextClassLoader().loadClass(newDynName.replace('/', '.')) : clz;
|
||||
return (Creator<SncpAsyncHandler>) Creator.create(newHandlerClazz);
|
||||
} catch (Throwable ex) {
|
||||
//do nothing
|
||||
}
|
||||
// ------------------------------------------------------------------------------
|
||||
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES);
|
||||
|
||||
@@ -58,7 +58,7 @@ public class SncpClientResult implements ClientResult {
|
||||
|
||||
@Override
|
||||
public boolean isKeepAlive() {
|
||||
return header == null ? false : header.isKeepAlive();
|
||||
return header != null && header.isKeepAlive();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -236,6 +236,7 @@ public class SncpServlet extends Servlet<SncpContext, SncpRequest, SncpResponse>
|
||||
}
|
||||
}
|
||||
} catch (Throwable ex) {
|
||||
//do nothing
|
||||
}
|
||||
java.lang.reflect.Type[] originalParamTypes = TypeToken.getGenericType(method.getGenericParameterTypes(), service.getClass());
|
||||
java.lang.reflect.Type originalReturnType = TypeToken.getGenericType(method.getGenericReturnType(), service.getClass());
|
||||
@@ -474,6 +475,7 @@ public class SncpServlet extends Servlet<SncpContext, SncpRequest, SncpResponse>
|
||||
Class clz = RedkaleClassLoader.findDynClass(newDynName.replace('/', '.'));
|
||||
newClazz = clz == null ? Thread.currentThread().getContextClassLoader().loadClass(newDynName.replace('/', '.')) : clz;
|
||||
} catch (Throwable ex) {
|
||||
//do nothing
|
||||
}
|
||||
|
||||
final java.lang.reflect.Type[] originalParamTypes = TypeToken.getGenericType(method.getGenericParameterTypes(), serviceClass);
|
||||
@@ -667,6 +669,7 @@ public class SncpServlet extends Servlet<SncpContext, SncpRequest, SncpResponse>
|
||||
try {
|
||||
RedkaleClassLoader.putReflectionField(newDynName.replace('/', '.'), newClazz.getField("service"));
|
||||
} catch (Exception e) {
|
||||
//do nothing
|
||||
}
|
||||
for (java.lang.reflect.Type t : originalParamTypes) {
|
||||
if (t.toString().startsWith("java.lang.")) {
|
||||
|
||||
@@ -77,7 +77,7 @@ public abstract class AbstractDataSqlSource extends AbstractDataSource implement
|
||||
protected final BiFunction<DataSource, EntityInfo, CompletableFuture<List>> fullloader = (s, i)
|
||||
-> ((CompletableFuture<Sheet>) querySheetDBAsync(i, false, false, false, null, null, (FilterNode) null)).thenApply(e -> e == null ? new ArrayList() : e.list(true));
|
||||
|
||||
protected final Function<Integer, String> signFunc = index -> prepareParamSign(index);
|
||||
protected final IntFunction<String> signFunc = index -> prepareParamSign(index);
|
||||
|
||||
//超过多少毫秒视为较慢, 会打印警告级别的日志, 默认值: 2000
|
||||
protected long slowmsWarn;
|
||||
|
||||
@@ -1170,6 +1170,7 @@ public class DataJdbcSource extends AbstractDataSqlSource {
|
||||
conn.commit();
|
||||
conn.offerUpdateStatement(stmt);
|
||||
} catch (SQLException e2) {
|
||||
//do nothing
|
||||
}
|
||||
}
|
||||
//表不存在,更新条数为0
|
||||
@@ -2994,6 +2995,7 @@ public class DataJdbcSource extends AbstractDataSqlSource {
|
||||
stmt.close();
|
||||
conn.close();
|
||||
} catch (Exception e) {
|
||||
//do nothing
|
||||
}
|
||||
if (this.maxConns > newMaxconns) { //配置连接数过大
|
||||
changeMaxConns(newMaxconns);
|
||||
@@ -3118,6 +3120,7 @@ public class DataJdbcSource extends AbstractDataSqlSource {
|
||||
try {
|
||||
x.close();
|
||||
} catch (Exception e) {
|
||||
//do nothing
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
package org.redkale.source;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.IntFunction;
|
||||
import org.redkale.convert.ConvertDisabled;
|
||||
import org.redkale.convert.json.JsonConvert;
|
||||
import org.redkale.util.RedkaleClassLoader;
|
||||
@@ -21,10 +21,10 @@ import org.redkale.util.RedkaleClassLoader;
|
||||
*/
|
||||
public interface DataNativeSqlParser {
|
||||
|
||||
NativeSqlStatement parse(Function<Integer, String> signFunc, String dbtype, String rawSql, Map<String, Object> params);
|
||||
NativeSqlStatement parse(IntFunction<String> signFunc, String dbtype, String rawSql, Map<String, Object> params);
|
||||
|
||||
public static DataNativeSqlParser loadFirst() {
|
||||
if (NativeSqlStatement._first_parser != NativeSqlStatement._NIL) {
|
||||
if (NativeSqlStatement._first_parser != NativeSqlStatement.PARSER_NIL) {
|
||||
return NativeSqlStatement._first_parser;
|
||||
}
|
||||
Iterator<DataNativeSqlParserProvider> it = ServiceLoader.load(DataNativeSqlParserProvider.class).iterator();
|
||||
@@ -41,14 +41,14 @@ public interface DataNativeSqlParser {
|
||||
|
||||
public static class NativeSqlStatement {
|
||||
|
||||
private static final DataNativeSqlParser _NIL = new DataNativeSqlParser() {
|
||||
private static final DataNativeSqlParser PARSER_NIL = new DataNativeSqlParser() {
|
||||
@Override
|
||||
public NativeSqlStatement parse(Function<Integer, String> signFunc, String dbtype, String rawSql, Map<String, Object> params) {
|
||||
public NativeSqlStatement parse(IntFunction<String> signFunc, String dbtype, String rawSql, Map<String, Object> params) {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
};
|
||||
|
||||
private static DataNativeSqlParser _first_parser = _NIL;
|
||||
private static DataNativeSqlParser _first_parser = PARSER_NIL;
|
||||
|
||||
//根据参数值集合重新生成的带?参数可执行的sql
|
||||
protected String nativeSql;
|
||||
|
||||
@@ -735,6 +735,7 @@ public interface Attribute<T, F> {
|
||||
getter = m;
|
||||
}
|
||||
} catch (Exception ex2) {
|
||||
//do nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -742,6 +743,7 @@ public interface Attribute<T, F> {
|
||||
try {
|
||||
setter = clazz.getMethod("set" + mn, field.getType());
|
||||
} catch (Exception ex) {
|
||||
//do nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -868,6 +870,7 @@ public interface Attribute<T, F> {
|
||||
_attach.set(rs, attach);
|
||||
return rs;
|
||||
} catch (Throwable ex) {
|
||||
//do nothing
|
||||
}
|
||||
//---------------------------------------------------
|
||||
final ClassWriter cw = new ClassWriter(COMPUTE_FRAMES);
|
||||
|
||||
@@ -1054,6 +1054,7 @@ public interface Copier<S, D> extends BiFunction<S, D, D> {
|
||||
}
|
||||
}
|
||||
} catch (Exception e2) {
|
||||
//do nothing
|
||||
}
|
||||
}
|
||||
if (setter == null) {
|
||||
|
||||
@@ -272,6 +272,7 @@ public interface Creator<T> {
|
||||
Class clz = RedkaleClassLoader.findDynClass(newDynName.replace('/', '.'));
|
||||
return (Creator) (clz == null ? loader.loadClass(newDynName.replace('/', '.')) : clz).getDeclaredConstructor().newInstance();
|
||||
} catch (Throwable ex) {
|
||||
//do nothing
|
||||
}
|
||||
|
||||
Constructor<T> constructor0 = null;
|
||||
|
||||
@@ -33,7 +33,7 @@ public abstract class Flows {
|
||||
* }
|
||||
* </pre></blockquote>
|
||||
*/
|
||||
private static final String functionMonoFutureBinary = "cafebabe0000003700220a000200030700040c0005000"
|
||||
private static final String FUNCTION_MONO_FUTRUE_BINARY = "cafebabe0000003700220a000200030700040c0005000"
|
||||
+ "60100106a6176612f6c616e672f4f626a6563740100063c696e69743e01000328295607000801001b72656163746f722f636f72652"
|
||||
+ "f7075626c69736865722f4d6f6e6f0a0007000a0c000b000c010008746f46757475726501002a28294c6a6176612f7574696c2f636"
|
||||
+ "f6e63757272656e742f436f6d706c657461626c654675747572653b0a000e000f0700100c0011001201002c6f72672f7265646b616"
|
||||
@@ -65,7 +65,7 @@ public abstract class Flows {
|
||||
* }
|
||||
* </pre></blockquote>
|
||||
*/
|
||||
private static final String functionFluxFutureBinary = "cafebabe0000003700280a000200030700040c0005000"
|
||||
private static final String FUNCTION_FLUX_FUTRUE_BINARY = "cafebabe0000003700280a000200030700040c0005000"
|
||||
+ "60100106a6176612f6c616e672f4f626a6563740100063c696e69743e01000328295607000801001b72656163746f722f636f72"
|
||||
+ "652f7075626c69736865722f466c75780a0007000a0c000b000c01000b636f6c6c6563744c69737401001f28294c72656163746"
|
||||
+ "f722f636f72652f7075626c69736865722f4d6f6e6f3b0a000e000f0700100c0011001201001b72656163746f722f636f72652f"
|
||||
@@ -110,9 +110,10 @@ public abstract class Flows {
|
||||
try {
|
||||
monoFuncClass = (Class) Thread.currentThread().getContextClassLoader().loadClass("org.redkale.util.AnonymousMonoFutureFunction");
|
||||
} catch (Throwable t) {
|
||||
//do nothing
|
||||
}
|
||||
if (monoFuncClass == null) {
|
||||
byte[] classBytes = hexToBin(functionMonoFutureBinary);
|
||||
byte[] classBytes = hexToBin(FUNCTION_MONO_FUTRUE_BINARY);
|
||||
monoFuncClass = (Class<Function<Object, CompletableFuture>>) new ClassLoader() {
|
||||
public final Class<?> loadClass(String name, byte[] b) {
|
||||
return defineClass(name, b, 0, b.length);
|
||||
@@ -128,9 +129,10 @@ public abstract class Flows {
|
||||
try {
|
||||
fluxFuncClass = (Class) Thread.currentThread().getContextClassLoader().loadClass("org.redkale.util.AnonymousFluxFutureFunction");
|
||||
} catch (Throwable t) {
|
||||
//do nothing
|
||||
}
|
||||
if (fluxFuncClass == null) {
|
||||
byte[] classBytes = hexToBin(functionFluxFutureBinary);
|
||||
byte[] classBytes = hexToBin(FUNCTION_FLUX_FUTRUE_BINARY);
|
||||
fluxFuncClass = (Class<Function<Object, CompletableFuture>>) new ClassLoader() {
|
||||
public final Class<?> loadClass(String name, byte[] b) {
|
||||
return defineClass(name, b, 0, b.length);
|
||||
@@ -141,6 +143,7 @@ public abstract class Flows {
|
||||
RedkaleClassLoader.putReflectionDeclaredConstructors(fluxFuncClass, fluxFuncClass.getName());
|
||||
reactorFluxFunction0 = (Function<Object, CompletableFuture>) fluxFuncClass.getDeclaredConstructor().newInstance();
|
||||
} catch (Throwable t) {
|
||||
//do nothing
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,18 +12,18 @@ import static org.redkale.asm.Opcodes.*;
|
||||
import org.redkale.asm.Type;
|
||||
|
||||
/**
|
||||
* 动态生成指定方法的调用对象, 替代Method.invoke的反射方式
|
||||
* 动态生成指定public方法的调用对象, 替代Method.invoke的反射方式
|
||||
*
|
||||
* <p>
|
||||
* 详情见: https://redkale.org
|
||||
*
|
||||
* @param <OBJECT_TYPE> 泛型
|
||||
* @param <RETURN_TYPE> 泛型
|
||||
* @param <C> 泛型
|
||||
* @param <R> 泛型
|
||||
*
|
||||
* @author zhangjx
|
||||
* @since 2.5.0
|
||||
*/
|
||||
public interface Invoker<OBJECT_TYPE, RETURN_TYPE> {
|
||||
public interface Invoker<C, R> {
|
||||
|
||||
/**
|
||||
* 调用方法放回值, 调用静态方法obj=null
|
||||
@@ -33,9 +33,9 @@ public interface Invoker<OBJECT_TYPE, RETURN_TYPE> {
|
||||
*
|
||||
* @return 方法返回的结果
|
||||
*/
|
||||
public RETURN_TYPE invoke(OBJECT_TYPE obj, Object... params);
|
||||
public R invoke(C obj, Object... params);
|
||||
|
||||
public static <OBJECT_TYPE, RETURN_TYPE> Invoker<OBJECT_TYPE, RETURN_TYPE> load(final Class<OBJECT_TYPE> clazz, final String methodName, final Class... paramTypes) {
|
||||
public static <C, T> Invoker<C, T> load(final Class<C> clazz, final String methodName, final Class... paramTypes) {
|
||||
java.lang.reflect.Method method = null;
|
||||
try {
|
||||
method = clazz.getMethod(methodName, paramTypes);
|
||||
@@ -45,7 +45,7 @@ public interface Invoker<OBJECT_TYPE, RETURN_TYPE> {
|
||||
return load(clazz, method);
|
||||
}
|
||||
|
||||
public static <OBJECT_TYPE, RETURN_TYPE> Invoker<OBJECT_TYPE, RETURN_TYPE> create(final Class<OBJECT_TYPE> clazz, final String methodName, final Class... paramTypes) {
|
||||
public static <C, T> Invoker<C, T> create(final Class<C> clazz, final String methodName, final Class... paramTypes) {
|
||||
java.lang.reflect.Method method = null;
|
||||
try {
|
||||
method = clazz.getMethod(methodName, paramTypes);
|
||||
@@ -64,8 +64,8 @@ public interface Invoker<OBJECT_TYPE, RETURN_TYPE> {
|
||||
public static <C, T> Invoker<C, T> create(final Class<C> clazz, final Method method) {
|
||||
RedkaleClassLoader.putReflectionDeclaredMethods(clazz.getName());
|
||||
RedkaleClassLoader.putReflectionMethod(clazz.getName(), method);
|
||||
boolean throwflag = Utility.contains(method.getExceptionTypes(), e -> !RuntimeException.class.isAssignableFrom(e)); //方法是否会抛出非RuntimeException异常
|
||||
boolean staticflag = Modifier.isStatic(method.getModifiers());
|
||||
boolean throwFlag = Utility.contains(method.getExceptionTypes(), e -> !RuntimeException.class.isAssignableFrom(e)); //方法是否会抛出非RuntimeException异常
|
||||
boolean staticFlag = Modifier.isStatic(method.getModifiers());
|
||||
final Class<T> returnType = (Class<T>) method.getReturnType();
|
||||
final String supDynName = Invoker.class.getName().replace('.', '/');
|
||||
final String interName = clazz.getName().replace('.', '/');
|
||||
@@ -100,6 +100,7 @@ public interface Invoker<OBJECT_TYPE, RETURN_TYPE> {
|
||||
Class clz = RedkaleClassLoader.findDynClass(newDynName.replace('/', '.'));
|
||||
return (Invoker<C, T>) (clz == null ? loader.loadClass(newDynName.replace('/', '.')) : clz).getDeclaredConstructor().newInstance();
|
||||
} catch (Throwable ex) {
|
||||
//do nothing
|
||||
}
|
||||
//-------------------------------------------------------------
|
||||
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES);
|
||||
@@ -122,11 +123,11 @@ public interface Invoker<OBJECT_TYPE, RETURN_TYPE> {
|
||||
Label label0 = new Label();
|
||||
Label label1 = new Label();
|
||||
Label label2 = new Label();
|
||||
if (throwflag) {
|
||||
if (throwFlag) {
|
||||
mv.visitTryCatchBlock(label0, label1, label2, "java/lang/Throwable");
|
||||
mv.visitLabel(label0);
|
||||
}
|
||||
if (!staticflag) {
|
||||
if (!staticFlag) {
|
||||
mv.visitVarInsn(ALOAD, 1);
|
||||
}
|
||||
|
||||
@@ -142,11 +143,11 @@ public interface Invoker<OBJECT_TYPE, RETURN_TYPE> {
|
||||
paramIndex++;
|
||||
}
|
||||
|
||||
mv.visitMethodInsn(staticflag ? INVOKESTATIC : (clazz.isInterface() ? INVOKEINTERFACE : INVOKEVIRTUAL), interName, method.getName(), "(" + paramDescs + ")" + returnPrimiveDesc, !staticflag && clazz.isInterface());
|
||||
mv.visitMethodInsn(staticFlag ? INVOKESTATIC : (clazz.isInterface() ? INVOKEINTERFACE : INVOKEVIRTUAL), interName, method.getName(), "(" + paramDescs + ")" + returnPrimiveDesc, !staticFlag && clazz.isInterface());
|
||||
Asms.visitPrimitiveValueOf(mv, returnType);
|
||||
mv.visitLabel(label1);
|
||||
mv.visitInsn(ARETURN);
|
||||
if (throwflag) {
|
||||
if (throwFlag) {
|
||||
mv.visitLabel(label2);
|
||||
mv.visitFrame(Opcodes.F_SAME1, 0, null, 1, new Object[]{"java/lang/Throwable"});
|
||||
mv.visitVarInsn(ASTORE, 3);
|
||||
|
||||
@@ -1041,13 +1041,14 @@ public class NonBlockingHashMap<TypeK, TypeV> extends AbstractMap<TypeK, TypeV>
|
||||
newkvs = _newkvs; // Between dorking around, another thread did it
|
||||
if (newkvs != null) // See if resize is already in progress
|
||||
return newkvs; // Use the new table already
|
||||
// TODO - use a wait with timeout, so we'll wakeup as soon as the new table
|
||||
// TO DO - use a wait with timeout, so we'll wakeup as soon as the new table
|
||||
// is ready, or after the timeout in any case.
|
||||
// For now, sleep a tad and see if the 2 guys already trying to make
|
||||
// the table actually get around to making it happen.
|
||||
try {
|
||||
Thread.sleep(megs);
|
||||
} catch (Exception e) {
|
||||
//do nothing
|
||||
}
|
||||
}
|
||||
// Last check, since the 'new' below is expensive and there is a chance
|
||||
|
||||
@@ -14,13 +14,13 @@ package org.redkale.util;
|
||||
*/
|
||||
public final class Redkale {
|
||||
|
||||
private static final String rootPackage = "org.redkale";
|
||||
private static final String ROOT_PACKAGE = "org.redkale";
|
||||
|
||||
private Redkale() {
|
||||
}
|
||||
|
||||
public static String getRootPackage() {
|
||||
return rootPackage;
|
||||
return ROOT_PACKAGE;
|
||||
}
|
||||
|
||||
public static String getDotedVersion() {
|
||||
|
||||
@@ -3,8 +3,8 @@ package org.redkale.util;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.Map;
|
||||
import java.util.function.*;
|
||||
import static org.redkale.asm.ClassWriter.COMPUTE_FRAMES;
|
||||
import org.redkale.asm.*;
|
||||
import static org.redkale.asm.ClassWriter.COMPUTE_FRAMES;
|
||||
import static org.redkale.asm.Opcodes.*;
|
||||
|
||||
/**
|
||||
@@ -17,6 +17,7 @@ import static org.redkale.asm.Opcodes.*;
|
||||
* @author zhangjx
|
||||
* @param <D> 目标对象的数据类型
|
||||
* @param <S> 源对象的数据类型
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
@Deprecated(since = "2.8.0")
|
||||
@@ -64,6 +65,7 @@ public interface Reproduce<D, S> extends BiFunction<D, S, D> {
|
||||
Class clz = RedkaleClassLoader.findDynClass(newDynName.replace('/', '.'));
|
||||
return (Reproduce) (clz == null ? loader.loadClass(newDynName.replace('/', '.')) : clz).getDeclaredConstructor().newInstance();
|
||||
} catch (Throwable ex) {
|
||||
//do nothing
|
||||
}
|
||||
// ------------------------------------------------------------------------------
|
||||
ClassWriter cw = new ClassWriter(COMPUTE_FRAMES);
|
||||
@@ -87,16 +89,26 @@ public interface Reproduce<D, S> extends BiFunction<D, S, D> {
|
||||
//mv.setDebug(true);
|
||||
|
||||
for (java.lang.reflect.Field field : srcClass.getFields()) {
|
||||
if (Modifier.isStatic(field.getModifiers())) continue;
|
||||
if (Modifier.isFinal(field.getModifiers())) continue;
|
||||
if (!Modifier.isPublic(field.getModifiers())) continue;
|
||||
if (Modifier.isStatic(field.getModifiers())) {
|
||||
continue;
|
||||
}
|
||||
if (Modifier.isFinal(field.getModifiers())) {
|
||||
continue;
|
||||
}
|
||||
if (!Modifier.isPublic(field.getModifiers())) {
|
||||
continue;
|
||||
}
|
||||
final String sfname = field.getName();
|
||||
if (srcColumnPredicate != null && !srcColumnPredicate.test(field, sfname)) continue;
|
||||
if (srcColumnPredicate != null && !srcColumnPredicate.test(field, sfname)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
final String dfname = names == null ? sfname : names.getOrDefault(sfname, sfname);
|
||||
java.lang.reflect.Method setter = null;
|
||||
try {
|
||||
if (!field.getType().equals(destClass.getField(dfname).getType())) continue;
|
||||
if (!field.getType().equals(destClass.getField(dfname).getType())) {
|
||||
continue;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
try {
|
||||
char[] cs = dfname.toCharArray();
|
||||
@@ -119,19 +131,31 @@ public interface Reproduce<D, S> extends BiFunction<D, S, D> {
|
||||
}
|
||||
|
||||
for (java.lang.reflect.Method getter : srcClass.getMethods()) {
|
||||
if (Modifier.isStatic(getter.getModifiers())) continue;
|
||||
if (getter.getParameterTypes().length > 0) continue;
|
||||
if ("getClass".equals(getter.getName())) continue;
|
||||
if (!getter.getName().startsWith("get") && !getter.getName().startsWith("is")) continue;
|
||||
if (Modifier.isStatic(getter.getModifiers())) {
|
||||
continue;
|
||||
}
|
||||
if (getter.getParameterTypes().length > 0) {
|
||||
continue;
|
||||
}
|
||||
if ("getClass".equals(getter.getName())) {
|
||||
continue;
|
||||
}
|
||||
if (!getter.getName().startsWith("get") && !getter.getName().startsWith("is")) {
|
||||
continue;
|
||||
}
|
||||
final boolean is = getter.getName().startsWith("is");
|
||||
String sfname = getter.getName().substring(is ? 2 : 3);
|
||||
if (sfname.isEmpty()) continue;
|
||||
if (sfname.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
if (sfname.length() < 2 || Character.isLowerCase(sfname.charAt(1))) {
|
||||
char[] cs = sfname.toCharArray();
|
||||
cs[0] = Character.toLowerCase(cs[0]);
|
||||
sfname = new String(cs);
|
||||
}
|
||||
if (srcColumnPredicate != null && !srcColumnPredicate.test(getter, sfname)) continue;
|
||||
if (srcColumnPredicate != null && !srcColumnPredicate.test(getter, sfname)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
final String dfname = names == null ? sfname : names.getOrDefault(sfname, sfname);
|
||||
java.lang.reflect.Method setter = null;
|
||||
@@ -144,7 +168,9 @@ public interface Reproduce<D, S> extends BiFunction<D, S, D> {
|
||||
} catch (Exception e) {
|
||||
try {
|
||||
srcField = destClass.getField(dfname);
|
||||
if (!getter.getReturnType().equals(srcField.getType())) continue;
|
||||
if (!getter.getReturnType().equals(srcField.getType())) {
|
||||
continue;
|
||||
}
|
||||
} catch (Exception e2) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -34,24 +34,24 @@ public class SelectColumn implements Predicate<String> {
|
||||
if (len < 1) {
|
||||
return;
|
||||
}
|
||||
Pattern[] regs = null;
|
||||
Pattern[] regxs = null;
|
||||
String[] cols = null;
|
||||
int regcount = 0;
|
||||
int colcount = 0;
|
||||
for (String col : columns0) {
|
||||
boolean reg = false;
|
||||
boolean regx = false;
|
||||
for (int i = 0; i < col.length(); i++) {
|
||||
char ch = col.charAt(i);
|
||||
if (ch == '^' || ch == '$' || ch == '*' || ch == '?' || ch == '+' || ch == '[' || ch == '(') {
|
||||
reg = true;
|
||||
regx = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (reg) {
|
||||
if (regs == null) {
|
||||
regs = new Pattern[len];
|
||||
if (regx) {
|
||||
if (regxs == null) {
|
||||
regxs = new Pattern[len];
|
||||
}
|
||||
regs[regcount++] = Pattern.compile(col);
|
||||
regxs[regcount++] = Pattern.compile(col);
|
||||
} else {
|
||||
if (cols == null) {
|
||||
cols = new String[len];
|
||||
@@ -59,11 +59,11 @@ public class SelectColumn implements Predicate<String> {
|
||||
cols[colcount++] = col;
|
||||
}
|
||||
}
|
||||
if (regs != null) {
|
||||
if (regxs != null) {
|
||||
if (regcount == len) {
|
||||
this.patterns = regs;
|
||||
this.patterns = regxs;
|
||||
} else {
|
||||
this.patterns = Arrays.copyOf(regs, regcount);
|
||||
this.patterns = Arrays.copyOf(regxs, regcount);
|
||||
}
|
||||
}
|
||||
if (cols != null) {
|
||||
|
||||
@@ -17,9 +17,9 @@ import java.util.function.Supplier;
|
||||
*/
|
||||
public class Traces {
|
||||
|
||||
private static final boolean enable = !Boolean.getBoolean("redkale.trace.disable");
|
||||
private static final boolean ENABLE = !Boolean.getBoolean("redkale.trace.disable");
|
||||
|
||||
private static final String PROCESS_ID = UUID.randomUUID().toString().replaceAll("-", "");
|
||||
private static final String PROCESS_ID = UUID.randomUUID().toString().replace("-", "");
|
||||
|
||||
private static final AtomicLong sequence = new AtomicLong(System.currentTimeMillis());
|
||||
|
||||
@@ -33,7 +33,7 @@ public class Traces {
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean enable() {
|
||||
return enable;
|
||||
return ENABLE;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -42,7 +42,7 @@ public class Traces {
|
||||
* @return String
|
||||
*/
|
||||
public static String createTraceid() {
|
||||
return enable ? tidSupplier.get() : null;
|
||||
return ENABLE ? tidSupplier.get() : null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -51,14 +51,14 @@ public class Traces {
|
||||
* @return String
|
||||
*/
|
||||
public static String currentTraceid() {
|
||||
return enable ? localTrace.get() : null;
|
||||
return ENABLE ? localTrace.get() : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除当前线程的traceid
|
||||
*/
|
||||
public static void removeTraceid() {
|
||||
if (enable) {
|
||||
if (ENABLE) {
|
||||
localTrace.remove();
|
||||
}
|
||||
}
|
||||
@@ -70,7 +70,7 @@ public class Traces {
|
||||
*
|
||||
*/
|
||||
public static void currentTraceid(String traceid) {
|
||||
if (enable) {
|
||||
if (ENABLE) {
|
||||
if (traceid != null && !traceid.isEmpty()) {
|
||||
localTrace.set(traceid);
|
||||
} else {
|
||||
@@ -87,7 +87,7 @@ public class Traces {
|
||||
* @return String
|
||||
*/
|
||||
public static String computeIfAbsent(String traceid) {
|
||||
if (enable) {
|
||||
if (ENABLE) {
|
||||
String rs = traceid;
|
||||
if (rs == null || rs.isEmpty()) {
|
||||
rs = tidSupplier.get();
|
||||
@@ -107,7 +107,7 @@ public class Traces {
|
||||
* @return String
|
||||
*/
|
||||
public static String computeIfAbsent(String traceid, String traceid2) {
|
||||
if (enable) {
|
||||
if (ENABLE) {
|
||||
String rs = traceid;
|
||||
if (rs == null || rs.isEmpty()) {
|
||||
if (traceid2 == null || traceid2.isEmpty()) {
|
||||
|
||||
@@ -639,6 +639,7 @@ public abstract class TypeToken<T> {
|
||||
try {
|
||||
return loader.loadClass(newDynName.replace('/', '.')).getField("field").getGenericType();
|
||||
} catch (Throwable ex) {
|
||||
//do nothing
|
||||
}
|
||||
// ------------------------------------------------------------------------------
|
||||
org.redkale.asm.ClassWriter cw = new org.redkale.asm.ClassWriter(COMPUTE_FRAMES);
|
||||
|
||||
@@ -41,7 +41,7 @@ public final class Utility {
|
||||
|
||||
private static final char hex[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
|
||||
|
||||
private static final int cpus = Integer.getInteger("redkale.cpus", Runtime.getRuntime().availableProcessors());
|
||||
private static final int CPUS = Integer.getInteger("redkale.cpus", Runtime.getRuntime().availableProcessors());
|
||||
|
||||
private static final int MAX_POW2 = 1 << 30;
|
||||
|
||||
@@ -148,6 +148,7 @@ public final class Utility {
|
||||
try {
|
||||
virtualClazz1 = (Class) loader.loadClass("org.redkale.util.AnonymousThreadLocal");
|
||||
} catch (Throwable t) {
|
||||
//do nothing
|
||||
}
|
||||
if (virtualClazz1 == null) {
|
||||
byte[] classBytes = hexToBin(functionThreadLocalBinary);
|
||||
@@ -162,6 +163,7 @@ public final class Utility {
|
||||
Supplier supplier = () -> null;
|
||||
virtualThreadLocalFunction0 = virtualClazz1.getConstructor(Supplier.class).newInstance(supplier);
|
||||
} catch (Throwable t) {
|
||||
//do nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -170,6 +172,7 @@ public final class Utility {
|
||||
try {
|
||||
virtualClazz1 = (Class) loader.loadClass("org.redkale.util.AnonymousThreadFactory");
|
||||
} catch (Throwable t) {
|
||||
//do nothing
|
||||
}
|
||||
if (virtualClazz1 == null) {
|
||||
byte[] classBytes = hexToBin(functionThreadFactoryBinary);
|
||||
@@ -183,6 +186,7 @@ public final class Utility {
|
||||
RedkaleClassLoader.putReflectionDeclaredConstructors(virtualClazz1, virtualClazz1.getName());
|
||||
virtualThreadFactoryFunction0 = virtualClazz1.getConstructor(String.class).newInstance(null);
|
||||
} catch (Throwable t) {
|
||||
//do nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -191,6 +195,7 @@ public final class Utility {
|
||||
try {
|
||||
virtualClazz1 = (Class) loader.loadClass("org.redkale.util.AnonymousVirtualPoolFunction");
|
||||
} catch (Throwable t) {
|
||||
//do nothing
|
||||
}
|
||||
if (virtualClazz1 == null) {
|
||||
byte[] classBytes = hexToBin(functionVirtualPoolBinary);
|
||||
@@ -204,6 +209,7 @@ public final class Utility {
|
||||
RedkaleClassLoader.putReflectionDeclaredConstructors(virtualClazz1, virtualClazz1.getName());
|
||||
virtualPoolFunction0 = virtualClazz1.getConstructor().newInstance();
|
||||
} catch (Throwable t) {
|
||||
//do nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -212,6 +218,7 @@ public final class Utility {
|
||||
try {
|
||||
virtualClazz1 = (Class) loader.loadClass("org.redkale.util.AnonymousVirtualExecutor");
|
||||
} catch (Throwable t) {
|
||||
//do nothing
|
||||
}
|
||||
if (virtualClazz1 == null) {
|
||||
byte[] classBytes = hexToBin(consumerVirtualExecutorBinary);
|
||||
@@ -225,6 +232,7 @@ public final class Utility {
|
||||
RedkaleClassLoader.putReflectionDeclaredConstructors(virtualClazz1, virtualClazz1.getName());
|
||||
virtualExecutorConsumer0 = virtualClazz1.getConstructor().newInstance();
|
||||
} catch (Throwable t) {
|
||||
//do nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -240,6 +248,7 @@ public final class Utility {
|
||||
try {
|
||||
unsafeClazz1 = (Class) loader.loadClass("org.redkale.util.AnonymousUnsafe");
|
||||
} catch (Throwable t) {
|
||||
//do nothing
|
||||
}
|
||||
if (unsafeClazz1 == null) {
|
||||
byte[] classBytes = hexToBin(funcAnonymousUnsafeBinary);
|
||||
@@ -269,6 +278,7 @@ public final class Utility {
|
||||
try {
|
||||
shutdownClazz1 = (Class) loader.loadClass("org.redkale.util.SignalShutDown");
|
||||
} catch (Throwable t) {
|
||||
//do nothing
|
||||
}
|
||||
if (shutdownClazz1 == null) {
|
||||
byte[] classBytes = hexToBin(consumerSignalShutdownBinary);
|
||||
@@ -329,7 +339,7 @@ public final class Utility {
|
||||
}
|
||||
|
||||
public static int cpus() {
|
||||
return cpus;
|
||||
return CPUS;
|
||||
}
|
||||
|
||||
public static Function<String, ExecutorService> virtualExecutorFunction() {
|
||||
@@ -422,6 +432,7 @@ public final class Utility {
|
||||
try {
|
||||
Thread.sleep(millis);
|
||||
} catch (Exception e) {
|
||||
//do nothing
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user