Skip to content

Fix response parsing in shaded builds and update test infrastructure for modern JDKs #363

Description

@maheshshinde9100

Bug Description

The SDK currently relies on a hardcoded package name (com.razorpay.) inside ApiClient.java while resolving entity classes through reflection.

When the SDK is repackaged using shading or relocation (for example, with the Maven Shade Plugin), the package name changes, causing reflection to fail. This results in response parsing failures and ClassCastException/Unable to parse response errors, as reported in Issue #41 and Issue #333.

Additionally, the current test infrastructure depends on legacy Mockito APIs and older build tooling, which causes compatibility issues on modern Java versions (JDK 17+).

Proposed Solution

  • Replace hardcoded package references with dynamic package resolution using getClass().getPackage().getName().
  • Modernize the test environment by upgrading Mockito and JaCoCo.
  • Configure Maven Surefire for newer JVMs.
  • Replace deprecated Mockito APIs (anyObject()any(), initMocks()openMocks()).
  • Remove the duplicate org.json dependency from pom.xml.

Expected Outcome

  • Response parsing works correctly even when the SDK is shaded or relocated.
  • Developers can run the full test suite successfully on JDK 8–21.
  • Removes deprecated APIs and improves long-term maintainability.

Verification

  • mvn clean compile
  • mvn test
  • ✅ All 170 unit tests passed on Java 21.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions