Skip to content

Commit a3feb6c

Browse files
committed
Move writeBinaryValue and SDK_BYTES asByteArrayUnsafe optimization to GC branch
Revert SDK_BYTES switch case to use the original writeValue(asByteBuffer()) path, matching the existing SimpleTypeJsonMarshaller.SDK_BYTES behavior. Remove writeBinaryValue from StructuredJsonGenerator and SdkJsonGenerator since it is no longer used on this branch. The writeBinaryValue optimization (bypassing ByteBuffer allocation and copyBytesFrom) will be introduced on alexwoo/json_huge_gc_opt alongside the other allocation-reduction changes.
1 parent 58a9d99 commit a3feb6c

3 files changed

Lines changed: 1 addition & 25 deletions

File tree

core/protocols/aws-json-protocol/src/main/java/software/amazon/awssdk/protocols/json/SdkJsonGenerator.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -206,16 +206,6 @@ public StructuredJsonGenerator writeValue(ByteBuffer bytes) {
206206
return this;
207207
}
208208

209-
@Override
210-
public StructuredJsonGenerator writeBinaryValue(byte[] bytes) {
211-
try {
212-
generator.writeBinary(bytes);
213-
} catch (IOException e) {
214-
throw new JsonGenerationException(e);
215-
}
216-
return this;
217-
}
218-
219209
@Override
220210
//TODO: This date formatting is coupled to AWS's format. Should generalize it
221211
public StructuredJsonGenerator writeValue(Instant instant) {

core/protocols/aws-json-protocol/src/main/java/software/amazon/awssdk/protocols/json/StructuredJsonGenerator.java

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,6 @@ public StructuredJsonGenerator writeValue(ByteBuffer bytes) {
102102
return this;
103103
}
104104

105-
@Override
106-
public StructuredJsonGenerator writeBinaryValue(byte[] bytes) {
107-
return this;
108-
}
109-
110105
@Override
111106
public StructuredJsonGenerator writeValue(Instant instant) {
112107
return this;
@@ -174,15 +169,6 @@ default StructuredJsonGenerator writeValue(byte val) {
174169

175170
StructuredJsonGenerator writeValue(ByteBuffer bytes);
176171

177-
/**
178-
* Writes binary data directly from a byte array, avoiding the overhead of wrapping in a
179-
* {@link ByteBuffer}. The default implementation wraps the array and delegates to
180-
* {@link #writeValue(ByteBuffer)}.
181-
*/
182-
default StructuredJsonGenerator writeBinaryValue(byte[] bytes) {
183-
return writeValue(ByteBuffer.wrap(bytes));
184-
}
185-
186172
StructuredJsonGenerator writeValue(Instant instant);
187173

188174
StructuredJsonGenerator writeNumber(String number);

core/protocols/aws-json-protocol/src/main/java/software/amazon/awssdk/protocols/json/internal/marshall/JsonProtocolMarshaller.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ private void marshallPayloadField(SdkField<?> field, Object val) {
389389
break;
390390
case SDK_BYTES:
391391
gen.writeFieldName(fieldName);
392-
gen.writeBinaryValue(((SdkBytes) val).asByteArrayUnsafe());
392+
gen.writeValue(((SdkBytes) val).asByteBuffer());
393393
break;
394394
case SDK_POJO:
395395
SimpleTypeJsonMarshaller.SDK_POJO.marshall((SdkPojo) val, marshallerContext,

0 commit comments

Comments
 (0)