This commit is contained in:
地平线
2015-11-06 13:51:56 +08:00
parent 3df5085134
commit 6a8b0c2671
3 changed files with 11 additions and 11 deletions

View File

@@ -44,7 +44,7 @@ public final class BsonConvert extends Convert<BsonReader, BsonWriter> {
}
public BsonWriter pollBsonWriter() {
final BsonWriter out = writerPool.poll();
final BsonWriter out = writerPool.get();
out.setTiny(tiny);
return out;
}
@@ -54,7 +54,7 @@ public final class BsonConvert extends Convert<BsonReader, BsonWriter> {
}
public BsonReader pollBsonReader() {
return readerPool.poll();
return readerPool.get();
}
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) {
if (type == null) return null;
final BsonReader in = readerPool.poll();
final BsonReader in = readerPool.get();
in.setBytes(bytes, start, len);
@SuppressWarnings("unchecked")
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) {
if (type == null) return null;
final BsonWriter out = writerPool.poll();
final BsonWriter out = writerPool.get();
out.setTiny(tiny);
factory.loadEncoder(type).convertTo(out, value);
byte[] result = out.toArray();
@@ -108,7 +108,7 @@ public final class BsonConvert extends Convert<BsonReader, BsonWriter> {
public byte[] convertTo(Object value) {
if (value == null) {
final BsonWriter out = writerPool.poll();
final BsonWriter out = writerPool.get();
out.setTiny(tiny);
out.writeNull();
byte[] result = out.toArray();
@@ -120,7 +120,7 @@ public final class BsonConvert extends Convert<BsonReader, BsonWriter> {
public ByteBuffer convertToBuffer(final Type type, Object value) {
if (type == null) return null;
final BsonWriter out = writerPool.poll();
final BsonWriter out = writerPool.get();
out.setTiny(tiny);
factory.loadEncoder(type).convertTo(out, value);
ByteBuffer result = out.toBuffer();
@@ -130,7 +130,7 @@ public final class BsonConvert extends Convert<BsonReader, BsonWriter> {
public ByteBuffer convertToBuffer(Object value) {
if (value == null) {
final BsonWriter out = writerPool.poll();
final BsonWriter out = writerPool.get();
out.setTiny(tiny);
out.writeNull();
ByteBuffer result = out.toBuffer();

View File

@@ -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) {
if (text == null || type == null) return null;
final JsonReader in = readerPool.poll();
final JsonReader in = readerPool.get();
in.setText(text, start, len);
T rs = (T) factory.loadDecoder(type).convertFrom(in);
readerPool.offer(in);
@@ -57,7 +57,7 @@ public final class JsonConvert extends Convert<JsonReader, JsonWriter> {
public String convertTo(final Type type, Object value) {
if (type == null) return null;
if (value == null) return "null";
final JsonWriter out = writerPool.poll();
final JsonWriter out = writerPool.get();
out.setTiny(tiny);
factory.loadEncoder(type).convertTo(out, value);
String result = out.toString();
@@ -78,7 +78,7 @@ public final class JsonConvert extends Convert<JsonReader, JsonWriter> {
public byte[] convertToUTF8Bytes(final Type type, Object value) {
if (type == null) return null;
if (value == null) return new byte[]{110, 117, 108, 108};
final JsonWriter out = writerPool.poll();
final JsonWriter out = writerPool.get();
out.setTiny(tiny);
factory.loadEncoder(type).convertTo(out, value);
byte[] result = out.toUTF8Bytes();

View File

@@ -63,7 +63,7 @@ public final class ObjectPool<T> {
this.creator = creator;
}
public T poll() {
public T get() {
T result = queue.poll();
if (result == null) {
if (creatCounter != null) creatCounter.incrementAndGet();