📍Use lombok, reformat, and optimize the code (#1560)

* Use lombok, reformat, and optimize the code

* Fix merge conflicts and some sonar issues

Co-authored-by: va1m <va1m@email.com>
This commit is contained in:
va1m
2021-03-13 13:19:21 +01:00
committed by GitHub
parent 0e26a6adb5
commit 5cf2fe009b
681 changed files with 2472 additions and 4966 deletions

View File

@@ -24,8 +24,7 @@
package com.iluwatar.halfsynchalfasync;
import java.util.concurrent.LinkedBlockingQueue;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import lombok.extern.slf4j.Slf4j;
/**
* This application demonstrates Half-Sync/Half-Async pattern. Key parts of the pattern are {@link
@@ -60,10 +59,9 @@ import org.slf4j.LoggerFactory;
* tasks are executed. Our implementation is just one simple way of implementing this pattern, there
* are many variants possible as described in its applications.
*/
@Slf4j
public class App {
private static final Logger LOGGER = LoggerFactory.getLogger(App.class);
/**
* Program entry point.
*

View File

@@ -29,8 +29,7 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.FutureTask;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import lombok.extern.slf4j.Slf4j;
/**
* This is the asynchronous layer which does not block when a new request arrives. It just passes
@@ -39,9 +38,8 @@ import org.slf4j.LoggerFactory;
* thread picks up the task and executes it synchronously in background and the result is posted
* back to the caller via callback.
*/
@Slf4j
public class AsynchronousService {
private static final Logger LOGGER = LoggerFactory.getLogger(AsynchronousService.class);
/*
* This represents the queuing layer as well as synchronous layer of the pattern. The thread pool
* contains worker threads which execute the tasks in blocking/synchronous manner. Long running

View File

@@ -23,13 +23,6 @@
package com.iluwatar.halfsynchalfasync;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.InOrder;
import java.io.IOException;
import java.util.concurrent.LinkedBlockingQueue;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.inOrder;
@@ -40,6 +33,11 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when;
import java.io.IOException;
import java.util.concurrent.LinkedBlockingQueue;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
/**
* Date: 12/12/15 - 11:15 PM
*
@@ -56,7 +54,7 @@ public class AsynchronousServiceTest {
}
@Test
public void testPerfectExecution() throws Exception {
void testPerfectExecution() throws Exception {
final var result = new Object();
when(task.call()).thenReturn(result);
service.execute(task);
@@ -72,7 +70,7 @@ public class AsynchronousServiceTest {
}
@Test
public void testCallException() throws Exception {
void testCallException() throws Exception {
final var exception = new IOException();
when(task.call()).thenThrow(exception);
service.execute(task);
@@ -88,7 +86,7 @@ public class AsynchronousServiceTest {
}
@Test
public void testPreCallException() {
void testPreCallException() {
final var exception = new IllegalStateException();
doThrow(exception).when(task).onPreCall();
service.execute(task);