Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.fasterxml.jackson.annotation.JsonProperty;
import io.dropwizard.Configuration;
import io.dropwizard.db.DataSourceFactory;
import org.hibernate.validator.constraints.NotEmpty;
import jakarta.validation.constraints.NotBlank;
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Mixing jakarta.validation with javax.validation causes @NotBlank to be silently ignored

The @NotBlank annotation is imported from jakarta.validation.constraints (line 6), but the rest of the file and the entire Dropwizard 1.0.5 framework uses the javax.validation namespace (lines 9-10 still import javax.validation.Valid and javax.validation.constraints.NotNull). The Dropwizard validation framework is wired to process javax.validation annotations, so the jakarta.validation.constraints.NotBlank annotation will be silently ignored at runtime. This means the template and defaultName fields will no longer be validated as non-empty/non-blank, allowing invalid configurations to pass without error.

Additional context: Dropwizard version and Bean Validation API

The project uses Dropwizard 1.0.5 (pom.xml ${project.version} = 1.0.5), which depends on Bean Validation 1.1 (javax.validation API) and Hibernate Validator 5.x. The jakarta.validation namespace is from Jakarta EE 9+, a completely different dependency. Even if jakarta.validation happened to be on the classpath, the runtime validator wouldn't scan for it. The correct fix would be to either keep org.hibernate.validator.constraints.NotEmpty or use javax.validation.constraints.NotBlank if upgrading to Bean Validation 2.0+ (Dropwizard 2.x+).

Prompt for agents
The import on line 6 uses `jakarta.validation.constraints.NotBlank`, but this project is on Dropwizard 1.0.5 which uses the `javax.validation` namespace (Bean Validation 1.1 / Hibernate Validator 5.x). The `jakarta.validation` annotation will be silently ignored by the validator at runtime.

Options to fix:
1. Revert to the original `org.hibernate.validator.constraints.NotEmpty` which works with the current Dropwizard/Hibernate Validator version.
2. If migrating to a newer Dropwizard (2.x+), update ALL javax.validation imports to jakarta.validation consistently, and update the Dropwizard version in pom.xml.
3. If staying on Dropwizard 1.x but wanting to deprecate the Hibernate-specific annotation, note that `javax.validation.constraints.NotBlank` is only available in Bean Validation 2.0+ (Hibernate Validator 6.x+), so a dependency upgrade would still be needed.

The key issue is that lines 9-10 still use `javax.validation.Valid` and `javax.validation.constraints.NotNull`, so the namespace must be consistent.
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch — this project uses Dropwizard 1.0.5 which is built on Bean Validation 1.1 (javax.validation), so jakarta.validation.constraints.NotBlank would indeed be ignored at runtime by the validator. Flagging this to the PR author for a decision on how to proceed.

import com.dropwizard.employee.core.Template;

import javax.validation.Valid;
Expand All @@ -16,10 +16,10 @@
*/
public class EmployeeConfiguration extends Configuration {

@NotEmpty
@NotBlank
private String template;

@NotEmpty
@NotBlank
private String defaultName = "Employee!";

@Valid
Expand Down