Skip to content

Slow or throwing Entity.toString() and Entity.Id.toString() make YOJ calls slow or failing #143

@nvamelichev

Description

@nvamelichev

...even if tech.ydb.yoj.repository.db logger level is higher than DEBUG, and typically none of the transaction statements ever need to be logged.

You can wreak havoc with a simple entity like this:

@Value
@EqualsAndHashCode(doNotUseGetters = true)
public class BadToStringEntity implements Entity<BadToStringEntity> {
    @NonNull
    Id id;

    @Nullable
    Duration toStringDuration;

    @SuppressWarnings("unused")
    public Duration getToStringDuration() {
        // Mwahahahahahah #1: NPE if a nullable field is null
        Objects.requireNonNull(toStringDuration, "toStringDuration");
        // Mwahahahahahah #2: Delay if a nullable field is not null
        Uninterruptibles.sleepUninterruptibly(toStringDuration);

        return toStringDuration;
    }

    public record Id(@NonNull String id) implements Entity.Id<BadToStringEntity> {
    }
}

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions