ADR-006: Cloudant SDK for CouchDB Access

Decision Analysis and Resolution: CouchDB Client Library Migration

Created by: SW360 Architecture Team
Original Decision: 2024
Reformatted: April 2026
Status: Accepted
Estimated read time: 10 minutes


Table of Contents

  1. Background
  2. Goal
  3. Key Principles
  4. Key Inputs, Assumptions and Restrictions
  5. Options Analysis
  6. Criteria for Making a Decision
  7. Final Decision
  8. Migration Path
  9. Contributors

Background

SW360 uses Apache CouchDB as its primary database (see ADR-002). The original CouchDB client library was Ektorp, a Java library that provided:

  • Object mapping for CouchDB documents
  • View query support
  • Attachment handling

However, Ektorp became deprecated and unmaintained:

  • Last release: 2016 (8+ years without updates)
  • Java compatibility: No support for Java 17+, 21+
  • Security: Known vulnerabilities not addressed
  • Features: Missing support for CouchDB 3.x features (Mango queries, Nouveau)

Why This Decision Matters: The CouchDB client is used throughout SW360’s data layer. An unmaintained library with security vulnerabilities poses significant risk.


Goal

The goal of this decision analysis is to:

  1. Replace the deprecated Ektorp library
  2. Enable Java 17+ and Java 21 compatibility
  3. Ensure active maintenance and security patches
  4. Support CouchDB 3.x features
  5. Minimize migration disruption

Key Principles

#PrincipleDescription
1Active MaintenanceLibrary must have regular updates
2Security FocusQuick response to vulnerabilities
3Modern JavaSupport Java 17+ and 21
4CouchDB CompatibleWork with vanilla Apache CouchDB
5Feature ParitySupport all current Ektorp functionality

Key Inputs, Assumptions and Restrictions

TypeDescription
InputEktorp last updated in 2016, officially deprecated
InputEktorp has unpatched CVEs
InputSW360 uses CouchDB 3.x with views and attachments
AssumptionIBM Cloudant SDK works with vanilla CouchDB
AssumptionMigration can be done incrementally
RestrictionMust not require CouchDB schema changes
RestrictionMust support all existing query patterns

Options Analysis

Option 1 - IBM Cloudant SDK

Summary

Use IBM’s Cloudant Java SDK (cloudant-java-sdk), which despite its name, is fully compatible with Apache CouchDB. IBM unified their cloud SDKs and actively maintains this library.

Conceptual View

graph TB
    subgraph SDK["IBM Cloudant SDK"]
        direction TB
        W["Works with:<br/>├── IBM Cloudant (cloud)<br/>└── Apache CouchDB (self-hosted) ✓"]
        F["Features:<br/>Document CRUD | View queries<br/>Mango queries | Attachments<br/>Bulk operations | Async support"]
    end

Impact / Changes Required

  • Refactor repository classes to use Cloudant SDK APIs
  • Update connection configuration
  • Migrate view query code to new API
  • Update attachment handling code

SWOT Analysis

CategoryAnalysis
Strengths1. Active maintenance by IBM
2. Regular security updates
3. Full Java 21 compatibility
4. Modern builder-based API
5. Async operations support
6. Comprehensive documentation
7. Works with vanilla CouchDB
Weaknesses1. API differs from Ektorp (migration effort)
2. “Cloudant” name suggests IBM-only (misleading)
3. Larger dependency tree
4. Learning curve for new patterns
Opportunities1. Access to CouchDB 3.x features
2. Better performance with async ops
3. Future IBM enhancements
Threats1. IBM strategic changes
2. API breaking changes in updates

Option 2 - Apache CouchDB-Java

Summary

Use Apache’s official CouchDB Java client library, which provides basic HTTP client operations for CouchDB.

Conceptual View

graph TB
    subgraph CJ["Apache CouchDB-Java"]
        direction TB
        C1["Basic HTTP client for CouchDB"]
        C2["Limited object mapping"]
        C3["Manual JSON serialization"]
    end

Impact / Changes Required

  • Build custom object mapping layer
  • Implement view query abstraction
  • Custom attachment handling
  • More code to maintain

SWOT Analysis

CategoryAnalysis
Strengths1. Apache-backed
2. Minimal dependencies
3. Official CouchDB project
Weaknesses1. Limited features—basic HTTP only
2. No object mapping
3. Manual JSON handling
4. Limited documentation
5. More custom code required
Opportunities1. Direct Apache support
Threats1. High maintenance burden
2. Bugs in custom code
3. Feature lag

Option 3 - Ektorp Fork (Community)

Summary

Use a community-maintained fork of Ektorp that attempts to keep the library updated with Java compatibility patches.

Conceptual View

graph TB
    subgraph EF["Ektorp Fork (Community)"]
        direction TB
        E1["Fork of original Ektorp"]
        E2["Community-maintained"]
        E3["Same API as original"]
    end

Impact / Changes Required

  • Update Maven dependency coordinates
  • Test compatibility
  • Minimal code changes

SWOT Analysis

CategoryAnalysis
Strengths1. Same API—minimal migration
2. Drop-in replacement potential
3. Community support
Weaknesses1. Uncertain maintenance commitment
2. No corporate backing
3. May have unresolved CVEs
4. Limited contributor base
5. No guarantee of Java 21 support
Opportunities1. Could contribute to fork
Threats1. Fork may become abandoned
2. Security vulnerabilities
3. No SLA on updates
4. Technical debt accumulation

Option 4 - Custom HTTP Client

Summary

Build a custom CouchDB client using a modern HTTP client library like OkHttp or Java’s HttpClient, with Jackson for JSON serialization.

Conceptual View

graph TB
    subgraph CH["Custom HTTP Client"]
        direction TB
        H1["OkHttp / Java HttpClient"]
        H2["+ Jackson for JSON"]
        H3["+ Custom CouchDB abstractions"]
    end

Impact / Changes Required

  • Design and implement complete client library
  • Build all CouchDB operations from scratch
  • Implement view query builders
  • Handle attachments manually
  • Ongoing maintenance

SWOT Analysis

CategoryAnalysis
Strengths1. Full control
2. No external dependencies
3. Tailored to SW360 needs
4. Modern HTTP client features
Weaknesses1. Massive development effort
2. Must reinvent the wheel
3. Ongoing maintenance burden
4. Higher bug risk
5. No community leverage
Opportunities1. Perfect fit for requirements
Threats1. Resource drain
2. Bugs in custom code
3. Developer time waste
4. Missing CouchDB edge cases

Criteria for Making a Decision

T-Shirt Sizing Scale

T-Shirt SizeNumeric ValueMeaning
XS1.0Worst for this aspect
S2.5Poor
S-M3.75Below Average
M5.0Average
M-L6.25Above Average
L7.5Good
L-XL8.75Very Good
XL10.0Best for this aspect

Weighted Evaluation Matrix

CriteriaDescriptionWeightCloudant SDKCouchDB-JavaEktorp ForkCustom
RatingScoreRatingScoreRatingScoreRatingScore
Active MaintenanceRegular updates10XL100.0M50.0S-M37.5M50.0
Security PatchesCVE response10L-XL87.5M-L62.5S25.0M50.0
Java 21 SupportModern Java compat9XL90.0L67.5M45.0L-XL78.75
Feature CompletenessAll CouchDB features8L-XL70.0M40.0L60.0L60.0
Migration EffortEase of transition8M-L50.0S-M30.0L-XL70.0XS8.0
DocumentationQuality and coverage7L-XL61.25M35.0M35.0XS7.0
Corporate BackingLong-term viability8XL80.0L60.0XS8.0M40.0
CouchDB CompatibilityWorks with vanilla CouchDB8XL80.0XL80.0XL80.0XL80.0
Async SupportNon-blocking operations5XL50.0M25.0S12.5L37.5
CommunityHelp resources5L37.5M-L31.25M25.0XS5.0
TOTAL706.25481.25398.0416.25

Score Summary

RankOptionTotal ScoreRecommendation
🥇 1IBM Cloudant SDK706.25SELECTED
🥈 2Apache CouchDB-Java481.25Limited features
🥉 3Custom HTTP Client416.25❌ Too much effort
4Ektorp Fork398.0❌ Uncertain future

Final Decision

Selected Option: IBM Cloudant SDK

Rationale

IBM Cloudant SDK was selected as the CouchDB client library based on:

  1. Highest Weighted Score (706.25) - Clear winner on critical criteria

  2. Active Maintenance (XL) - IBM corporate commitment:

    • Regular releases
    • Security vulnerability response
    • Feature additions
  3. Java 21 Support (XL) - Full modern Java compatibility

  4. CouchDB Compatibility (XL) - Despite the name, works perfectly with vanilla CouchDB:

    // Works with Apache CouchDB, not just IBM Cloudant
    Cloudant client = new Cloudant("sw360", authenticator);
    client.setServiceUrl("http://couchdb:5984");
    
  5. Corporate Backing (XL) - IBM’s unified cloud SDK strategy ensures long-term viability


Migration Path

Phase 1: Add Cloudant SDK Alongside Ektorp

  • Add dependency without removing Ektorp
  • Create adapter layer for gradual migration

Phase 2: Migrate Core Repositories

  • Convert document CRUD operations
  • Migrate view queries
  • Update attachment handling

Phase 3: Complete Migration

  • Remove remaining Ektorp usages
  • Remove Ektorp dependency
  • Update documentation

Migration Examples

Ektorp (Old):

CouchDbConnector db = new StdCouchDbConnector("sw360db", couchDbInstance);
Component component = db.get(Component.class, id);

Cloudant SDK (New):

GetDocumentOptions options = new GetDocumentOptions.Builder()
    .db("sw360db")
    .docId(id)
    .build();
Document doc = client.getDocument(options).execute().getResult();
Component component = mapper.convertValue(doc, Component.class);

Maven Dependency

<dependency>
    <groupId>com.ibm.cloud</groupId>
    <artifactId>cloudant</artifactId>
    <version>0.8.x</version>
</dependency>

Contributors

NameRoleContribution
SW360 Architecture TeamDecision MakersTechnical analysis
Development TeamImplementersMigration, testing

Consequences Summary

Positive

  • ✅ Active maintenance—regular updates and security patches
  • ✅ Corporate backing—IBM’s commitment to the SDK
  • ✅ Modern API—clean, builder-based design
  • ✅ Async support—non-blocking operations for performance
  • ✅ Documentation—comprehensive IBM documentation
  • ✅ Java 21—full modern Java support

Negative

  • ⚠️ Migration effort—refactoring from Ektorp APIs required
  • ⚠️ IBM branding—name suggests Cloudant-only
  • ⚠️ Dependency size—larger dependency tree
  • ⚠️ Learning curve—new API patterns for developers

Technical Debt Addressed

  • Eliminated unmaintained library (Ektorp)
  • Resolved unpatched security vulnerabilities
  • Enabled Java 21 compatibility
  • Gained access to CouchDB 3.x features

Revision History

VersionDateAuthorChanges
1.02024Architecture TeamInitial decision
2.0April 2026Bibhuti Bhusan DashReformatted to DAR/SWOT template