Friday, 11 October 2019

Tuesday, 8 October 2019

Handling Security Exceptions in Spring Boot


Actually, handling exceptions thrown in the security is different from handling ones thrown from the rest APIs, for they happens in the filters before reaching the Servlet dispatcher.

Hence, we cannot handle security-relevant exceptions in @ControllerAdvice and @ExceptionHanlder,  it needs a different way


Encoding Issue Running Gradle Test

Gradle setup: if having a problem at the command line

It may due to missing encoding set in the Gradle property.

We may setup the encoding convention to force the JVM using a specific encoding strategy.

org.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=512m 
-XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8

Setup Gradle Properties

JVM Configuration Attributes

Intellij setup: if having a problem at the IDE

Intellij  GOTO 'Help' Tab, Click 'Edit Custom VM Option'

adding

-Dfile.encoding=UTF8






Wednesday, 2 October 2019

Spring Session


HTTP is a stateless protocol, meaning that all requests and responses are independent.

Http session is a way to keep states at a server-side. A cookie is another way to keep states in the client-side.

Spring session is a way to manage a cluster of Http sessions;  across sessions, including their persistence.

Spring Security Session

Spring Boot Session

Can Jackson Deserialize Java Time ZonedDateTime

Yes, but must include JSR310. Thus ZonedDateTime can be deserialized directly from JSON response to POJO field. <dependency> <g...