0% found this document useful (0 votes)
22 views1 page

Facts

Uploaded by

vishwasransing
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views1 page

Facts

Uploaded by

vishwasransing
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

1.

RequestBody along with GET:


- Goes against HTTP 1.1 specification
- Possible but discouraged since purpose of GET is to retrieve data
- Accessed using @RequestBody annotation
- Caching: GET requests are often cached, and caching mechanisms assume no
body in GET requests.
- Compatibility: Many HTTP servers and proxies ignore or discard bodies in
GET requests.
2. Avoid null atributes to the response:
- spring.jackson.default-property-inclusion=non-null (in app.properties)
- @JsonInclude(JsonInclude.Include.NON_NULL) (Over mapping method in
controller)
3. Try-with resources block:
static String readFirstLineFromFile(String path) throws IOException {
try (FileReader fr = new FileReader(path);
BufferedReader br = new BufferedReader(fr)) {
return br.readLine();
}
}

- Only object that implement AutoCloseable could be used as resource


- No need to manually close resources using finally block.

You might also like