CyberSource / CyberSource/cybersource-rest-client-java

Cybersource-rest-client-java failure under Java 17

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

Nobody has claimed this yet.

Dominant language
Java
Stars
29
Forks
50
Avg merge
28m
Merged PRs (30d)
1

Description

We use the cybersource-rest-client-java library for making merchant payments. Our code runs successfully under Java 11.

Porting to Java 17, we see the following failure when making API calls -

com.google.gson.JsonIOException: Failed making field 'java.io.Reader#lock' accessible; either change its visibility or write a custom TypeAdapter for its declaring type at com.google.gson.internal.reflect.ReflectionHelper.makeAccessible(ReflectionHelper.java:23) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:203) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:112) at com.google.gson.Gson.getAdapter(Gson.java:531) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(ReflectiveTypeAdapterFactory.java:137) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:211) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:112) at com.google.gson.Gson.getAdapter(Gson.java:531) at com.google.gson.Gson.toJson(Gson.java:778) at com.google.gson.Gson.toJson(Gson.java:756) at com.google.gson.Gson.toJson(Gson.java:711) at com.google.gson.Gson.toJson(Gson.java:691) at Invokers.JSON.serialize(JSON.java:83) at Invokers.ApiClient.execute(ApiClient.java:1204) at Api.PaymentsApi.createPaymentWithHttpInfo(PaymentsApi.java:161) at Api.PaymentsApi.createPayment(PaymentsApi.java:146)

This all seems to come from one single line of debug logging in the ApliClient. execute method -

logger.debug("Network Response :\n" + json.serialize(response.headers()));

The response object here is an OK HTTP object, with Java IO members that do not work for this reflective serialization under Java 17

I have built my own copy of the library with this one line removed, and the code works for me under Java 17,

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 at the debug logging line in ApiClient.execute that calls json.serialize(response.headers()), then trace the reported failure through Invokers.JSON.serialize. Reproduce an API call under Java 17 and verify that response logging no longer triggers the Gson reflective-access exception while the request still completes successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.