OpenAPITools / OpenAPITools/openapi-generator

[BUG][ANDROID] java.util.concurrent.TimeoutException

Open
#3,430 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Description

After generating an android client calling any API method results in java.util.concurrent.TimeoutException.
Stack trace:

 Caused by: java.util.concurrent.TimeoutException
    at com.android.volley.toolbox.RequestFuture.doGet(RequestFuture.java:128)
    at com.android.volley.toolbox.RequestFuture.get(RequestFuture.java:97)
    at com.etalonsoft.delifarm.invoker.ApiInvoker.invokeAPI(ApiInvoker.java:372)
    at com.etalonsoft.delifarm.api.DeliFarmApi.tasksGet(DeliFarmApi.java:2084)
    at com.etalonsoft.delifarm.api.ApiClient.getTask(ApiClient.java:15)

Relevant method:

  public String invokeAPI(String host, String path, String method, List<Pair> queryParams, Object body, Map<String, String> headerParams, Map<String, String> formParams, String contentType, String[] authNames) throws ApiException, InterruptedException, ExecutionException, TimeoutException {
    try {
      RequestFuture<String> future = RequestFuture.newFuture();
      Request request = createRequest(host, path, method, queryParams, body, headerParams, formParams, contentType, authNames, future, future);
      if(request != null) {
         mRequestQueue.add(request);
         return future.get(connectionTimeout, TimeUnit.SECONDS); //timeout exception here
      } else {
        return "no data";
      }
    } catch (UnsupportedEncodingException ex) {
      throw new ApiException(0, "UnsupportedEncodingException");
    }
  } 

openapi-generator version

openapi-generator-gradle-plugin:4.0.2

OpenAPI declaration file content or url
openapi: 3.0.0
servers:
  url: http://13.80.240.118:8081
info:
  title: Delifarm ANDROID API
  description: Delifarm ANDROID API using OpenAPI 3.0
  version: 1.0.0
components:
  securitySchemes:
    ApiKeyAuth:        # arbitrary name for the security scheme
      type: apiKey
      in: header       # can be "header", "query" or "cookie"
      name: X-API-KEY  # name of the header, query parameter or cookie
    BearerAuth:
      type: http
      scheme: bearer
  schemas:
    errorResponse:
      type: object
      properties:
        errorcode:
          type: integer
          description: Hibakód - szám
        errordescription:
          type: string
          description: Hiba szöveges leírása
      example:
        errorcode: 10
        errordescription: Ismeretlen eszköz
    login_param:
      type: object
      properties:
        deviceid:
          description: Eszköz azonosítója
          type: string
        username:
          type: string
          description: Megadott felhasználói név hash
        password:
          type: string
          description: Megadott jelszó hash
    login_response:
      type: object
      properties:
        id:
          type: string
          description: Felhasználó azonosító kód, referencia
      example:
        id: 1
    selling_edit_param:
      type: object
      properties:
        userid:
          type: string
          description: Felhasználó
        deviceid:
          type: string
          description: Eszköz azonosítója
        cartcode:
          type: string
          description: Értékesítési kosárkód
        itemcode:
          type: string
          description: Termék kód (ha a cikk még nem létezik a szerver oldalon, akkor új tétel, egyébként a mennyiséget felül kell írni)
        quantity:
          type: integer
          description: Kiszedett mennyiség (0 esetén törlés)
    selling_edit_response:
      type: object
      properties:
        task_id:
          type: string
          description: Visszaadja a cikk kódot
    selling_start_param:
      type: object
      properties:
        userid:
          type: string
          description: Felhasználó
        deviceid:
          type: string
          description: Eszköz azonosítója
        cartcode:
          type: string
          description: Kosárkód
    selling_start_response:
      type: object
      properties:
        cartcode:
          type: string
          description: Visszaadja a kosárkódot
    selling_delete_param:
      type: object
      properties:
        userid:
          type: string
          description: Felhasználó
        deviceid:
          type: string
          description: Eszköz azonosítója
        cartcode:
          type: string
          description: Kosárkód
    selling_delete_response:
      type: object
      properties:
        task_id:
          type: string
          description: Visszaadja a kosárkódot
    selling_get:
      type: object
      properties:
        items:
          type: array
          items:
            type: object
            properties:
              itemcode:
                type: string
                description: Cikk azonosítója
              itemname:
                type: string
                description: Cikk megnevezése
              price:
                type: string
                description: Cikk egységára
              quantity:
                type: integer
      example:
        items:
          - itemcode: DF00001
            itemname: Búza
            price: 92,3456
            quantity: 1
          - itemcode: DF00002
            itemname: Rozs
            price: 102,3456
            quantity: 5
          - itemcode: DF00003
            itemname: Kukorica
            price: 442,3456
            quantity: 5
    shipping_list_param:
      type: object
      properties:
        deviceid:
          type: string
          description: Eszköz azonosító - kötelező
    shipping_post:
      type: array
      items:
        type: object
        properties:
          id:
            type: string
            description: Számlázási hely kód
          name:
            type: string
            description: Számlázási hely név
        example:
          - id: 38
            name: T-shirt
          - id: 114
            name: Phone
    task_get:
      type: object
      properties:
        task_id:
          type: string
          description: Feladat azonosítója - kiszedett mennyiség módosításánál a feladatkód elég, mint egyedi azonosító (a rendelésszám a szerver oldalon ebből azonosítható)
        ordernumber:
          type: string
          description: Rendelés szám
        item:
          type: integer
          minimum: 1
          description: Cikk (db)
        itempart:
          type: integer
          minimum: 1
          description: Cikkelem (db)
        weight:
          type: integer
          description: Súly (kg)
        cart:
          type: integer
          description: Kosár (db)
        processed:
          type: integer
          description: Feldolgozva (%)
      example:
        task_id: 121
        ordernumber: 12468/88
        item: 12
        cikkelem: 47
        weight: 30
        cart:
        processed: 0
    cart_delete_param:
      type: object
      properties:
        deviceid:
          type: string
        task_id:
          type: string
        cartcode:
          type: string
          description: Kosár beolvasott vonalkódja
    cart_delete_response:
      type: object
      properties:
        cartcode:
          type: string
          description: Kosár beolvasott vonalkódja
    cart_attach_param:
      type: object
      properties:
        deviceid:
          type: string
          description: Eszköz azonosítója
        task_id:
          type: string
          description: Feladat kód
        cartcode:
          type: string
          description: Kosár beolvasott vonalkódja
    cart_attach_response:
      type: object
      properties:
        cartcode:
          type: string
          description: Kosár beolvasott vonalkódja
    cart_get:
      type: object
      properties:
        items:
          type: array
          items:
            type: object
            properties:
              itemname:
                type: string
                description: Cikk megnevezése
              quantity:
                type: integer
        carts:
          type: array
          items:
            type: object
            properties:
              cartcode:
                type: string
                description: Kosár vonalkódja
      example:
        items:
          - itemname: Ajtó elektromos kerítéshálóhoz, árammal ellátható, teljes készlet
            quantity: 125
          - itemname: DIP-szórópalack tőgyfertőtlenítő kehellyel
            quantity: 10
          - itemname: Aesculap precíziós beállító segédeszköz Torqui Favoritához
            quantity: 5
          - itemname: G16 öntött itatóvályú nemesacél nyelvvel, zománcozott
            quantity: 1
          - itemname: Tartozék az alulapáthoz és a Profi alulapáthoz
            quantity: 2
          - itemname: Nedves helyiségre alkalmas vályúvilágítás LED-es fénycsövekhez
            quantity: 1
        carts:
          - cartcode: 11234
          - cartcode: 11235
    commission_edit_param:
      type: object
      properties:
        userid:
          type: string
          description: Felhasználó
        deviceid:
          type: string
          description: Eszköz azonosítója
        task_id:
          type: string
          description: Feladat kód
        quantity:
          type: integer
          description: Kiszedett mennyiség
        szavidos_quantity:
          type: array
          items:
            type: object
            properties:
              datum:
                type: string
                format: date
              quantity:
                type: integer
    commission_edit_response:
      type: object
      properties:
        task_id:
          type: string
          description: Visszaadja a feladatkódot
    commission_close_param:
      type: object
      properties:
        userid:
          type: string
          description: Felhasználó
        deviceid:
          type: string
          description: Eszköz azonosítója
        task_id:
          type: string
          description: Feladat kód
    commission_close_response:
      type: object
      properties:
        task_id:
          type: string
          description: Visszaadja a feladatkódot
    commission_return_param:
      type: object
      properties:
        userid:
          type: string
          description: Felhasználó
        deviceid:
          type: string
          description: Eszköz azonosítója
        task_id:
          type: string
          description: Feladat kód
    commission_return_response:
      type: object
      properties:
        task_id:
          type: string
          description: Visszaadja a feladatkódot
    commission_get:
      type: object
      properties:
        items:
          type: array
          items:
            type: object
            properties:
              item_id:
                type: string
                description: Cikk kódja
              itemname:
                type: string
                description: Cikk megnevezése
              quantity:
                type: integer
                description: Kiszedendő mennyiség
              quantity_left:
                type: integer
                description: Hátralévő mennyiség
              storage_location:
                type: integer
                description: Ahol a termék a raktárban megtalálható (tárolás hely)
      example:
        items:
          - item_id: DF50001/01
            itemname: Ajtó elektromos kerítéshálóhoz, árammal ellátható, teljes készlet
            quantity: 125
            quantity_left: 100
            storage_location: AA121,AB232,AC253
          - item_id: A50088
            itemname: DIP-szórópalack tőgyfertőtlenítő kehellyel
            quantity: 10
            quantity_left: 9
            storage_location: AA121,AB232,AC253
          - item_id: DF88000
            itemname: Aesculap precíziós beállító segédeszköz Torqui Favoritához
            quantity: 5
            quantity_left: 3
            storage_location: AA121,AB232,AC253
    package_shelf_binding_param:
      type: object
      properties:
        deviceid:
          type: string
          description: Eszköz azonosítója
        shelf_id:
          type: string
          description: Polc kód
        package_id:
          type: string
          description: Csomag vonalkódja
    package_shelf_binding_response:
      type: object
      properties:
        cartcode:
          type: string
          description: Polc beolvasott vonalkódja
    item_shelf_binding_param:
      type: object
      properties:
        deviceid:
          type: string
          description: Eszköz azonosítója
        shelf_id:
          type: string
          description: Polc kód
        itemcode:
          type: string
          description: Cikk vonalkódja
    item_shelf_binding_response:
      type: object
      properties:
        cartcode:
          type: string
          description: Polc beolvasott vonalkódja
security:
  - ApiKeyAuth: []
paths:
  /login:
    post:
      tags:
        - DeliFarm
      summary: Eszköz/felhasználó bejelentkezés
      requestBody:
        description: Login enitás
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/login_param'
      responses:
        200:
          description: Sikeres bejelentkezés
          content:
            application/json:
              schema:
                $ref: '#/components/login_response'
        401:
          description: Hibás bejelentkezés
          content:
            application/json:
              schema:
                $ref: '#/components/errorResponse'
  /sellings:
    get:
      tags:
        - DeliFarm
      summary: Értékesítés lekérése (pl. újraindul a vonalkód olvasó kütyü, v lemerül)
      parameters:
        - in: query
          name: deviceid
          schema:
            type: string
          required: true
          description: Eszköz azonosító - kötelező
        - in: query
          name: cartcode
          schema:
            type: string
          required: true
          description: Kosárkód - kötelező
      responses:
        200:
          description: Kiszedés részletek
          content:
            application/json:
              schema:
                $ref: '#/components/selling_get'
        401:
          description: Hibás device/felhasználó id
          content:
            application/json:
              schema:
                $ref: '#/components/errorResponse'
        404:
          description: A kosár nem található
          content:
            application/json:
              schema:
                $ref: '#/components/errorResponse'
    post:
      tags:
        - DeliFarm
      summary: Értékesítés módosítása
      requestBody:
        description: Kiszedett mannyiség módosítása
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/selling_edit_param'
      responses:
        200:
          description: Sikeres rögzítés válasza, visszadja a beküldött cikk kódot
          content:
            application/json:
              schema:
                $ref: '#/components/selling_edit_response'
        401:
          description: Hibás device id
          content:
            application/json:
              schema:
                $ref: '#/components/errorResponse'
        404:
          description: Kosár vagy a cikk nem található
          content:
            application/json:
              schema:
                $ref: '#/components/errorResponse'
    put:
      tags:
        - DeliFarm
      summary: Értékesítés indítása
      requestBody:
        description: Ertékesítés indítása, beolvasott kosárkód elküldésével
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/selling_start_param'
      responses:
        200:
          description: Sikeres rögzítés válasza, visszadja a beküldött kosárkódot
          content:
            application/json:
              schema:
                $ref: '#/components/selling_start_response'
        401:
          description: Hibás device id
          content:
            application/json:
              schema:
                $ref: '#/components/errorResponse'
    delete:
      tags:
        - DeliFarm
      summary: Érékesítés törlése
      requestBody:
          description: Értékesítés törlése
          required: true
          content:
            application/json:
              schema:
                $ref: '#/components/selling_delete_param'
      responses:
        200:
          description: Sikeres törlés válasza, visszadja a beküldött kosárkódot
          content:
            application/json:
              schema:
                $ref: '#/components/selling_delete_response'
        401:
          description: Hibás device id
          content:
            application/json:
              schema:
                $ref: '#/components/errorResponse'
        404:
          description: Kosárkód nem található
          content:
            application/json:
              schema:
                $ref: '#/components/errorResponse'
  /shippings:
    post:
      tags:
        - DeliFarm
      summary: Az összes számlázási helyet listázza
      requestBody:
        description: Számlázási helyek listázása
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/shipping_list_param'
      responses:
        200:
          description: Számlázási helyek lista
          content:
            application/json:
              schema:
                $ref: '#/components/shipping_post'
        401:
          description: Hibás device id
          content:
            application/json:
              schema:
                $ref: '#/components/errorResponse'
  /tasks:
    get:
      tags:
        - DeliFarm
      summary: Feladatokkal kapcsolatos műveletek
      parameters:
        - in: query
          name: deviceid
          required: true
          description: Eszköz azonosító
          schema:
            type: string
        - in: query
          name: userid
          required: true
          description: Felhasználó azonosító hash
          schema:
            type: string
      responses:
        200:
          description: Felhasználóhoz tartozó feladat
          content:
            application/json:
              schema:
                $ref: '#/components/task_get'
        401:
          description: Hibás device/felhasználó id
          content:
            application/json:
              schema:
                $ref: '#/components/errorResponse'
  /carts:
    get:
      tags:
        - DeliFarm
      summary: Kosarakkal kapcsolatos műveletek
      parameters:
        - in: query
          name: deviceid
          schema:
            type: string
          required: true
          description: Eszköz azonosító - kötelező
        - in: query
          name: taskid
          schema:
            type: string
          required: true
          description: Feladat azonosító - kötelező
      responses:
        200:
          description: Feladathoz tartozó kosarak
          content:
            application/json:
              schema:
                $ref: '#/components/cart_get'
        401:
          description: Hibás device/felhasználó id
          content:
            application/json:
              schema:
                $ref: '#/components/errorResponse'
    delete:
      tags:
        - DeliFarm
      summary: Kosár törlése
      requestBody:
        description: Törlendő kosár adatai
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/cart_delete_param'
      responses:
        200:
          description: Sikeres törlés válasza, visszadja a beküldött kosárkódot
          content:
            application/json:
              schema:
                $ref: '#/components/cart_delete_response'
        401:
          description: Hibás device id
          content:
            application/json:
              schema:
                $ref: '#/components/errorResponse'
        404:
          description: Törlendő kosár nem található
          content:
            application/json:
              schema:
                $ref: '#/components/errorResponse'
    post:
      tags:
        - DeliFarm
      summary: Kosár csatolása
      requestBody:
        description: Kosár csatolása
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/cart_attach_param'
      responses:
        200:
          description: Sikeres csatolás válasza, visszadja a beküldött kosárkódot
          content:
            application/json:
              schema:
                $ref: '#/components/cart_attach_response'
        401:
          description: Hibás device id
          content:
            application/json:
              schema:
                $ref: '#/components/errorResponse'
        404:
          description: Feleadatkód/rendelés nem található
          content:
            application/json:
              schema:
                $ref: '#/components/errorResponse'
  /commissions:
    get:
      tags:
        - DeliFarm
      summary: Kiszedés lekérése
      parameters:
        - in: query
          name: deviceid
          schema:
            type: string
          required: true
          description: Eszköz azonosító - kötelező
        - in: query
          name: taskid
          schema:
            type: string
          required: true
          description: Feladat azonosító - kötelező
      responses:
        200:
          description: Kiszedés részletek
          content:
            application/json:
              schema:
                $ref: '#/components/commission_get'
        401:
          description: Hibás device/felhasználó id
          content:
            application/json:
              schema:
                $ref: '#/components/errorResponse'
    post:
      tags:
        - DeliFarm
      summary: Kiszedés módosítása
      requestBody:
        description: Kiszedett mannyiség módosítása
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/commission_edit_param'
      responses:
        200:
          description: Sikeres rögzítés válasza, visszadja a beküldött feladatkódot
          content:
            application/json:
              schema:
                $ref: '#/components/commission_edit_response'
        401:
          description: Hibás device id
          content:
            application/json:
              schema:
                $ref: '#/components/errorResponse'
        404:
          description: Feleadatkód/rendelés nem található
          content:
            application/json:
              schema:
                $ref: '#/components/errorResponse'
    put:
      tags:
        - DeliFarm
      summary: Kiszedés lezárása
      requestBody:
        description: Kiszedés lezárása
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/commission_close_param'
      responses:
        200:
          description: Sikeres rögzítés válasza, visszadja a beküldött feladatkódot
          content:
            application/json:
              schema:
                $ref: '#/components/commission_close_response'
        401:
          description: Hibás device id
          content:
            application/json:
              schema:
                $ref: '#/components/errorResponse'
        404:
          description: Feleadatkód/rendelés nem található
          content:
            application/json:
              schema:
                $ref: '#/components/errorResponse'
    delete:
      tags:
        - DeliFarm
      summary: Kiszedés visszaadása
      requestBody:
        description: Kiszedés visszaadása
        content:
          application/json:
            schema:
              $ref: '#/components/commission_return_param'
      responses:
        200:
          description: Sikeres rögzítés válasza, visszadja a beküldött feladatkódot
          content:
            application/json:
              schema:
                $ref: '#/components/commission_return_response'
        401:
          description: Hibás device id
          content:
            application/json:
              schema:
                $ref: '#/components/errorResponse'
        404:
          description: Feleadatkód/rendelés nem található
          content:
            application/json:
              schema:
                $ref: '#/components/errorResponse'
  /packages:
    post:
      tags:
        - DeliFarm
      summary: Polc és csomag összerendelése
      requestBody:
        description: Polc vonalkód és a hozzá tartozó cikk vonalkódja
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/package_shelf_binding_param'
      responses:
        200:
          description: Sikeres rögzítés válasza, visszadja a beküldött polckódot
          content:
            application/json:
              schema:
                $ref: '#/components/package_shelf_binding_response'
        401:
          description: Hibás device id
          content:
            application/json:
              schema:
                $ref: '#/components/errorResponse'
  /items:
    post:
      tags:
        - DeliFarm
      summary: Polc és cikk összerendelése
      requestBody:
        description: Polc vonalkód és a hozzá tartozó cikk vonalkódja
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/item_shelf_binding_param'
      responses:
        200:
          description: Sikeres rögzítés válasza, visszadja a beküldött polckódot
          content:
            application/json:
              schema:
                $ref: '#/components/item_shelf_binding_response'
        401:
          description: Hibás device id
          content:
            application/json:
              schema:
                $ref: '#/components/errorResponse'
Command line used for generation
task buildAndroidClient(type: org.openapitools.generator.gradle.plugin.tasks.GenerateTask) {
    validateSpec = false
    generatorName = "android"
    outputDir = outputPath + "/android".toString()
    inputSpec = specificationPath.toString()
    apiPackage = "com.etalonsoft.delifarm.api"
    invokerPackage = "com.etalonsoft.delifarm.invoker"
    modelPackage = "com.etalonsoft.delifarm.model"
    groupId = "com.etalonsoft.delifarm.androidclient"
    configOptions = [
            artifactId: "delifarm-android-client",
            artifactVersion: "1.0.0",
            androidGradleVersion: "2.3.1",
            androidSdkVersion: "26",
            androidBuildToolsVersion: "26.0.2"
    ]
    systemProperties = [
            modelDocs: "false"
    ]
}

Calling the same API using Volley in the same Android application to rule out any possible network/permission issue works fine:

        val queue = Volley.newRequestQueue(this)
        val url = "http://aaa.aaa.aaa.aaa:8080/carts?deviceid=1&taskid=1"

        val stringRequest = StringRequest(
            Request.Method.GET, url,
            Response.Listener<String> { response ->
                // Display the first 500 characters of the response string.
                val result = "Response is: ${response.substring(0, 500)}"
                Log.d("RT", result)
            },
            Response.ErrorListener {Log.d("RT", "That didn't work!") })

        queue.add(stringRequest)

Contributor guide

Open the contributing guide

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 the generated ApiInvoker.java invokeAPI method and the RequestFuture.get call shown in the report, using the openapi-generator-gradle-plugin 4.0.2 setup and the supplied server URL to reproduce the timeout. Trace whether the request is created and completed, then compare the generated Android client behavior with the API response; done means the cause is identified and a reproducible fix or narrowed issue is documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, java
Domain
api, mobile-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.