Configuring Custom BackOff Policy for RetryTemplate (using RetryTemplateBuilder)

Hi everybody, in this post under Spring Retry I will show you with example how to configure custom BackOff policy using RetryTemplateBuilder. For the example we will use the below service class Service1 class public class Service1 { private int i = 0; private int j = 0; public void executeWithException() { i = i…… Continue reading Configuring Custom BackOff Policy for RetryTemplate (using RetryTemplateBuilder)

Configuring Custom Retry Policy for RetryTemplate (using RetryTemplateBuilder)

In this post under Spring Retry, I will show with example how to configure your own custom Retry Policy using RetryTemplateBuilder class. For this example, we will use modified version of Spring’s MaxAttemptsRetryPolicy, as shown below CustomMaxAttemptsRetryPolicy import org.springframework.retry.RetryContext; import org.springframework.retry.policy.MaxAttemptsRetryPolicy; public class CustomMaxAttemptsRetryPolicy extends MaxAttemptsRetryPolicy { private String name; public CustomMaxAttemptsRetryPolicy(String name) { this.name…… Continue reading Configuring Custom Retry Policy for RetryTemplate (using RetryTemplateBuilder)

Clearing HTML content of invalid or blacklisted tags

In this post under Jsoup, I will show how to remove invalid or blacklisted tags from the user inputed HTML content. In our example we will have an html content with one invalid tag “script” and we will have whitelist (i.e., list of allowed tags) containing “p” and “span” tag. When we run our code,…… Continue reading Clearing HTML content of invalid or blacklisted tags

Configuring ExponentialBackOffPolicy for RetryTemplate (using RetryTemplateBuilder)

In this post under Spring Retry, I will show with example how to configure ExponentialBackOffPolicy using RetryTemplateBuilder. First lets recap what is ExponentialBackOffPolicy is. ExponentialBackOffPolicy increases the backoff period at every retry attempt by a specified number. ExponentialBackOffPolicy requires three inputs for it to work, which are1) initialInterval –> the backoff period used at first…… Continue reading Configuring ExponentialBackOffPolicy for RetryTemplate (using RetryTemplateBuilder)

Validating html documents against whitelist of html tags

You may have a requirement where your application has to accept html data as input from the user and you have to make sure that the input contains only those tag that are allowed by your application. In this post under Jsoup, I will show how to implement the above requirement. First we have to…… Continue reading Validating html documents against whitelist of html tags