Skip to content

Improvements#25

Merged
fronzec merged 14 commits intomainfrom
remove-deprecated
Mar 3, 2026
Merged

Improvements#25
fronzec merged 14 commits intomainfrom
remove-deprecated

Conversation

@fronzec
Copy link
Owner

@fronzec fronzec commented Feb 11, 2026

Summary by CodeRabbit

  • Bug Fixes

    • Fixed an issue where creation timestamps were being incorrectly overwritten during entity processing.
  • Chores

    • Updated container base image to Java 21.
    • Removed unused scheduler and collection dependencies.
    • Added project configuration to standardize formatting, commands, and guidelines.
  • Tests

    • Modernized tests with JUnit 5/Mockito extension and more robust assertions.
  • Documentation

    • Expanded README and added AGENTS.md with project context, usage, and setup guidance.
  • Refactor

    • Switched to SLF4J logging and migrated date handling to modern Java date APIs.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 11, 2026

📝 Walkthrough

Walkthrough

Upgrades dev Docker image to Java 21, removes Quartz and Eclipse Collections deps, fixes a row-mapper bug (preserves createdAt), migrates job date handling to LocalDate, updates tests to JUnit5+Mockito extension, swaps Step3Writer logging to SLF4J + @Component, adds opencode.jsonc and expands docs, and inserts header comments across many source files.

Changes

Cohort / File(s) Summary
Java & Dependencies
fr-batch-service/_devenvironment/Dockerfile, fr-batch-service/pom.xml
Dev Docker base updated to maven:eclipse-temurin-21; removed Spring Boot Quartz starter and Eclipse Collections dependencies.
Job manager & date API
fr-batch-service/src/main/java/.../JobsManagerService.java
Switched job-launch APIs and internals from Date to LocalDate, use date.toString() for job params, copy default params to avoid mutation, and adjusted logging/param handling.
Row mapping fix
fr-batch-service/src/main/java/.../EntityPersonV2RowMapper.java
Fixed mapping to set UpdatedAt from updated_at rather than overwriting CreatedAt.
Logging & component
fr-batch-service/src/main/java/.../step3/Step3Writer.java
Replaced java.util.logging with SLF4J private static final logger, used parameterized logs, and added @Component.
Tests — JUnit5 & Mockito extension
fr-batch-service/src/test/java/.../JobsManagerServiceTest.java, fr-batch-service/src/test/java/.../ApiClientJavaVersionTest.java
Added @ExtendWith(MockitoExtension.class), removed manual openMocks, replaced Date with LocalDate in tests, adjusted verifications/assertions and exception paths; test methods now declare throws Exception.
Docs & project config
fr-batch-service/AGENTS.md, fr-batch-service/README.md, fr-batch-service/opencode.jsonc
Expanded AGENTS.md and README with project/context/run/docs; added opencode.jsonc with coding/style/testing guidelines and project commands.
Header/comment additions
fr-batch-service/src/main/java/.../*
Person.java, Customer.java, CustomerOutput.java, DispatchStatus.java, DispatchedGroupEntityRepository.java, PayloadItemInfo.java, PersonRepository.java, PersonV2Repository.java, BatchItemsPayload.java, DataCalculatedResponse.java, JobInfo.java, etc.
Inserted top-of-file header comment /* 2024-2025 */ across many source files; no behavior changes.
Minor formatting / EOF
fr-batch-service/_devenvironment/Dockerfile
Added trailing newline at EOF.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested labels

enhancement

Poem

🐰 I hopped through code with curious eyes,
Upgraded Java skies and kept old ties,
Fixed a mapper's gentle pluck,
Tuned tests and logs — one tiny luck,
Code nibbles neat, the rabbit sighs.

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'Improvements' is too vague and generic to convey meaningful information about the changeset. It fails to identify the primary purpose of the PR despite significant changes across multiple areas including Java 21 upgrade, dependency removal, date type migration, test modernization, and documentation updates. Replace with a more specific title that highlights the main change, such as 'Upgrade Java 21 and modernize testing with Mockito extensions' or 'Migrate to Java 21 and remove deprecated dependencies'.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch remove-deprecated

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
fr-batch-service/src/main/java/com/fronzec/frbatchservice/batchjobs/JobsManagerService.java (1)

134-138: ⚠️ Potential issue | 🔴 Critical

Change field types from JobOperator to JobLauncher; JobOperator.run(Job, JobParameters) does not exist in Spring Batch 5.x.

In Spring Batch 5.x (used with Spring Boot 4.0.0), the run(Job, JobParameters) method belongs to JobLauncher, not JobOperator. The JobOperator interface uses start(String jobName, Properties parameters) for launching jobs by name. Your fields named asyncJobLauncher and syncJobLauncher should be typed as JobLauncher, not JobOperator. The current code will not compile.

🤖 Fix all issues with AI agents
In `@fr-batch-service/README.md`:
- Line 97: Change the misspelled word "Sometimetimes" to "Sometimes" in the
README line that currently starts with "Sometimetimes mockintosh venv..." so the
sentence reads "Sometimes mockintosh venv doesn't work correctly by incompatible
version of `markupsafe`, install a compatible version with the". Ensure only the
single-word typo is corrected and preserve the rest of the sentence and
surrounding formatting.

In
`@fr-batch-service/src/main/java/com/fronzec/frbatchservice/batchjobs/JobsManagerService.java`:
- Around line 64-71: manualDefinedJobs stores a reference to defaultParams which
is later mutated by launchAllNonAutoDetectedJobs via
defaultJobParams.put("DATE", ...) and put("ATTEMPT_NUMBER", ...) causing
shared-map corruption; fix by cloning the stored or mutated maps so mutations
don't affect the original defaults: when preparing params in
launchAllNonAutoDetectedJobs, create a new map from defaultJobParams (e.g., new
HashMap<>(defaultJobParams)) and then add DATE/ATTEMPT_NUMBER to that copy (or
alternatively store copies into manualDefinedJobs when calling
manualDefinedJobs.put("job1", ...)), ensuring defaultParams remains immutable
across launches.
🧹 Nitpick comments (5)
fr-batch-service/src/main/java/com/fronzec/frbatchservice/batchjobs/job1/step3/Step3Writer.java (1)

59-59: Stale TODO from 2022 — consider addressing or tracking.

This TODO has been around since September 2022. If finalizing the job on send failure is still needed, consider creating an issue to track it so it doesn't remain forgotten.

Would you like me to open a GitHub issue to track this TODO?

fr-batch-service/AGENTS.md (1)

59-70: Minor: Spotless plugin version and status may drift.

Line 61 hardcodes specific versions ("version 2.43.0", "version 1.22.0") and states the plugin is "currently temporarily disabled." These details will become stale if pom.xml changes. Consider referencing the pom.xml as the source of truth rather than duplicating version numbers here.

fr-batch-service/README.md (1)

51-61: Consider renaming "Job1" to "Job 1" for readability.

The static analysis tool flagged "Job1" as a potential spelling issue. Using "Job 1" (with a space) reads more naturally in a heading.

📝 Proposed fix
-### Job1 - ETL Pipeline Demo
+### Job 1 - ETL Pipeline Demo
fr-batch-service/src/main/java/com/fronzec/frbatchservice/batchjobs/JobsManagerService.java (1)

140-152: Consider extracting repeated exception-handling block.

The identical four-catch pattern (lines 140–152, 182–194, 238–250, 305–317) is duplicated across every launch method. A small helper that accepts a Callable<JobExecution> and returns an error string (or empty) would eliminate this duplication.

fr-batch-service/src/test/java/com/fronzec/frbatchservice/batchjobs/JobsManagerServiceTest.java (1)

70-74: Redundant assertion — containsKey is already covered by assertNotNull(result.get(...)).

Line 73 adds no value after line 71. If get("TestJob") returned non-null, the key necessarily exists.

♻️ Remove redundant assertion
         assertEquals(1, result.size());
         assertNotNull(result.get("TestJob"));
-        // The result contains the job.toString() value which is set by the mock
-        assertTrue(result.containsKey("TestJob"));

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
fr-batch-service/src/main/java/com/fronzec/frbatchservice/batchjobs/JobsManagerService.java (1)

166-178: ⚠️ Potential issue | 🟠 Major

runningNumber is nullable Integer — potential NPE at line 178.

launchAllNonAutoDetectedJobs (line 109) uses int (primitive), so it's null-safe. Here, Integer allows null to slip through — runningNumber.toString() at line 178 would throw an NPE. Either:

  • Add Objects.requireNonNull(runningNumber) alongside the existing date null check at line 168, or
  • Change the type to int to match the other method.

Also, this method uses "RUNNING_NUMBER" while launchAllNonAutoDetectedJobs uses "ATTEMPT_NUMBER" for what appears to be the same concept. Consider unifying the parameter key.

🐛 Suggested fix
     public HashMap<String, String> launchAllJobsPreloaded(
-            LocalDate date, final Integer runningNumber) {
+            LocalDate date, final int runningNumber) {
         Objects.requireNonNull(date);

If Integer must be kept (e.g., for deserialization), add:

         Objects.requireNonNull(date);
+        Objects.requireNonNull(runningNumber);
🧹 Nitpick comments (3)
fr-batch-service/src/main/java/com/fronzec/frbatchservice/batchjobs/JobsManagerService.java (3)

63-83: Extract hardcoded job names and parameter keys into named constants.

Lines 67-68 use "paramname" / "paramvalue" and line 70 uses "job1" as raw literals. These strings also appear conceptually tied to repeated keys like "DATE", "ATTEMPT_NUMBER", and "RUNNING_NUMBER" used later in the file. Pulling them into private static final String constants avoids typo-induced bugs and makes the intent self-documenting.

The logging improvements and the TODO for dynamic configuration are a nice touch.

♻️ Suggested constant declarations (add near line 38)
 private static final Logger logger = LoggerFactory.getLogger(JobsManagerService.class);
+
+  private static final String PARAM_DATE = "DATE";
+  private static final String PARAM_ATTEMPT_NUMBER = "ATTEMPT_NUMBER";
+  private static final String PARAM_RUNNING_NUMBER = "RUNNING_NUMBER";
+  private static final String PARAM_DESCRIPTION = "DESCRIPTION";

As per coding guidelines, "Avoid magic numbers and strings; use named constants or enums instead of hardcoded literal values."


85-93: Public methods expose HashMap as return type — prefer Map interface.

The changed method signatures at lines 85, 90, and 166 return HashMap<String, String>. Methods asyncRunJobWithParams and syncRunJobWithParams in the same class already return Map<String, String>. Returning the interface type keeps the API consistent and avoids coupling callers to a concrete implementation.

♻️ Suggested change (apply similarly to other methods)
-    public HashMap<String, String> launchAllNonAutoDetectedJobsAsync(
+    public Map<String, String> launchAllNonAutoDetectedJobsAsync(
             LocalDate date, final int runningNumber) {

36-61: Consider making constructor-injected fields final.

Fields asyncJobLauncher, syncJobLauncher, beanFactory, jobsList, jobRepository, and manualDefinedJobs are assigned once in the constructor and never reassigned. Marking them final enforces immutability and signals intent. This is pre-existing, so deferrable.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@fr-batch-service/_devenvironment/Dockerfile`:
- Around line 1-5: Dockerfile runs as root; create and switch to a non-root user
before running Maven and the app: add steps to create a group/user (e.g.,
APP_USER), set a home directory, chown the workspace (/tmp) and copied files to
that user, set USER to APP_USER, and ensure any build/run commands (mvn clean
verify and mvn spring-boot:run) execute with that user; verify environment
variables like HOME and adjust file permissions so the non-root user can write
to the build and runtime directories.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5a5b85d and 754cdac.

📒 Files selected for processing (1)
  • fr-batch-service/_devenvironment/Dockerfile

Comment on lines +1 to +5
FROM maven:3.9.12-eclipse-temurin-21
WORKDIR /tmp
COPY . .
RUN mvn clean verify
CMD mvn spring-boot:run No newline at end of file
CMD mvn spring-boot:run
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Run the container as a non-root user.

The image currently runs as root by default, which weakens container security posture.

🔒 Proposed hardening diff
 FROM maven:3.9.12-eclipse-temurin-21
+RUN useradd --create-home --uid 10001 appuser
 WORKDIR /tmp
-COPY . .
+COPY --chown=appuser:appuser . .
+USER appuser
 RUN mvn clean verify
-CMD mvn spring-boot:run
+CMD ["mvn", "spring-boot:run"]
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
FROM maven:3.9.12-eclipse-temurin-21
WORKDIR /tmp
COPY . .
RUN mvn clean verify
CMD mvn spring-boot:run
\ No newline at end of file
CMD mvn spring-boot:run
FROM maven:3.9.12-eclipse-temurin-21
RUN useradd --create-home --uid 10001 appuser
WORKDIR /tmp
COPY --chown=appuser:appuser . .
USER appuser
RUN mvn clean verify
CMD ["mvn", "spring-boot:run"]
🧰 Tools
🪛 Trivy (0.69.1)

[error] 1-1: Image user should not be 'root'

Specify at least 1 USER command in Dockerfile with non-root user as argument

Rule: DS-0002

Learn more

(IaC/Dockerfile)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@fr-batch-service/_devenvironment/Dockerfile` around lines 1 - 5, Dockerfile
runs as root; create and switch to a non-root user before running Maven and the
app: add steps to create a group/user (e.g., APP_USER), set a home directory,
chown the workspace (/tmp) and copied files to that user, set USER to APP_USER,
and ensure any build/run commands (mvn clean verify and mvn spring-boot:run)
execute with that user; verify environment variables like HOME and adjust file
permissions so the non-root user can write to the build and runtime directories.

@fronzec fronzec merged commit 2661b10 into main Mar 3, 2026
3 checks passed
@fronzec fronzec deleted the remove-deprecated branch March 3, 2026 05:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant