Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

194
Views
RequestFuture.get (tiempo de espera prolongado, unidad de unidad de tiempo) no se agota el tiempo de espera

Tengo problemas para usar la biblioteca de Volley. No quiero esperar la solicitud indefinidamente, así que no quiero establecer un tiempo de espera. Pero no está funcionando. Tengo lo mismo en otros lugares (donde uso RequestFuture y no RequestFuture) y funciona bien, pero aquí no puedo configurarlo para que funcione.

 static final long TIMEOUT = 3; static final TimeUnit TIMEOUT_TIME_UNIT = TimeUnit.SECONDS; public boolean fetchPoiUserRating(PoiModel poi, String userId) throws RemoteDataException { RequestQueue queue = mRequestQueue; String url = API_POI_RATING_URL + "/" + poi.getId() + "/" + userId; RequestFuture<JSONObject> future = RequestFuture.newFuture(); JsonObjectRequest request = new JsonObjectRequest(Request.Method.GET, url, null, future, future); future.setRequest(queue.add(request)); try { Log.d(TAG, "Start poi user rating fetch"); JSONObject response = future.get(TIMEOUT, TIMEOUT_TIME_UNIT); // this should timeout but it doesn't Log.d(TAG, "Finished poi user rating fetch"); poi.setUserRating((float) response.getDouble("rating")); return true; } catch (InterruptedException | ExecutionException | JSONException | TimeoutException e) { handleError(e); return false; } }

¡Si puedes proporcionar alguna ayuda, sería increíble! Gracias

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

¡Pude solucionar el problema!

El problema era que el servidor respondía con el código de estado 204 (NO_CONTENT) y no enviaba ningún contenido.

La explicación más probable es que debido a que se devuelve un código de estado de éxito (2XX), espera indefinidamente un JSONObject que nunca llega, ignorando el tiempo de espera (porque recibió un código de éxito).

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!