sonar优化
This commit is contained in:
@@ -156,7 +156,7 @@ public class LoggingFileHandler extends LoggingBaseHandler {
|
|||||||
Files.move(logfile.toPath(), new File(logfile.getPath() + ".1").toPath(), REPLACE_EXISTING, ATOMIC_MOVE);
|
Files.move(logfile.toPath(), new File(logfile.getPath() + ".1").toPath(), REPLACE_EXISTING, ATOMIC_MOVE);
|
||||||
} else {
|
} else {
|
||||||
if (logfile.exists() && logfile.length() < 1) {
|
if (logfile.exists() && logfile.length() < 1) {
|
||||||
logfile.delete();
|
Files.delete(logfile.toPath());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
logstream = null;
|
logstream = null;
|
||||||
@@ -174,7 +174,7 @@ public class LoggingFileHandler extends LoggingBaseHandler {
|
|||||||
Files.move(logunusualfile.toPath(), new File(logunusualfile.getPath() + ".1").toPath(), REPLACE_EXISTING, ATOMIC_MOVE);
|
Files.move(logunusualfile.toPath(), new File(logunusualfile.getPath() + ".1").toPath(), REPLACE_EXISTING, ATOMIC_MOVE);
|
||||||
} else {
|
} else {
|
||||||
if (logunusualfile.exists() && logunusualfile.length() < 1) {
|
if (logunusualfile.exists() && logunusualfile.length() < 1) {
|
||||||
logunusualfile.delete();
|
Files.delete(logunusualfile.toPath());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
logunusualstream = null;
|
logunusualstream = null;
|
||||||
|
|||||||
@@ -972,12 +972,14 @@ public abstract class ConvertFactory<R extends Reader, W extends Writer> {
|
|||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
//do nothing
|
//do nothing
|
||||||
}
|
}
|
||||||
try {
|
if (field != null) {
|
||||||
register(type.getMethod("set" + bigColumn, field.getType()), entry);
|
try {
|
||||||
} catch (Exception ex) {
|
register(type.getMethod("set" + bigColumn, field.getType()), entry);
|
||||||
//do nothing
|
} catch (Exception ex) {
|
||||||
|
//do nothing
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return field == null ? true : register(field, entry);
|
return field == null || register(field, entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final <E> boolean register(final AccessibleObject field, final ConvertColumnEntry entry) {
|
public final <E> boolean register(final AccessibleObject field, final ConvertColumnEntry entry) {
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ public class OptionalCoder<R extends Reader, W extends Writer, T> extends Simple
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void convertTo(W out, Optional<T> value) {
|
public void convertTo(W out, Optional<T> value) {
|
||||||
if (value == null || !value.isPresent()) {
|
if (!value.isPresent()) {
|
||||||
out.writeObjectNull(null);
|
out.writeObjectNull(null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -109,12 +109,11 @@ public class BsonWriter extends Writer implements ByteTuple {
|
|||||||
*/
|
*/
|
||||||
protected int expand(int len) {
|
protected int expand(int len) {
|
||||||
int newcount = count + len;
|
int newcount = count + len;
|
||||||
if (newcount <= content.length) {
|
if (newcount > content.length) {
|
||||||
return 0;
|
byte[] newdata = new byte[Math.max(content.length * 3 / 2, newcount)];
|
||||||
|
System.arraycopy(content, 0, newdata, 0, count);
|
||||||
|
this.content = newdata;
|
||||||
}
|
}
|
||||||
byte[] newdata = new byte[Math.max(content.length * 3 / 2, newcount)];
|
|
||||||
System.arraycopy(content, 0, newdata, 0, count);
|
|
||||||
this.content = newdata;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -325,7 +325,7 @@ public abstract class JsonDynEncoder<T> implements Encodeable<JsonWriter, T> {
|
|||||||
if (element instanceof Field) {
|
if (element instanceof Field) {
|
||||||
return ((Field) element).getType();
|
return ((Field) element).getType();
|
||||||
}
|
}
|
||||||
return element == null ? null : ((Method) element).getReturnType();
|
return ((Method) element).getReturnType();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static String readGetSetFieldName(AccessibleObject element) {
|
protected static String readGetSetFieldName(AccessibleObject element) {
|
||||||
@@ -333,9 +333,6 @@ public abstract class JsonDynEncoder<T> implements Encodeable<JsonWriter, T> {
|
|||||||
return ((Field) element).getName();
|
return ((Field) element).getName();
|
||||||
}
|
}
|
||||||
Method method = (Method) element;
|
Method method = (Method) element;
|
||||||
if (method == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
String fname = method.getName();
|
String fname = method.getName();
|
||||||
if (!(fname.startsWith("is") && fname.length() > 2)
|
if (!(fname.startsWith("is") && fname.length() > 2)
|
||||||
&& !(fname.startsWith("get") && fname.length() > 3)
|
&& !(fname.startsWith("get") && fname.length() > 3)
|
||||||
@@ -376,8 +373,8 @@ public abstract class JsonDynEncoder<T> implements Encodeable<JsonWriter, T> {
|
|||||||
ConvertColumnEntry ref1 = factory.findRef(clazz, element);
|
ConvertColumnEntry ref1 = factory.findRef(clazz, element);
|
||||||
final String fieldname = ref1 == null || ref1.name().isEmpty() ? readGetSetFieldName(element) : ref1.name();
|
final String fieldname = ref1 == null || ref1.name().isEmpty() ? readGetSetFieldName(element) : ref1.name();
|
||||||
memberb.append(fieldname).append(',');
|
memberb.append(fieldname).append(',');
|
||||||
final Class fieldtype = readGetSetFieldType(element);
|
final Class fieldType = readGetSetFieldType(element);
|
||||||
if (fieldtype != String.class && !fieldtype.isPrimitive()) {
|
if (fieldType != String.class && !fieldType.isPrimitive()) {
|
||||||
if (mixedNames0 == null) {
|
if (mixedNames0 == null) {
|
||||||
mixedNames0 = new HashMap<>();
|
mixedNames0 = new HashMap<>();
|
||||||
}
|
}
|
||||||
@@ -430,17 +427,17 @@ public abstract class JsonDynEncoder<T> implements Encodeable<JsonWriter, T> {
|
|||||||
fv.visitEnd();
|
fv.visitEnd();
|
||||||
fv = cw.visitField(ACC_PROTECTED + ACC_FINAL, fieldname + "FirstFieldBytes", "[B", null, null);
|
fv = cw.visitField(ACC_PROTECTED + ACC_FINAL, fieldname + "FirstFieldBytes", "[B", null, null);
|
||||||
fv.visitEnd();
|
fv.visitEnd();
|
||||||
final Class fieldtype = readGetSetFieldType(element);
|
final Class fieldType = readGetSetFieldType(element);
|
||||||
if (fieldtype != String.class && !fieldtype.isPrimitive()) {
|
if (fieldType != String.class && !fieldType.isPrimitive()) {
|
||||||
fv = cw.visitField(ACC_PROTECTED, fieldname + "Encoder", encodeableDesc, null, null);
|
fv = cw.visitField(ACC_PROTECTED, fieldname + "Encoder", encodeableDesc, null, null);
|
||||||
fv.visitEnd();
|
fv.visitEnd();
|
||||||
}
|
}
|
||||||
if (fieldtype == int.class) {
|
if (fieldType == int.class) {
|
||||||
intFieldCount++;
|
intFieldCount++;
|
||||||
}
|
}
|
||||||
if (fieldtype == String.class && membersSize == 1 && readConvertSmallString(element) != null) {
|
if (fieldType == String.class && membersSize == 1 && readConvertSmallString(element) != null) {
|
||||||
onlyOneLatin1FieldObjectFlag = true;
|
onlyOneLatin1FieldObjectFlag = true;
|
||||||
} else if (fieldtype != short.class && fieldtype != int.class && fieldtype != long.class && !(fieldtype == String.class && readConvertSmallString(element) != null)) {
|
} else if (fieldType != short.class && fieldType != int.class && fieldType != long.class && !(fieldType == String.class && readConvertSmallString(element) != null)) {
|
||||||
onlyShotIntLongLatin1MoreFieldObjectFlag = false;
|
onlyShotIntLongLatin1MoreFieldObjectFlag = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -542,19 +539,19 @@ public abstract class JsonDynEncoder<T> implements Encodeable<JsonWriter, T> {
|
|||||||
elementIndex++;
|
elementIndex++;
|
||||||
AccessibleObject element1 = members.get(elementIndex);
|
AccessibleObject element1 = members.get(elementIndex);
|
||||||
ConvertColumnEntry ref1 = factory.findRef(clazz, element1);
|
ConvertColumnEntry ref1 = factory.findRef(clazz, element1);
|
||||||
final String fieldname1 = ref1 == null || ref1.name().isEmpty() ? readGetSetFieldName(element1) : ref1.name();
|
final String fieldName1 = ref1 == null || ref1.name().isEmpty() ? readGetSetFieldName(element1) : ref1.name();
|
||||||
final Class fieldtype1 = readGetSetFieldType(element1);
|
final Class fieldtype1 = readGetSetFieldType(element1);
|
||||||
|
|
||||||
elementIndex++;
|
elementIndex++;
|
||||||
AccessibleObject element2 = members.get(elementIndex);
|
AccessibleObject element2 = members.get(elementIndex);
|
||||||
ConvertColumnEntry ref2 = factory.findRef(clazz, element2);
|
ConvertColumnEntry ref2 = factory.findRef(clazz, element2);
|
||||||
final String fieldname2 = ref2 == null || ref2.name().isEmpty() ? readGetSetFieldName(element2) : ref2.name();
|
final String fieldName2 = ref2 == null || ref2.name().isEmpty() ? readGetSetFieldName(element2) : ref2.name();
|
||||||
final Class fieldtype2 = readGetSetFieldType(element2);
|
final Class fieldtype2 = readGetSetFieldType(element2);
|
||||||
|
|
||||||
mv.visitVarInsn(ALOAD, 1);
|
mv.visitVarInsn(ALOAD, 1);
|
||||||
|
|
||||||
mv.visitVarInsn(ALOAD, 0);
|
mv.visitVarInsn(ALOAD, 0);
|
||||||
mv.visitFieldInsn(GETFIELD, newDynName, fieldname1 + "FirstFieldBytes", "[B");
|
mv.visitFieldInsn(GETFIELD, newDynName, fieldName1 + "FirstFieldBytes", "[B");
|
||||||
|
|
||||||
mv.visitVarInsn(ALOAD, 2); //String message = value.getMessage(); 加载 value
|
mv.visitVarInsn(ALOAD, 2); //String message = value.getMessage(); 加载 value
|
||||||
if (element1 instanceof Field) {
|
if (element1 instanceof Field) {
|
||||||
@@ -565,7 +562,7 @@ public abstract class JsonDynEncoder<T> implements Encodeable<JsonWriter, T> {
|
|||||||
maxLocals++;
|
maxLocals++;
|
||||||
|
|
||||||
mv.visitVarInsn(ALOAD, 0);
|
mv.visitVarInsn(ALOAD, 0);
|
||||||
mv.visitFieldInsn(GETFIELD, newDynName, fieldname2 + "CommaFieldBytes", "[B");
|
mv.visitFieldInsn(GETFIELD, newDynName, fieldName2 + "CommaFieldBytes", "[B");
|
||||||
|
|
||||||
mv.visitVarInsn(ALOAD, 2); //String message = value.getMessage(); 加载 value
|
mv.visitVarInsn(ALOAD, 2); //String message = value.getMessage(); 加载 value
|
||||||
if (element2 instanceof Field) {
|
if (element2 instanceof Field) {
|
||||||
|
|||||||
@@ -148,12 +148,11 @@ public class ProtobufWriter extends Writer implements ByteTuple {
|
|||||||
|
|
||||||
protected int expand(int len) {
|
protected int expand(int len) {
|
||||||
int newcount = count + len;
|
int newcount = count + len;
|
||||||
if (newcount <= content.length) {
|
if (newcount > content.length) {
|
||||||
return 0;
|
byte[] newdata = new byte[Math.max(content.length * 3 / 2, newcount)];
|
||||||
|
System.arraycopy(content, 0, newdata, 0, count);
|
||||||
|
this.content = newdata;
|
||||||
}
|
}
|
||||||
byte[] newdata = new byte[Math.max(content.length * 3 / 2, newcount)];
|
|
||||||
System.arraycopy(content, 0, newdata, 0, count);
|
|
||||||
this.content = newdata;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ public class HttpMessageServlet extends MessageServlet {
|
|||||||
protected void onError(Response response, MessageRecord message, Throwable t) {
|
protected void onError(Response response, MessageRecord message, Throwable t) {
|
||||||
if (message.getRespTopic() != null && !message.getRespTopic().isEmpty()) {
|
if (message.getRespTopic() != null && !message.getRespTopic().isEmpty()) {
|
||||||
HttpMessageRequest request = ((HttpMessageResponse) response).request();
|
HttpMessageRequest request = ((HttpMessageResponse) response).request();
|
||||||
HttpMessageResponse.finishHttpResult(logger.isLoggable(Level.FINEST), response == null ? null : request.getRespConvert(),
|
HttpMessageResponse.finishHttpResult(logger.isLoggable(Level.FINEST), request == null ? null : request.getRespConvert(),
|
||||||
null, message, messageClient, message.getRespTopic(), new HttpResult().status(500));
|
null, message, messageClient, message.getRespTopic(), new HttpResult().status(500));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -225,9 +225,7 @@ public abstract class MessageAgent implements Resourcable {
|
|||||||
if (this.messageBaseProducer == null) {
|
if (this.messageBaseProducer == null) {
|
||||||
messageProducerLock.lock();
|
messageProducerLock.lock();
|
||||||
try {
|
try {
|
||||||
if (this.messageBaseProducer == null) {
|
startMessageProducer();
|
||||||
startMessageProducer();
|
|
||||||
}
|
|
||||||
} finally {
|
} finally {
|
||||||
messageProducerLock.unlock();
|
messageProducerLock.unlock();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,12 +15,6 @@ import java.util.concurrent.atomic.AtomicLong;
|
|||||||
import java.util.concurrent.locks.ReentrantLock;
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import org.redkale.cluster.ClusterRpcClient;
|
import org.redkale.cluster.ClusterRpcClient;
|
||||||
import org.redkale.convert.Convert;
|
|
||||||
import org.redkale.convert.json.JsonConvert;
|
|
||||||
import static org.redkale.mq.MessageRecord.CTYPE_HTTP_REQUEST;
|
|
||||||
import static org.redkale.mq.MessageRecord.CTYPE_HTTP_RESULT;
|
|
||||||
import org.redkale.net.http.HttpResult;
|
|
||||||
import org.redkale.net.http.HttpSimpleRequest;
|
|
||||||
import org.redkale.util.RedkaleException;
|
import org.redkale.util.RedkaleException;
|
||||||
import org.redkale.util.Traces;
|
import org.redkale.util.Traces;
|
||||||
import org.redkale.util.Utility;
|
import org.redkale.util.Utility;
|
||||||
@@ -137,18 +131,6 @@ public class MessageClient implements ClusterRpcClient<MessageRecord, MessageRec
|
|||||||
return new MessageRecord(seqid, ctype, topic, respTopic, traceid, content);
|
return new MessageRecord(seqid, ctype, topic, respTopic, traceid, content);
|
||||||
}
|
}
|
||||||
|
|
||||||
private byte ctype(Convert convert, Object bean) {
|
|
||||||
byte ctype = 0;
|
|
||||||
if (convert instanceof JsonConvert) {
|
|
||||||
if (bean instanceof HttpSimpleRequest) {
|
|
||||||
ctype = CTYPE_HTTP_REQUEST;
|
|
||||||
} else if (bean instanceof HttpResult) {
|
|
||||||
ctype = CTYPE_HTTP_RESULT;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ctype;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getProtocol() {
|
public String getProtocol() {
|
||||||
return protocol;
|
return protocol;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -164,7 +164,7 @@ public abstract class ClientCodec<R extends ClientRequest, P extends ClientResul
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
workThread.runWork(() -> {
|
Utility.execute(() -> {
|
||||||
Traces.currentTraceid(request.traceid);
|
Traces.currentTraceid(request.traceid);
|
||||||
respFuture.complete(rs);
|
respFuture.complete(rs);
|
||||||
Traces.removeTraceid();
|
Traces.removeTraceid();
|
||||||
@@ -190,7 +190,7 @@ public abstract class ClientCodec<R extends ClientRequest, P extends ClientResul
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
workThread.runWork(() -> {
|
Utility.execute(() -> {
|
||||||
Traces.currentTraceid(request.traceid);
|
Traces.currentTraceid(request.traceid);
|
||||||
respFuture.completeExceptionally(exc);
|
respFuture.completeExceptionally(exc);
|
||||||
Traces.removeTraceid();
|
Traces.removeTraceid();
|
||||||
@@ -217,7 +217,7 @@ public abstract class ClientCodec<R extends ClientRequest, P extends ClientResul
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
workThread.runWork(() -> {
|
Utility.execute(() -> {
|
||||||
Traces.currentTraceid(request.traceid);
|
Traces.currentTraceid(request.traceid);
|
||||||
respFuture.completeExceptionally(t);
|
respFuture.completeExceptionally(t);
|
||||||
Traces.removeTraceid();
|
Traces.removeTraceid();
|
||||||
|
|||||||
@@ -74,7 +74,9 @@ public class ClientFuture<R extends ClientRequest, T> extends CompletableFuture<
|
|||||||
|
|
||||||
private void runTimeout() {
|
private void runTimeout() {
|
||||||
String traceid = request != null ? request.getTraceid() : null;
|
String traceid = request != null ? request.getTraceid() : null;
|
||||||
conn.removeRespFuture(request.getRequestid(), this);
|
if (request != null) {
|
||||||
|
conn.removeRespFuture(request.getRequestid(), this);
|
||||||
|
}
|
||||||
TimeoutException ex = new TimeoutException("client-request: " + request);
|
TimeoutException ex = new TimeoutException("client-request: " + request);
|
||||||
WorkThread workThread = null;
|
WorkThread workThread = null;
|
||||||
if (request != null) {
|
if (request != null) {
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ public class HttpSimpleClient extends Client<HttpSimpleConnection, HttpSimpleReq
|
|||||||
protected int writeTimeoutSeconds = 6;
|
protected int writeTimeoutSeconds = 6;
|
||||||
|
|
||||||
protected HttpSimpleClient(ExecutorService workExecutor, AsyncGroup asyncGroup) {
|
protected HttpSimpleClient(ExecutorService workExecutor, AsyncGroup asyncGroup) {
|
||||||
super("Redkale-http-client", asyncGroup, new ClientAddress(new InetSocketAddress("127.0.0.1", 0)));
|
super("Redkale-http-client", asyncGroup, new ClientAddress(new InetSocketAddress("127.0.0.1", 0)));
|
||||||
this.workExecutor = workExecutor;
|
this.workExecutor = workExecutor;
|
||||||
this.asyncGroup = asyncGroup;
|
this.asyncGroup = asyncGroup;
|
||||||
}
|
}
|
||||||
@@ -417,7 +417,7 @@ public class HttpSimpleClient extends Client<HttpSimpleConnection, HttpSimpleReq
|
|||||||
HttpResult result = this.responseResult;
|
HttpResult result = this.responseResult;
|
||||||
try {
|
try {
|
||||||
result.result(c.convertFrom(valueType, this.responseResult.getResult()));
|
result.result(c.convertFrom(valueType, this.responseResult.getResult()));
|
||||||
if (workThread != null) {
|
if (workThread != null && workThread.getState() == Thread.State.RUNNABLE) {
|
||||||
workThread.runWork(() -> {
|
workThread.runWork(() -> {
|
||||||
Traces.currentTraceid(traceid);
|
Traces.currentTraceid(traceid);
|
||||||
future.complete((HttpResult<T>) this.responseResult);
|
future.complete((HttpResult<T>) this.responseResult);
|
||||||
@@ -434,25 +434,25 @@ public class HttpSimpleClient extends Client<HttpSimpleConnection, HttpSimpleReq
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
if (workThread != null) {
|
if (workThread != null && workThread.getState() == Thread.State.RUNNABLE) {
|
||||||
Utility.execute(() -> {
|
workThread.execute(() -> {
|
||||||
Traces.currentTraceid(traceid);
|
Traces.currentTraceid(traceid);
|
||||||
future.completeExceptionally(e);
|
future.completeExceptionally(e);
|
||||||
});
|
});
|
||||||
} else if (workExecutor == null) {
|
} else if (workExecutor != null) {
|
||||||
workExecutor.execute(() -> {
|
workExecutor.execute(() -> {
|
||||||
Traces.currentTraceid(traceid);
|
Traces.currentTraceid(traceid);
|
||||||
future.completeExceptionally(e);
|
future.completeExceptionally(e);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
workThread.runWork(() -> {
|
Utility.execute(() -> {
|
||||||
Traces.currentTraceid(traceid);
|
Traces.currentTraceid(traceid);
|
||||||
future.completeExceptionally(e);
|
future.completeExceptionally(e);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (workThread != null) {
|
if (workThread != null && workThread.getState() == Thread.State.RUNNABLE) {
|
||||||
workThread.runWork(() -> {
|
workThread.runWork(() -> {
|
||||||
Traces.currentTraceid(traceid);
|
Traces.currentTraceid(traceid);
|
||||||
future.complete((HttpResult<T>) this.responseResult);
|
future.complete((HttpResult<T>) this.responseResult);
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ package org.redkale.net.http;
|
|||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.nio.charset.*;
|
import java.nio.charset.*;
|
||||||
|
import java.nio.file.Files;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.atomic.*;
|
import java.util.concurrent.atomic.*;
|
||||||
import java.util.logging.*;
|
import java.util.logging.*;
|
||||||
@@ -170,7 +171,7 @@ public final class MultiContext {
|
|||||||
}
|
}
|
||||||
boolean rs = part.save(max < 1 ? Long.MAX_VALUE : max, file);
|
boolean rs = part.save(max < 1 ? Long.MAX_VALUE : max, file);
|
||||||
if (!rs) {
|
if (!rs) {
|
||||||
file.delete();
|
Files.delete(file.toPath());
|
||||||
parent.delete();
|
parent.delete();
|
||||||
} else {
|
} else {
|
||||||
tmpfile = file;
|
tmpfile = file;
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import org.redkale.net.sncp.Sncp;
|
|||||||
import org.redkale.service.*;
|
import org.redkale.service.*;
|
||||||
import org.redkale.source.Flipper;
|
import org.redkale.source.Flipper;
|
||||||
import org.redkale.util.*;
|
import org.redkale.util.*;
|
||||||
|
import static org.redkale.util.Utility.isEmpty;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@@ -1653,17 +1654,18 @@ public final class Rest {
|
|||||||
nonblockField.set(obj, parentNonBlocking == null ? true : parentNonBlocking);
|
nonblockField.set(obj, parentNonBlocking == null ? true : parentNonBlocking);
|
||||||
return obj;
|
return obj;
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
|
//do nothing
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
final String defmodulename = getWebModuleNameLowerCase(serviceType);
|
final String defModuleName = getWebModuleNameLowerCase(serviceType);
|
||||||
final String bigmodulename = getWebModuleName(serviceType);
|
final String bigModuleName = getWebModuleName(serviceType);
|
||||||
final String catalog = controller == null ? "" : controller.catalog();
|
final String catalog = controller == null ? "" : controller.catalog();
|
||||||
if (!checkName(catalog)) {
|
if (!checkName(catalog)) {
|
||||||
throw new RestException(serviceType.getName() + " have illegal " + RestService.class.getSimpleName() + ".catalog, only 0-9 a-z A-Z _ cannot begin 0-9");
|
throw new RestException(serviceType.getName() + " have illegal " + RestService.class.getSimpleName() + ".catalog, only 0-9 a-z A-Z _ cannot begin 0-9");
|
||||||
}
|
}
|
||||||
if (!checkName(defmodulename)) {
|
if (!checkName(defModuleName)) {
|
||||||
throw new RestException(serviceType.getName() + " have illegal " + RestService.class.getSimpleName() + ".value, only 0-9 a-z A-Z _ cannot begin 0-9");
|
throw new RestException(serviceType.getName() + " have illegal " + RestService.class.getSimpleName() + ".value, only 0-9 a-z A-Z _ cannot begin 0-9");
|
||||||
}
|
}
|
||||||
ClassWriter cw = new ClassWriter(COMPUTE_FRAMES);
|
ClassWriter cw = new ClassWriter(COMPUTE_FRAMES);
|
||||||
@@ -1757,14 +1759,14 @@ public final class Rest {
|
|||||||
}
|
}
|
||||||
retvalTypes.add(rtype);
|
retvalTypes.add(rtype);
|
||||||
if (mappings.length == 0) { //没有Mapping,设置一个默认值
|
if (mappings.length == 0) { //没有Mapping,设置一个默认值
|
||||||
MappingEntry entry = new MappingEntry(serRpcOnly, methodidex, parentNonBlocking, null, bigmodulename, method);
|
MappingEntry entry = new MappingEntry(serRpcOnly, methodidex, parentNonBlocking, null, bigModuleName, method);
|
||||||
if (entrys.contains(entry)) {
|
if (entrys.contains(entry)) {
|
||||||
throw new RestException(serviceType.getName() + " on " + method.getName() + " 's mapping(" + entry.name + ") is repeat");
|
throw new RestException(serviceType.getName() + " on " + method.getName() + " 's mapping(" + entry.name + ") is repeat");
|
||||||
}
|
}
|
||||||
entrys.add(entry);
|
entrys.add(entry);
|
||||||
} else {
|
} else {
|
||||||
for (RestMapping mapping : mappings) {
|
for (RestMapping mapping : mappings) {
|
||||||
MappingEntry entry = new MappingEntry(serRpcOnly, methodidex, parentNonBlocking, mapping, defmodulename, method);
|
MappingEntry entry = new MappingEntry(serRpcOnly, methodidex, parentNonBlocking, mapping, defModuleName, method);
|
||||||
if (entrys.contains(entry)) {
|
if (entrys.contains(entry)) {
|
||||||
throw new RestException(serviceType.getName() + " on " + method.getName() + " 's mapping(" + entry.name + ") is repeat");
|
throw new RestException(serviceType.getName() + " on " + method.getName() + " 's mapping(" + entry.name + ") is repeat");
|
||||||
}
|
}
|
||||||
@@ -1793,10 +1795,10 @@ public final class Rest {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (defmodulename.isEmpty() || (!pound && entrys.size() <= 2)) {
|
if (isEmpty(defModuleName) || (!pound && entrys.size() <= 2)) {
|
||||||
Set<String> startWiths = new HashSet<>();
|
Set<String> startWiths = new HashSet<>();
|
||||||
for (MappingEntry entry : entrys) {
|
for (MappingEntry entry : entrys) {
|
||||||
String suburl = (catalog.isEmpty() ? "/" : ("/" + catalog + "/")) + (defmodulename.isEmpty() ? "" : (defmodulename + "/")) + entry.name;
|
String suburl = (isEmpty(catalog) ? "/" : ("/" + catalog + "/")) + (isEmpty(defModuleName) ? "" : (defModuleName + "/")) + entry.name;
|
||||||
if ("//".equals(suburl)) {
|
if ("//".equals(suburl)) {
|
||||||
suburl = "/";
|
suburl = "/";
|
||||||
} else if (suburl.length() > 2 && suburl.endsWith("/")) {
|
} else if (suburl.length() > 2 && suburl.endsWith("/")) {
|
||||||
@@ -1821,12 +1823,12 @@ public final class Rest {
|
|||||||
urlpath = urlpath.substring(1);
|
urlpath = urlpath.substring(1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
urlpath = (catalog.isEmpty() ? "/" : ("/" + catalog + "/")) + defmodulename + "/*";
|
urlpath = (catalog.isEmpty() ? "/" : ("/" + catalog + "/")) + defModuleName + "/*";
|
||||||
av1.visit(null, urlpath);
|
av1.visit(null, urlpath);
|
||||||
}
|
}
|
||||||
av1.visitEnd();
|
av1.visitEnd();
|
||||||
}
|
}
|
||||||
av0.visit("name", defmodulename);
|
av0.visit("name", defModuleName);
|
||||||
av0.visit("moduleid", moduleid);
|
av0.visit("moduleid", moduleid);
|
||||||
av0.visit("repair", repair);
|
av0.visit("repair", repair);
|
||||||
av0.visit("comment", comment);
|
av0.visit("comment", comment);
|
||||||
@@ -2288,12 +2290,12 @@ public final class Rest {
|
|||||||
av0.visitEnd();
|
av0.visitEnd();
|
||||||
}
|
}
|
||||||
av0 = mv.visitAnnotation(mappingDesc, true);
|
av0 = mv.visitAnnotation(mappingDesc, true);
|
||||||
String url = (catalog.isEmpty() ? "/" : ("/" + catalog + "/")) + (defmodulename.isEmpty() ? "" : (defmodulename + "/")) + entry.name + (reqpath ? "/" : "");
|
String url = (catalog.isEmpty() ? "/" : ("/" + catalog + "/")) + (defModuleName.isEmpty() ? "" : (defModuleName + "/")) + entry.name + (reqpath ? "/" : "");
|
||||||
if ("//".equals(url)) {
|
if ("//".equals(url)) {
|
||||||
url = "/";
|
url = "/";
|
||||||
}
|
}
|
||||||
av0.visit("url", url);
|
av0.visit("url", url);
|
||||||
av0.visit("name", (defmodulename.isEmpty() ? "" : (defmodulename + "_")) + entry.name);
|
av0.visit("name", (defModuleName.isEmpty() ? "" : (defModuleName + "_")) + entry.name);
|
||||||
av0.visit("example", entry.example);
|
av0.visit("example", entry.example);
|
||||||
av0.visit("rpcOnly", entry.rpcOnly);
|
av0.visit("rpcOnly", entry.rpcOnly);
|
||||||
av0.visit("auth", entry.auth);
|
av0.visit("auth", entry.auth);
|
||||||
|
|||||||
@@ -563,7 +563,7 @@ public final class EntityCache<T> {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private <V> Number getNumberResult(final Collection<T> entityList, final FilterFunc func, final Number defResult, final Class attrType, final Function<T, Number> attrFunc, final FilterNode node) {
|
private Number getNumberResult(final Collection<T> entityList, final FilterFunc func, final Number defResult, final Class attrType, final Function<T, Number> attrFunc, final FilterNode node) {
|
||||||
final Predicate<T> filter = node == null ? null : node.createPredicate(this);
|
final Predicate<T> filter = node == null ? null : node.createPredicate(this);
|
||||||
Stream<T> stream = entityList.stream();
|
Stream<T> stream = entityList.stream();
|
||||||
if (filter != null) {
|
if (filter != null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user