Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #617
Closed
Open
Issue created Jul 22, 2018 by Administrator@rootContributor

[Java] [Android] Jersey2 library request/issue - suppress warning log in android

Created by: mintu19

I am continuing the issue i have filed at Swagger-Codegen. I think that similar approach can be applied to here as well (as i understand this is fork of swagger). I have not tried it with latest release. I am creating this issue here as well for reference to feature.

Description

When I generate client for java using Jersey 2 library and use it with both java and android project (which works in android), there are warning thrown by client because of use of java.awt.* class in jersey unsupported by Android. Although these are just warnings but there are way to suppress such warnings. (and maybe make jersey2 client library available for android platform?)

The main purpose of using jersey client in Android is to support circular dependency json sent by server (Jsog Jackson)

Swagger-codegen version

2.3.1, older one (with no version command) I guess this will apply to openAPI generators as well...

Suggest a fix/enhancement

The way to suppress those warnings in logs is to add a feature to client that let hk2 not search for non available files.

Sample code for feature (that i am using with generated code)

import javax.ws.rs.core.Feature;
import javax.ws.rs.core.FeatureContext;
import org.glassfish.hk2.api.Descriptor;
import org.glassfish.hk2.api.Filter;
import org.glassfish.hk2.utilities.binding.AbstractBinder;

/**
 *
 * @author akshit
 */
public class AndroidFriendlyFeature implements Feature {
    @Override
    public boolean configure(FeatureContext context) {
      context.register(new AbstractBinder() {
          @Override
          protected void configure() {
              addUnbindFilter(new Filter() {
                  @Override
                  public boolean matches(Descriptor d) {
                      String implClass = d.getImplementation();
                      return implClass.startsWith("org.glassfish.jersey.message.internal.DataSource")
                       || implClass.startsWith("org.glassfish.jersey.message.internal.RenderedImage");
                  }
              });
          }
      });
      return true;
    }
}

then add it to client on ApiClient.java buildHttpClient Method

clientConfig.register(AndroidFriendlyFeature.class);
Assignee
Assign to
Time tracking