Skip to content

[Java] sbe 1.16.3 generates noisy Java code #766

Closed
@hrstoyanov

Description

@hrstoyanov

Please cleanup the SBE generated Java code. Here is SBE-generated snippet of code:

public SetFileAttributesEncoder putPath(final DirectBuffer src, final int srcOffset, final int length)
    {
        if (length > 1073741824)
        {
            throw new IllegalStateException("length > maxValue for type: " + length);
        }

        final int headerLength = 4;
        final int limit = parentMessage.limit();
        parentMessage.limit(limit + headerLength + length);
        buffer.putInt(limit, (int)length, java.nio.ByteOrder.LITTLE_ENDIAN);
        buffer.putBytes(limit + headerLength, src, srcOffset, length);

        return this;
    }

To which the Java compiler says:

..../hasql/message/src/main/java/dynamind/hasql/message/SetFileAttributesEncoder.java:215: warning: [cast] redundant cast to int
        buffer.putInt(limit, (int)length, java.nio.ByteOrder.LITTLE_ENDIAN);

This is very irritating because it is outside the developer's control, pollutes reports and CI builds.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions