修复ArrayEncoder并发下componentEncoder偶尔为null的bug
This commit is contained in:
@@ -48,6 +48,9 @@ public class ArrayEncoder<T> implements Encodeable<Writer, T[]> {
|
||||
}
|
||||
factory.register(type, this);
|
||||
this.componentEncoder = factory.loadEncoder(this.componentType);
|
||||
if (componentEncoder == null) {
|
||||
throw new ConvertException("ArrayEncoder init componentEncoder error, componentType = " + this.componentType);
|
||||
}
|
||||
this.anyEncoder = factory.getAnyEncoder();
|
||||
this.subTypeFinal = (this.componentType instanceof Class) && Modifier.isFinal(((Class) this.componentType).getModifiers());
|
||||
} finally {
|
||||
@@ -84,13 +87,16 @@ public class ArrayEncoder<T> implements Encodeable<Writer, T[]> {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
itemEncoder = this.componentEncoder;
|
||||
}
|
||||
}
|
||||
if (subTypeFinal) {
|
||||
if (out.writeArrayB(value.length, this, itemEncoder, value) < 0) {
|
||||
for (int i = 0;; i++) {
|
||||
writeMemberValue(out, member, itemEncoder, value[i], i);
|
||||
if (i == iMax) break;
|
||||
if (i == iMax) {
|
||||
break;
|
||||
}
|
||||
out.writeArrayMark();
|
||||
}
|
||||
}
|
||||
@@ -100,7 +106,9 @@ public class ArrayEncoder<T> implements Encodeable<Writer, T[]> {
|
||||
for (int i = 0;; i++) {
|
||||
Object v = value[i];
|
||||
writeMemberValue(out, member, ((v != null && (v.getClass() == comp || out.specify() == comp)) ? itemEncoder : anyEncoder), v, i);
|
||||
if (i == iMax) break;
|
||||
if (i == iMax) {
|
||||
break;
|
||||
}
|
||||
out.writeArrayMark();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,14 +5,13 @@
|
||||
*/
|
||||
package org.redkale.net.http;
|
||||
|
||||
import org.redkale.annotation.ConstructorParameters;
|
||||
import org.redkale.asm.MethodDebugVisitor;
|
||||
import java.nio.channels.CompletionHandler;
|
||||
import java.security.*;
|
||||
import java.util.concurrent.*;
|
||||
import org.redkale.asm.*;
|
||||
import java.security.SecureRandom;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import org.redkale.annotation.ConstructorParameters;
|
||||
import static org.redkale.asm.Opcodes.*;
|
||||
import org.redkale.net.*;
|
||||
import org.redkale.asm.*;
|
||||
import org.redkale.net.Context;
|
||||
import org.redkale.util.*;
|
||||
|
||||
/**
|
||||
@@ -39,6 +38,7 @@ public class HttpContext extends Context {
|
||||
|
||||
protected final AnyValue rpcAuthenticatorConfig;
|
||||
|
||||
//所有Servlet方法都不需要读取http-header,lazyHeaders=true
|
||||
protected boolean lazyHeaders; //存在动态改值
|
||||
|
||||
// protected RequestURINode[] uriCacheNodes;
|
||||
|
||||
@@ -59,9 +59,15 @@ public final class ByteArray implements ByteTuple {
|
||||
*/
|
||||
public OutputStream newOutputStream() {
|
||||
return new OutputStream() {
|
||||
|
||||
@Override
|
||||
public void write(int b) throws IOException {
|
||||
ByteArray.this.put((byte) b);
|
||||
put((byte) b);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(byte b[], int off, int len) throws IOException {
|
||||
put(b, off, len);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user