My Oracle Support Banner

Using the sun.net.http.retryPost Java System Property To Avoid Retrying Non-Idempotent POST Requests (Doc ID 1300232.1)

Last updated on NOVEMBER 09, 2023

Applies to:

Oracle GlassFish Server - Version 7.0 and later
Information in this document applies to any platform.

Goal

This document discusses a Java system property called "sun.net.http.retryPost" which can be used to control the behaviour of failed POST requests made with the Sun Java Runtime Environment's (JRE) HTTP client implementation, with specific reference to its use within the GlassFish Server environment.

An idempotent request is a request that has no side effects, and can therefore be retried without worry.  A non-idempotent request, for example making a deduction from a bank account, is something you do not want to blindly retry if you do not know whether the first attempt actually managed to make the deduction before failing.  What is, or isn't, an idempotent request can only be determined with knowledge of the remote system being accessed.

In the Sun JRE HTTP protocol handler implementation, HTTP requests that fail from either the remote server not responding with a valid HTTP code or the receipt of an IOException, are automatically retried one more time.  Therefore, if your application was making a non-idempotent request, then this will result in it being retried if such an error is encountered during its processing.

Therefore, if there are Java applications deployed to the GlassFish Server that make use of the Sun HTTP client to make requests to a remote server, and those requests could fail with an IOException, perhaps due to some processing timeout, then you will want to use the "sun.net.http.retryPost" Java System property to prevent the requests from being retried.  Note that if the deployed application is invoking a remote web service, the web service framework, such as JAX-WS, internally uses the JRE's HTTPClient implementation, so it is possible for the HTTP Client to be involved indirectly.

Solution

To view full details, sign in with your My Oracle Support account.

Don't have a My Oracle Support account? Click to get started!


In this Document
Goal
Solution
References


My Oracle Support provides customers with access to over a million knowledge articles and a vibrant support community of peers and Oracle experts.