Vyacheslav Rusakov
Vyacheslav Rusakov's Blog

Vyacheslav Rusakov's Blog

Guice-validator bugfix release

Vyacheslav Rusakov's photo
Vyacheslav Rusakov
·Sep 9, 2021·

1 min read

Guice-validator has been released for both javax.validation and jakarta.validation branches:

  • 2.0.1 for hiberante-validator 6.x
  • 3.0.1 for hiberante-validator 7.x

Both versions depend on guice 5 now, but are still compatible with guice 4 (just exclude transitive dep to downgrade).

The main reason for the release was a bug leading to manually specified Default group ignoring in strict groups mode:

new ValidationModule().strictGroupsDeclaration()

For example,

public class Service {
    public void method(@NotNull(groups = CustomGroup.class) String arg1, 
                                        @NotNull String arg2 {
         ....
    }
}

When user manually specify Default group, e.g. like this:

@Inject ValidationContext context;
@Inject Service service;

context.doWithGroups(() -> {            
                service.method("foo", null);
        }, Default.class, CustomGroup.class);

It was ignored and the call did not fail with a validation error (only in strict groups mode!).

I doubt anyone was ever affected by this, but just in case.

 
Share this