Skip to content

[UrlConnectionHttpClient] Wrap erroneous NPE from HttpURLConnection as IOException #2572

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 1, 2021

Conversation

Bennett-Lynch
Copy link
Contributor

Description

  • When interacting specifically with HttpURLConnection#getResponseCode,
    wrap any unexpected NullPointerExceptions as IOException
  • Add corresponding unit test

Motivation and Context

HttpURLConnection#getInputStream0 has been observed to intermittently
throw NullPointerExceptions for reasons that still require further
investigation, but are assumed to be due to a bug in the JDK.
Propagating such NPEs is confusing for users and are not subject to
being retried on by the default retry policy configuration, so instead
we should bias towards propagating these as IOExceptions.

Testing

Created new unit test to simulate the observed (but not yet reliably reproduced) behavior of HttpURLConnection throwing NPE.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Checklist

  • I have read the CONTRIBUTING document
  • Local run of mvn install succeeds
  • My code follows the code style of this project
  • My change requires a change to the Javadoc documentation
  • I have updated the Javadoc documentation accordingly
  • I have read the README document
  • I have added tests to cover my changes
  • All new and existing tests passed
  • A short description of the change has been added to the CHANGELOG
  • My change is to implement 1.11 parity feature and I have updated LaunchChangelog

License

  • I confirm that this pull request can be released under the Apache 2 license

Bennett Lynch added 2 commits June 30, 2021 14:53
…s IOException

## Motivation

`HttpURLConnection#getInputStream0` has been observed to intermittently
throw `NullPointerException`s for reasons that still require further
investigation, but are assumed to be due to a bug in the JDK.
Propagating such NPEs is confusing for users and are not subject to
being retried on by the default retry policy configuration, so instead
we should bias towards propagating these as `IOException`s.

## Modifications

* When interacting specifically with HttpURLConnection#getResponseCode,
wrap any unexpected NullPointerExceptions as IOException
* Add corresponding unit test

## Result

* Transient errors will be retried and be less likely to surface to a
user's application layer
…s IOException

## Motivation

`HttpURLConnection#getInputStream0` has been observed to intermittently
throw `NullPointerException`s for reasons that still require further
investigation, but are assumed to be due to a bug in the JDK.
Propagating such NPEs is confusing for users and are not subject to
being retried on by the default retry policy configuration, so instead
we should bias towards propagating these as `IOException`s.

## Modifications

* When interacting specifically with HttpURLConnection#getResponseCode,
wrap any unexpected NullPointerExceptions as IOException
* Add corresponding unit test

## Result

* Transient errors will be retried and be less likely to surface to a
user's application layer
…s IOException

## Motivation

`HttpURLConnection#getInputStream0` has been observed to intermittently
throw `NullPointerException`s for reasons that still require further
investigation, but are assumed to be due to a bug in the JDK.
Propagating such NPEs is confusing for users and are not subject to
being retried on by the default retry policy configuration, so instead
we should bias towards propagating these as `IOException`s.

## Modifications

* When interacting specifically with HttpURLConnection#getResponseCode,
wrap any unexpected NullPointerExceptions as IOException
* Add corresponding unit test

## Result

* Transient errors will be retried and be less likely to surface to a
user's application layer
Copy link
Contributor

@dagnir dagnir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@sonarqubecloud
Copy link

sonarqubecloud bot commented Jul 1, 2021

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

100.0% 100.0% Coverage
0.0% 0.0% Duplication

@Bennett-Lynch Bennett-Lynch merged commit 1a87ffd into aws:master Jul 1, 2021
@zoewangg
Copy link
Contributor

zoewangg commented Jul 1, 2021

@all-contributors please add @Bennett-Lynch for code

@allcontributors
Copy link
Contributor

@zoewangg

I've put up a pull request to add @Bennett-Lynch! 🎉

aws-sdk-java-automation added a commit that referenced this pull request May 25, 2023
…df6262e5e

Pull request: release <- staging/d3d243dd-2120-42f9-9b7a-e92df6262e5e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants