Skip to content

refactor(complex-methods): Extract batch logic, add exception wrapper, add value objects - #10

Open
maheshkumargangula wants to merge 3 commits into
developfrom
refactor/complex-methods
Open

refactor(complex-methods): Extract batch logic, add exception wrapper, add value objects#10
maheshkumargangula wants to merge 3 commits into
developfrom
refactor/complex-methods

Conversation

@maheshkumargangula

Copy link
Copy Markdown
Collaborator

PR Title

refactor(complex-methods): Extract batch logic, add exception wrapper, add value objects

Base Branch

develop

Summary

  • Extracted repeated exception handler: The identical 5-exception catch block pattern (QueryExecutionException, QueryValidationException, NoHostAvailableException, IllegalStateException, Exception) was copy-pasted across 6+ Cassandra batch methods. Extracted to handleBatchException().
  • batchInsert/batchInsertLogged deduplication: These two ~130-line methods were near-identical (only differing in BatchStatement.Type). Extracted to a shared performBatchInsert(BatchStatement.Type, ...) helper.
  • New CassandraException wrapper: Unified exception class for Cassandra-specific errors, enabling single-catch blocks in callers.
  • New CassandraQueryOptions value object: Builder-pattern POJO to replace 5–8 parameter method signatures.

Files Changed

  • core/sunbird-cassandra-utils/.../CassandraOperationImpl.java (modified)
  • core/sunbird-cassandra-utils/.../exception/CassandraException.java (new)
  • core/sunbird-cassandra-utils/.../helper/CassandraQueryOptions.java (new)

Implements Tasks

CM-01, CM-02, CM-04, CM-06, CM-07

Test Plan

  • Run Cassandra utils tests: mvn test -pl core/sunbird-cassandra-utils
  • Verify existing CassandraOperationImplTest still passes
  • Review that batchInsert and batchInsertLogged produce identical behavior to before

Claude Coordinator and others added 3 commits February 21, 2026 17:10
…, add value objects

- Extract repeated exception handler pattern from Cassandra batch methods (CM-01/CM-07)
- Add CassandraException wrapper class for unified error handling (CM-02)
- Add CassandraQueryOptions value object to reduce method parameter count (CM-04)
- Refactor batchInsert/batchInsertLogged into shared performBatchInsert() helper (CM-06)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…aOperationImpl

- handleCassandraBatchException() was defined 3 times; remove 2 duplicates
- executeBatch() was defined 3 times; remove 2 duplicates
- Wire batchInsert(), batchDelete(), batchInsertLogged() to call the shared
  handleCassandraBatchException() handler, replacing 4-5 catch blocks each
- Update method signature to include keyspaceName and tableName parameters
- File reduced from 5,076 to 4,620 lines (456 lines of dead code removed)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…lict files

36 .rej files from a failed patch application were accidentally committed
in the initial refactor commit. These are not source files and should not
be in the repository.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

2 participants