razorpay / razorpay/razorpay-java

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

Open
#363 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
74
Forks
83
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with ApiClient.java to trace response entity resolution, then inspect pom.xml and the test setup for Mockito, JaCoCo, and Surefire configuration. Review deprecated Mockito calls and the duplicate org.json dependency, then run mvn clean compile and mvn test. Done means shaded response parsing works and the full suite passes on supported JDKs.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api, build-system, testing
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.