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

A bug in ByteArrayInputStream #34

Closed
chenyun opened this issue Mar 30, 2015 · 4 comments
Closed

A bug in ByteArrayInputStream #34

chenyun opened this issue Mar 30, 2015 · 4 comments

Comments

@chenyun
Copy link
Contributor

chenyun commented Mar 30, 2015

I think length = bytes.length >> 2 should be length = bytes.length >> 1

    private byte[] reverse(byte[] bytes) {
        for (int i = 0, length = bytes.length >> 2; i <= length; i++) {
            int j = bytes.length - 1 - i;
            byte t = bytes[i];
            bytes[i] = bytes[j];
            bytes[j] = t;
        }
        return bytes;
    }
@shyiko shyiko changed the title A bug inByteArrayInputStream A bug in ByteArrayInputStream Mar 30, 2015
@shyiko shyiko closed this as completed in f57fd59 Mar 30, 2015
@shyiko
Copy link
Owner

shyiko commented Mar 30, 2015

That's insane! Thanks a lot for reporting.

@shyiko
Copy link
Owner

shyiko commented Mar 30, 2015

Incorporated in 0.1.3 (which should become available through Maven Central in the next 24h).

@chenyun
Copy link
Contributor Author

chenyun commented Apr 3, 2015

Hi @shyiko , I have a question: what is the purpose of EventDeserializer.Deserializer and EventDataWrapper?

    private void afterEventDataDeserializerSet(EventType eventType) {
        if (eventType == null || eventType == EventType.TABLE_MAP) {
            EventDataDeserializer eventDataDeserializer = getEventDataDeserializer(EventType.TABLE_MAP);
            if (eventDataDeserializer.getClass() != TableMapEventDataDeserializer.class &&
                eventDataDeserializer.getClass() != EventDataWrapper.Deserializer.class) {
                tableMapEventDataDeserializer = new EventDataWrapper.Deserializer(
                    new TableMapEventDataDeserializer(), eventDataDeserializer);
            } else {
                tableMapEventDataDeserializer = null;
            }
        }

why do you pay special care to tableMapEventDataDeserializer in this method?

@shyiko
Copy link
Owner

shyiko commented Apr 3, 2015

@chenyun TABLE_MAP and ROTATE events are used internally by EventDeserializer/BinaryLogClient and thus are required to be deserialized in a specific way regardless whether user specified custom deserializer or not. More on that #29 and #28.

misselvexu pushed a commit to misselvexu/mysql-binlog-connector-java that referenced this issue Jul 5, 2021
…tearrayinputstream

Optimize read operation on ByteArrayInputStream
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants