This commit is contained in:
redkale
2024-10-20 01:00:41 +08:00
parent a19b083478
commit c2a923619e
3 changed files with 15 additions and 14 deletions

View File

@@ -84,11 +84,11 @@ public abstract class Writer {
return this;
}
protected final boolean tiny() {
public final boolean tiny() {
return features > 0 && ConvertFactory.checkTinyFeature(features);
}
protected final boolean nullable() {
public final boolean nullable() {
return features > 0 && ConvertFactory.checkNullableFeature(features);
}

View File

@@ -53,14 +53,14 @@ public class ProtobufBytesWriter extends ProtobufWriter { // 存在child情况
@Override
protected boolean recycle() {
super.recycle();
if (this.delegate != null && this.pool != null) {
if (this.delegate != null && this.pool != null && this.parent == null) {
ProtobufWriter s;
ProtobufWriter p = this.delegate;
do {
s = p;
p = p.parent;
offerPool(s);
} while (p != this);
} while (p != this && p != null);
}
this.delegate = null;
if (this.content.length > RESET_MAX_SIZE) {
@@ -92,6 +92,11 @@ public class ProtobufBytesWriter extends ProtobufWriter { // 存在child情况
this.child = result;
delegate = result;
} else {
if (delegate.child != null) {
while (delegate.child != null) {
delegate = delegate.child;
}
}
result.parent = delegate;
delegate.child = result;
delegate = result;