Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

THRIFT-5696: Allow custom TConfiguration for TByteBuffer.java #2772

Merged
merged 1 commit into from Apr 6, 2023

Conversation

rizaon
Copy link
Contributor

@rizaon rizaon commented Apr 5, 2023

Client: java

TByteBuffer.java does not allow passing custom TConfiguration into constructor

public TByteBuffer(ByteBuffer byteBuffer) throws TTransportException {
super(new TConfiguration());
this.byteBuffer = byteBuffer;
updateKnownMessageSize(byteBuffer.capacity());
}

Default TConfiguration limit message size is 100MB maximum. TByteBuffer initialization will fail with "MaxMessageSize reached" error for ByteBuffer longer than 100MB.

org.apache.thrift.transport.TTransportException: MaxMessageSize reached
	at org.apache.thrift.transport.TEndpointTransport.resetConsumedMessageSize(TEndpointTransport.java:58)
	at org.apache.thrift.transport.TEndpointTransport.updateKnownMessageSize(TEndpointTransport.java:71)
	at org.apache.thrift.transport.TByteBuffer.<init>(TByteBuffer.java:24) 

This PR adds one more constructor in TByteBuffer.java that accept custom TConfiguration.

  • Did you create an Apache Jira ticket? (Request account here, not required for trivial changes)
  • If a ticket exists: Does your pull request title follow the pattern "THRIFT-NNNN: describe my issue"?
  • Did you squash your changes to a single commit? (not required, but preferred)
  • Did you do your best to avoid breaking changes? If one was needed, did you label the Jira ticket with "Breaking-Change"?
  • If your change does not involve any code, include [skip ci] anywhere in the commit message to free up build resources.

Copy link
Member

@fishy fishy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the patch! Looks good to me, I'll wait for the tests to pass and also to see if others have objections on it.

// Test that TByteBuffer init fail with small max message size.
final TConfiguration configSmall =
new TConfiguration(
4, TConfiguration.DEFAULT_MAX_FRAME_SIZE, TConfiguration.DEFAULT_RECURSION_DEPTH);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if we have a java style guide or something but this style looks weird to me, but that might be just me (as I don't write java nowadays).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there is checkstyle built in the gradle script. This pass gradle :spotlessApply.

@rizaon
Copy link
Contributor Author

rizaon commented Apr 6, 2023

@fishy The check failure in Build / lib-go (1.19) does not seem to be related with this patch.
Can we have another try running the checks?

@fishy
Copy link
Member

fishy commented Apr 6, 2023

@fishy The check failure in Build / lib-go (1.19) does not seem to be related with this patch. Can we have another try running the checks?

that's unrelated and I already fixed it, you can either rebase your branch on top of latest master to retry, or just ignore it.

@fishy fishy merged commit cb60265 into apache:master Apr 6, 2023
9 of 10 checks passed
@rizaon
Copy link
Contributor Author

rizaon commented Apr 6, 2023

Thank you for accepting this PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants