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

TreeMap encoding Issue #321

Closed
riadmaouchi opened this issue Jan 10, 2017 · 6 comments
Closed

TreeMap encoding Issue #321

riadmaouchi opened this issue Jan 10, 2017 · 6 comments

Comments

@riadmaouchi
Copy link

The wire serialization fail for TreeMap (as object field).

It throws a runtime exception:

java.lang.ClassCastException: java.util.TreeMap cannot be cast to java.util.function.Supplier

This not happened for SortedMap or NavigableMap

@peter-lawrey
Copy link
Member

Can you provide a simple unit test to demonstrate this, and we will fix it?

@riadmaouchi
Copy link
Author

Thank you for your feedback.

private interface Service {
        void onEventWithTreeMap(EventWithTreeMap event);

        void onEventWithSortedMap(EventWithSortedMap event);
}
private static class EventWithSortedMap extends AbstractMarshallable {
        final SortedMap<String, String> sortedMap;

        private EventWithSortedMap(SortedMap<String, String> sortedMap) {
            this.sortedMap = sortedMap;
        }
}

Please find below a success test using sorted map in event

    // Given
    ChronicleQueue chronicleQueue = SingleChronicleQueueBuilder.binary(eventQueuePath).build();
    final Service service = chronicleQueue.acquireAppender()
            .methodWriter(Service.class);

    // When
    service.onEventWithSortedMap(new EventWithSortedMap(new TreeMap<>()));

    final MethodReader reader = chronicleQueue.createTailer()
            .methodReader(serviceImpl);

    // Then
    assertThat(reader.readOne()).isTrue();

Please find below a failing test using tree map in event

private static class EventWithTreeMap extends AbstractMarshallable {
        final TreeMap<String, String> treeMap;

        private EventWithTreeMap(TreeMap<String, String> treeMap) {
            this.treeMap = treeMap;
        }
}
        // Given
        ChronicleQueue chronicleQueue = SingleChronicleQueueBuilder.binary(eventQueuePath).build();
        final Service service = chronicleQueue.acquireAppender()
                .methodWriter(Service.class);

        // When
        service.onEventWithTreeMap(new EventWithTreeMap(new TreeMap<>()));

        final MethodReader reader = chronicleQueue.createTailer()
                .methodReader(serviceImpl);

        // Then
        assertThat(reader.readOne()).isTrue();

@peter-lawrey
Copy link
Member

peter-lawrey commented Jan 10, 2017 via email

@peter-lawrey
Copy link
Member

peter-lawrey commented Jan 10, 2017 via email

@scottkidder
Copy link
Contributor

This can be closed as it appears the issue was fixed in OpenHFT/Chronicle-Wire@c91e7cf

@dpisklov
Copy link
Contributor

Fixed

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

4 participants