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

Fix get schema version in HttpLookupService. #6193

Merged
merged 7 commits into from
Feb 7, 2020

Conversation

codelipenghui
Copy link
Contributor

Motivation

Fix get schema version in HttpLookupService. The com.yahoo.sketches.Util.bytesToLong method need to flip the byte[]. Otherwise, will get a wrong long value. So use ByteBuffer to convert byte[] version to long.

This issue will happens when users use http protocol client and multiple version schemas.

Verifying this change

New tests added for HttpLookupService and BinaryLookupService.

Does this pull request potentially affect one of the following parts:

If yes was chosen, please highlight the changes

  • Dependencies (does it add or upgrade a dependency): (no)
  • The public API: (no)
  • The schema: (yes)
  • The default values of configurations: (no)
  • The wire protocol: (no)
  • The rest endpoints: (no)
  • The admin cli options: (no)
  • Anything that affects deployment: (no)

Documentation

  • Does this pull request introduce a new feature? (no)

@@ -176,5 +176,12 @@ public void close() throws Exception {
httpClient.close();
}

private long bytesToLong(byte[] bytes) {
schemaVersionConvertBuffer.clear();
schemaVersionConvertBuffer.put(bytes, 0, bytes.length);
Copy link
Member

Choose a reason for hiding this comment

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

hmm. this would result in copying memory. and it is not thread-safe.

I would suggest just using ByteBuffer.wrap(bytes) to get a ByteBuffer and then read the long number.

@codelipenghui
Copy link
Contributor Author

@sijie I have addressed your comment, please take a look, thanks.

@sijie
Copy link
Member

sijie commented Feb 5, 2020

/pulsarbot run-failure-checks

1 similar comment
@sijie
Copy link
Member

sijie commented Feb 5, 2020

/pulsarbot run-failure-checks

@sijie sijie closed this Feb 5, 2020
@sijie sijie reopened this Feb 5, 2020
@sijie
Copy link
Member

sijie commented Feb 5, 2020

/pulsarbot run-failure-checks

1 similar comment
@codelipenghui
Copy link
Contributor Author

/pulsarbot run-failure-checks

@skyrocknroll
Copy link
Contributor

/pulsarbot run-failure-checks

@sijie sijie merged commit 44dd412 into apache:master Feb 7, 2020
tuteng pushed a commit to AmateurEvents/pulsar that referenced this pull request Feb 23, 2020
### Motivation

Fix get schema version in HttpLookupService.  The com.yahoo.sketches.Util.bytesToLong method need to flip the byte[]. Otherwise, will get a wrong long value. So use ByteBuffer to convert byte[] version to long. 

This issue will happens when users use http protocol client and multiple version schemas.

### Verifying this change

New tests added for HttpLookupService and BinaryLookupService.
tuteng pushed a commit to AmateurEvents/pulsar that referenced this pull request Mar 21, 2020
### Motivation

Fix get schema version in HttpLookupService.  The com.yahoo.sketches.Util.bytesToLong method need to flip the byte[]. Otherwise, will get a wrong long value. So use ByteBuffer to convert byte[] version to long. 

This issue will happens when users use http protocol client and multiple version schemas.

### Verifying this change

New tests added for HttpLookupService and BinaryLookupService.


(cherry picked from commit 44dd412)
tuteng pushed a commit that referenced this pull request Apr 13, 2020
### Motivation

Fix get schema version in HttpLookupService.  The com.yahoo.sketches.Util.bytesToLong method need to flip the byte[]. Otherwise, will get a wrong long value. So use ByteBuffer to convert byte[] version to long. 

This issue will happens when users use http protocol client and multiple version schemas.

### Verifying this change

New tests added for HttpLookupService and BinaryLookupService.


(cherry picked from commit 44dd412)
jiazhai pushed a commit to jiazhai/pulsar that referenced this pull request May 18, 2020
### Motivation

Fix get schema version in HttpLookupService.  The com.yahoo.sketches.Util.bytesToLong method need to flip the byte[]. Otherwise, will get a wrong long value. So use ByteBuffer to convert byte[] version to long.

This issue will happens when users use http protocol client and multiple version schemas.

### Verifying this change

New tests added for HttpLookupService and BinaryLookupService.

(cherry picked from commit 44dd412)
huangdx0726 pushed a commit to huangdx0726/pulsar that referenced this pull request Aug 24, 2020
### Motivation

Fix get schema version in HttpLookupService.  The com.yahoo.sketches.Util.bytesToLong method need to flip the byte[]. Otherwise, will get a wrong long value. So use ByteBuffer to convert byte[] version to long. 

This issue will happens when users use http protocol client and multiple version schemas.

### Verifying this change

New tests added for HttpLookupService and BinaryLookupService.
@codelipenghui codelipenghui deleted the fix_get_schema_by_version branch May 19, 2021 05:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants