Skip to content

ResourceFingerprintVisitor fails to account for integer values #3616

@lmsurpre

Description

@lmsurpre

Describe the bug
I found that the ResourceFingerprintVisitor is failing to add integer values to its digest.

Environment
main

To Reproduce

    @Test
    public void testUnequalResources_intVals() throws Exception {
        Patient patient = TestUtil.getMinimalResource(Patient.class).toBuilder()
                .multipleBirth(1)
                .build();

        ResourceFingerprintVisitor resourceFingerprintVisitor = new ResourceFingerprintVisitor();
        patient.accept(resourceFingerprintVisitor);
        SaltHash baseline = resourceFingerprintVisitor.getSaltAndHash();

        patient = patient.toBuilder()
                .multipleBirth(2)
                .build();
        resourceFingerprintVisitor = new ResourceFingerprintVisitor(baseline);
        patient.accept(resourceFingerprintVisitor);
        assertNotEquals(resourceFingerprintVisitor.getSaltAndHash(), baseline);
    }

Expected behavior
the test should succeed

Additional context
does the ByteBuffer need to get flipped before we add it to the digest?

    @Override
    public void visit(java.lang.String elementName, java.lang.Integer value) {
        ByteBuffer bb = ByteBuffer.allocate(4);
        bb.putInt(value);
        // flip here?
        digest.update(bb);
    }

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions