Skip to content
This repository was archived by the owner on Apr 4, 2022. It is now read-only.
This repository was archived by the owner on Apr 4, 2022. It is now read-only.

callback passed to exec invoked 2 times, swallows original exception and passes null as input stream #205

@ghost

Description

Hi,

The code in doConnection has try catch on connectFunc and then on toResponse, but the method toResponse invokes the parser (callback from user), so that's very bad.

Instead of only handling errors during connection - it also handles errors in the user code, without them being aware.

consider the following scenario:

  • Connection established correctly, 200
  • The parser (not the connection function!) throws an IOException. this gets caught - and disappears. No handling, logging or propagation!
  • The parser is invoked once again! This time, the parser is passed the error stream, which is null because the status code was 200. the callback sees 200, handles as success and blows up on null pointer exception.
  • The developer is very confused

generally speaking, IMO, connectFunc should be wrapped in try catch, the user callback should not have any catch (but finally and stream cleanup is ok).

FYI

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions