Hacktoberfest 2026 : les issues que les mainteneurs ont marquées pour octobre, ouvertes et accessibles aux débutants. Parcourir les issues Hacktoberfest

FileNotFoundException thrown when server responds with 400 or above

Fermée Adaptée aux débutants
#261 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Une pull request liée a déjà été fusionnée.

  • #382 par @RaphaelFakhri — fusionnée

Évaluation

Difficulté
2/5
Temps estimé
1-3 heures
Accessibilité débutants
65/100
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
À l'abandon
Stack technique
android, java
Domaine
networking

Piste de recherche

La stack trace pointe vers HttpAuthorizer.authorize dans com.pusher.client.util, vers la ligne 128, où getInputStream() est appelée sur la connexion. Lisez comment le statut de la réponse y est traité, puis reproduisez le problème avec un serveur local qui renvoie 400 ou un code supérieur. C'est terminé lorsqu'un statut d'erreur renvoie le corps de l'erreur au lieu d'une FileNotFoundException, et que ce comportement est couvert par un test.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

What is the issue?

When the server responds with a HTTP status 400 or above a FileNotFoundException is thrown

Is it a crash report? Submit stack traces or anything that you think would help
com.pusher.client.AuthorizationFailureException: java.io.FileNotFoundException: http://10.0.2.2:8000/api/device/auth
        at com.pusher.client.util.HttpAuthorizer.authorize(HttpAuthorizer.java:146)
        at com.pusher.client.channel.impl.PrivateChannelImpl.getAuthResponse(PrivateChannelImpl.java:130)
        at com.pusher.client.channel.impl.PrivateChannelImpl.toSubscribeMessage(PrivateChannelImpl.java:90)
        at com.pusher.client.channel.impl.ChannelManager$1.run(ChannelManager.java:149)
        at com.pusher.client.util.Factory$1.run(Factory.java:119)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:919)
     Caused by: java.io.FileNotFoundException: http://10.0.2.2:8000/api/device/auth
        at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:255)
        at com.pusher.client.util.HttpAuthorizer.authorize(HttpAuthorizer.java:128)
        at com.pusher.client.channel.impl.PrivateChannelImpl.getAuthResponse(PrivateChannelImpl.java:130) 
        at com.pusher.client.channel.impl.PrivateChannelImpl.toSubscribeMessage(PrivateChannelImpl.java:90) 
        at com.pusher.client.channel.impl.ChannelManager$1.run(ChannelManager.java:149) 
        at com.pusher.client.util.Factory$1.run(Factory.java:119) 
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) 
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) 
        at java.lang.Thread.run(Thread.java:919) 
Any improvements you suggest

When a status 400 or above is returned from the server get the errorStream instead of the inputStream.

if (responseStatus >= HTTP_BAD_REQUEST) {
     is = connection.getErrorStream();
} else {
     is = connection.getInputStream();
}

CC @pusher/mobile

Langage dominant
Java
Étoiles
315
Forks
140
Merge moyen
10 j 14 h
PR mergées (30 j)
5

Préparer son environnement

  • Aucun Dockerfile ni fichier Docker Compose
  • Propose un modèle de pull request
  • Aucun guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de pusher/pusher-websocket-java

Toutes les issues de pusher/pusher-websocket-java

Issues similaires

Plus d'issues Java

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.