This commit is contained in:
@@ -44,7 +44,7 @@ public final class BsonConvert extends Convert<BsonReader, BsonWriter> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public BsonWriter pollBsonWriter() {
|
public BsonWriter pollBsonWriter() {
|
||||||
final BsonWriter out = writerPool.poll();
|
final BsonWriter out = writerPool.get();
|
||||||
out.setTiny(tiny);
|
out.setTiny(tiny);
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
@@ -54,7 +54,7 @@ public final class BsonConvert extends Convert<BsonReader, BsonWriter> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public BsonReader pollBsonReader() {
|
public BsonReader pollBsonReader() {
|
||||||
return readerPool.poll();
|
return readerPool.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void offerBsonReader(BsonReader in) {
|
public void offerBsonReader(BsonReader in) {
|
||||||
@@ -68,7 +68,7 @@ public final class BsonConvert extends Convert<BsonReader, BsonWriter> {
|
|||||||
|
|
||||||
public <T> T convertFrom(final Type type, final byte[] bytes, int start, int len) {
|
public <T> T convertFrom(final Type type, final byte[] bytes, int start, int len) {
|
||||||
if (type == null) return null;
|
if (type == null) return null;
|
||||||
final BsonReader in = readerPool.poll();
|
final BsonReader in = readerPool.get();
|
||||||
in.setBytes(bytes, start, len);
|
in.setBytes(bytes, start, len);
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
T rs = (T) factory.loadDecoder(type).convertFrom(in);
|
T rs = (T) factory.loadDecoder(type).convertFrom(in);
|
||||||
@@ -85,7 +85,7 @@ public final class BsonConvert extends Convert<BsonReader, BsonWriter> {
|
|||||||
|
|
||||||
public byte[] convertTo(final Type type, Object value) {
|
public byte[] convertTo(final Type type, Object value) {
|
||||||
if (type == null) return null;
|
if (type == null) return null;
|
||||||
final BsonWriter out = writerPool.poll();
|
final BsonWriter out = writerPool.get();
|
||||||
out.setTiny(tiny);
|
out.setTiny(tiny);
|
||||||
factory.loadEncoder(type).convertTo(out, value);
|
factory.loadEncoder(type).convertTo(out, value);
|
||||||
byte[] result = out.toArray();
|
byte[] result = out.toArray();
|
||||||
@@ -108,7 +108,7 @@ public final class BsonConvert extends Convert<BsonReader, BsonWriter> {
|
|||||||
|
|
||||||
public byte[] convertTo(Object value) {
|
public byte[] convertTo(Object value) {
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
final BsonWriter out = writerPool.poll();
|
final BsonWriter out = writerPool.get();
|
||||||
out.setTiny(tiny);
|
out.setTiny(tiny);
|
||||||
out.writeNull();
|
out.writeNull();
|
||||||
byte[] result = out.toArray();
|
byte[] result = out.toArray();
|
||||||
@@ -120,7 +120,7 @@ public final class BsonConvert extends Convert<BsonReader, BsonWriter> {
|
|||||||
|
|
||||||
public ByteBuffer convertToBuffer(final Type type, Object value) {
|
public ByteBuffer convertToBuffer(final Type type, Object value) {
|
||||||
if (type == null) return null;
|
if (type == null) return null;
|
||||||
final BsonWriter out = writerPool.poll();
|
final BsonWriter out = writerPool.get();
|
||||||
out.setTiny(tiny);
|
out.setTiny(tiny);
|
||||||
factory.loadEncoder(type).convertTo(out, value);
|
factory.loadEncoder(type).convertTo(out, value);
|
||||||
ByteBuffer result = out.toBuffer();
|
ByteBuffer result = out.toBuffer();
|
||||||
@@ -130,7 +130,7 @@ public final class BsonConvert extends Convert<BsonReader, BsonWriter> {
|
|||||||
|
|
||||||
public ByteBuffer convertToBuffer(Object value) {
|
public ByteBuffer convertToBuffer(Object value) {
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
final BsonWriter out = writerPool.poll();
|
final BsonWriter out = writerPool.get();
|
||||||
out.setTiny(tiny);
|
out.setTiny(tiny);
|
||||||
out.writeNull();
|
out.writeNull();
|
||||||
ByteBuffer result = out.toBuffer();
|
ByteBuffer result = out.toBuffer();
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ public final class JsonConvert extends Convert<JsonReader, JsonWriter> {
|
|||||||
|
|
||||||
public <T> T convertFrom(final Type type, final char[] text, int start, int len) {
|
public <T> T convertFrom(final Type type, final char[] text, int start, int len) {
|
||||||
if (text == null || type == null) return null;
|
if (text == null || type == null) return null;
|
||||||
final JsonReader in = readerPool.poll();
|
final JsonReader in = readerPool.get();
|
||||||
in.setText(text, start, len);
|
in.setText(text, start, len);
|
||||||
T rs = (T) factory.loadDecoder(type).convertFrom(in);
|
T rs = (T) factory.loadDecoder(type).convertFrom(in);
|
||||||
readerPool.offer(in);
|
readerPool.offer(in);
|
||||||
@@ -57,7 +57,7 @@ public final class JsonConvert extends Convert<JsonReader, JsonWriter> {
|
|||||||
public String convertTo(final Type type, Object value) {
|
public String convertTo(final Type type, Object value) {
|
||||||
if (type == null) return null;
|
if (type == null) return null;
|
||||||
if (value == null) return "null";
|
if (value == null) return "null";
|
||||||
final JsonWriter out = writerPool.poll();
|
final JsonWriter out = writerPool.get();
|
||||||
out.setTiny(tiny);
|
out.setTiny(tiny);
|
||||||
factory.loadEncoder(type).convertTo(out, value);
|
factory.loadEncoder(type).convertTo(out, value);
|
||||||
String result = out.toString();
|
String result = out.toString();
|
||||||
@@ -78,7 +78,7 @@ public final class JsonConvert extends Convert<JsonReader, JsonWriter> {
|
|||||||
public byte[] convertToUTF8Bytes(final Type type, Object value) {
|
public byte[] convertToUTF8Bytes(final Type type, Object value) {
|
||||||
if (type == null) return null;
|
if (type == null) return null;
|
||||||
if (value == null) return new byte[]{110, 117, 108, 108};
|
if (value == null) return new byte[]{110, 117, 108, 108};
|
||||||
final JsonWriter out = writerPool.poll();
|
final JsonWriter out = writerPool.get();
|
||||||
out.setTiny(tiny);
|
out.setTiny(tiny);
|
||||||
factory.loadEncoder(type).convertTo(out, value);
|
factory.loadEncoder(type).convertTo(out, value);
|
||||||
byte[] result = out.toUTF8Bytes();
|
byte[] result = out.toUTF8Bytes();
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ public final class ObjectPool<T> {
|
|||||||
this.creator = creator;
|
this.creator = creator;
|
||||||
}
|
}
|
||||||
|
|
||||||
public T poll() {
|
public T get() {
|
||||||
T result = queue.poll();
|
T result = queue.poll();
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
if (creatCounter != null) creatCounter.incrementAndGet();
|
if (creatCounter != null) creatCounter.incrementAndGet();
|
||||||
|
|||||||
Reference in New Issue
Block a user