This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Getting 204 - No Content for Rest GET with ehcache intermittently  RSS feed

 
Kousik Majumder
Ranch Hand
Posts: 241
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I have a application where from UI multiple REST services are called sequentially to fulfill value in dropdown list. All these service are cached using ehcache with 1 min as TTL.
The problem is I am getting response code 204 - No Content intermittently for any of those services. It is not always the same service which is throwing 204. All intermittently throwing 204, not all at the same time but one of them at a time.
Please help.
 
Dana Ucaed
Ranch Hand
Posts: 350
6
Netbeans IDE Oracle Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you did update in database for example, you receive 204.

204 means success, not error.

 
Rob Spoor
Sheriff
Posts: 21044
85
Chrome Eclipse IDE Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Correct. Every response code between 200 and 299 (inclusive) means a success, or at least a partial success. You already know that 200 means OK, but there are some others you'll encounter quite frequently:
* 201: Created. Basically the same as a 200, but you also get a Location header with which you can access the newly created resource.
* 204: No Content. Like 200 but there is no response body.
* 202: Accepted. This basically means that your request has been received by the server, which has queued it for later processing.
 
Ron McLeod
Saloon Keeper
Posts: 1560
219
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dana Ucaed wrote:When you did update in database for example, you receive 204 ...


The OP wrote:I have a application where from UI multiple REST services are called sequentially to fulfill value in dropdown list.

This makes me think he was performing GETs.  I would expect a 404 Not Found or a 410 Gone in response to a GET if the requested resource was not available, not a 204 No Content.


The OP also wrote:The problem is I am getting response code 204 - No Content intermittently for any of those services. It is not always the same service which is throwing 204. All intermittently throwing 204, not all at the same time but one of them at a time.

If a 204 No Content response is the intended to indicate that a resource is not available, I would expect it to be returned consistently, not intermittently.
 
Ron McLeod
Saloon Keeper
Posts: 1560
219
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ron McLeod wrote:I would expect a 404 Not Found or a 410 Gone in response to a GET if the requested resource was not available, not a 204 No Content.

Unless the response is trying to convey that the resource is present, but is empty (rather than a 200 OK with an empty body)??
 
Rob Spoor
Sheriff
Posts: 21044
85
Chrome Eclipse IDE Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Some REST server-side implementations like Jersey return a 204 if the return value of a method is null. That could be the case here, although a 404/410 would indeed be a better response*. Without more input we can't say anything about it though.


* This would be the responsibility of the developer. For instance:
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!