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

Incorrect assumption that non-Marshallable Comparables are scalars #751

Closed
alamar opened this issue Oct 19, 2023 · 3 comments
Closed

Incorrect assumption that non-Marshallable Comparables are scalars #751

alamar opened this issue Oct 19, 2023 · 3 comments

Comments

@alamar
Copy link
Contributor

alamar commented Oct 19, 2023

At Wires.java:1120

            if (Comparable.class.isAssignableFrom(aClass))
                return ANY_SCALAR;

In practice, two POJOs may be Comparable.

@alamar
Copy link
Contributor Author

alamar commented Oct 19, 2023

public class Issue751Test extends WireTestCommon {

    public static class One extends SelfDescribingMarshallable {
        Comparable<?> text;

        public One(Comparable<?> text) {
            this.text = text;
        }
    }

    public static class Two implements Comparable<Two> {
        Comparable<?> text;

        public Two(Comparable<?> text) {
            this.text = text;
        }

        @Override
        public int compareTo(@NotNull Issue751Test.Two o) {
            return text.hashCode() - o.text.hashCode();
        }
    }

    public static class Three extends SelfDescribingMarshallable {
        private One one;
        private Two two;

        public Three(One one, Two two) {
            this.one = one;
            this.two = two;
        }
    }

    @Test
    public void comparableField() {
        Wire wire = new YamlWire(Bytes.allocateElasticOnHeap());
        wire.write("first").object(new Three(
                new One("hello"), new Two(42)));

        System.err.println(wire.read("first").object());
    }
}

reproducer

@alamar
Copy link
Contributor Author

alamar commented Dec 11, 2023

Not a problem in practice since class should implement Marshallable/Serializable as well.
Correctly handling raw classes is a goodwill of Wire, and no behavior change is likely possible or needed.

RobAustin added a commit that referenced this issue Dec 19, 2023
* Enable tests for Zing.

TriviallyCopyable

* Bring Event.updateEvent back.

* Fix test.

* Updating to bom version 2.25ea1

* [maven-release-plugin] prepare release chronicle-wire-2.25ea1

* [maven-release-plugin] prepare for next development iteration

* Reverting back to bom version 2.25ea-SNAPSHOT

* Add tests to show expected behaviour for empty documents (#783)

* Add tests to show expected behaviour for empty documents

* Add new lines

* MarshallableOutBuilderTest use ephemeral ports for test

* Fix multiple and missing new lines (#786)

* Fix multiple and missing new lines

* Fix multiple and missing new lines

* Add test for Comparable Marshallable - closes #751

* Updating to bom version 2.25ea5

* [maven-release-plugin] prepare release chronicle-wire-2.25ea2

* [maven-release-plugin] prepare for next development iteration

* Reverting back to bom version 2.25ea-SNAPSHOT

* Updating to bom version 2.25ea6

* [maven-release-plugin] prepare release chronicle-wire-2.25ea3

* [maven-release-plugin] prepare for next development iteration

* Reverting back to bom version 2.25ea-SNAPSHOT

---------

Co-authored-by: yevgenp <yevgenp@users.noreply.github.com>
Co-authored-by: yevgen.pavlenko <yevgen.pavlenko@chronicle.software>
Co-authored-by: hft-team-city <teamcity@chronicle.software>
Co-authored-by: Peter Lawrey <peter.lawrey@chronicle.software>
Co-authored-by: Tom Dellmann <tom.dellmann@chronicle.software>
Co-authored-by: Ilya Kaznacheev <ilya.kaznacheev@chronicle.software>
@hft-team-city
Copy link
Collaborator

Released in Chronicle-Wire-2.25ea2, BOM-2.25ea10

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