Merge branch 'eugenp:master' into master

This commit is contained in:
press0 2023-04-10 10:39:14 -05:00 committed by GitHub
commit 1628c013c6
769 changed files with 6256 additions and 3223 deletions

1
.gitignore vendored
View File

@ -89,6 +89,7 @@ spring-soap/src/main/java/com/baeldung/springsoap/gen/
/report-*.json
transaction.log
*-shell.log
customers.xml
apache-cxf/cxf-aegis/baeldung.xml
testing-modules/report-*.json

View File

@ -36,7 +36,6 @@
</dependency>
</dependencies>
<properties>
<akka.http.version>10.0.11</akka.http.version>
<akka.stream.version>2.5.11</akka.stream.version>

View File

@ -21,7 +21,6 @@
</dependency>
</dependencies>
<properties>
<auto-service.version>1.0-rc2</auto-service.version>
</properties>

View File

@ -12,6 +12,5 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring
- [Reading an HTTP Response Body as a String in Java](https://www.baeldung.com/java-http-response-body-as-string)
- [How To Get Cookies From the Apache HttpClient Response](https://www.baeldung.com/java-apache-httpclient-cookies)
- [Enabling Logging for Apache HttpClient](https://www.baeldung.com/apache-httpclient-enable-logging)
- [Expand Shortened URLs with Apache HttpClient](https://www.baeldung.com/apache-httpclient-expand-url)
- [Apache HttpClient vs. CloseableHttpClient](https://www.baeldung.com/apache-httpclient-vs-closeablehttpclient)
- More articles: [[<-- prev]](../apache-httpclient)

View File

@ -9,6 +9,7 @@ This module contains articles about Apache HttpClient 4.5
- [Custom HTTP Header with the Apache HttpClient](https://www.baeldung.com/httpclient-custom-http-header)
- [Apache HttpClient vs. CloseableHttpClient](https://www.baeldung.com/apache-httpclient-vs-closeablehttpclient)
- [Expand Shortened URLs with Apache HttpClient](https://www.baeldung.com/apache-httpclient-expand-url)
- [Retrying Requests using Apache HttpClient](https://www.baeldung.com/java-retrying-requests-using-apache-httpclient)
### Running the Tests
To run the live tests, use the command: mvn clean install -Plive

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>apache-httpclient4</artifactId>
<version>0.1-SNAPSHOT</version>

View File

@ -0,0 +1,168 @@
package com.baeldung.httpclient.retry;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertThrows;
import java.io.IOException;
import java.net.URI;
import java.net.UnknownHostException;
import java.util.Objects;
import org.apache.http.HttpRequestInterceptor;
import org.apache.http.HttpResponseInterceptor;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPatch;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpPut;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.DefaultHttpRequestRetryHandler;
import org.apache.http.impl.client.HttpClientBuilder;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
public class ApacheHttpClientRetryIntegrationTest {
private Integer requestCounter;
private CloseableHttpClient httpClient;
@BeforeEach
void setUp() {
requestCounter = 0;
}
@AfterEach
void tearDown() throws IOException {
if (httpClient != null) {
httpClient.close();
}
}
private void createDefaultApacheHttpClient() {
this.httpClient = HttpClientBuilder
.create()
.addInterceptorFirst((HttpRequestInterceptor) (httpRequest, httpContext) -> {
requestCounter++;
}).build();
}
private void createFailingHttpClient() {
this.httpClient = HttpClientBuilder
.create()
.addInterceptorFirst((HttpRequestInterceptor) (httpRequest, httpContext) -> requestCounter++)
.addInterceptorLast((HttpResponseInterceptor) (httpResponse, httpContext) -> {
throw new IOException();
})
.build();
}
private void createHttpClientWithRetryHandler() {
this.httpClient = HttpClientBuilder
.create()
.addInterceptorFirst((HttpRequestInterceptor) (httpRequest, httpContext) -> requestCounter++)
.addInterceptorLast((HttpResponseInterceptor) (httpRequest, httpContext) -> { throw new IOException(); })
.setRetryHandler(new DefaultHttpRequestRetryHandler(6, true))
.build();
}
private void createHttpClientWithCustomRetryHandler() {
this.httpClient = HttpClientBuilder
.create()
.addInterceptorFirst((HttpRequestInterceptor) (httpRequest, httpContext) -> requestCounter++)
.addInterceptorLast((HttpResponseInterceptor) (httpRequest, httpContext) -> { throw new IOException(); })
.setRetryHandler((exception, executionCount, context) -> {
if (executionCount < 5 && Objects.equals("GET", ((HttpClientContext) context).getRequest().getRequestLine().getMethod())) {
return true;
} else {
return false;
}
})
.build();
}
private void createHttpClientWithRetriesDisabled() {
this.httpClient = HttpClientBuilder
.create()
.addInterceptorFirst((HttpRequestInterceptor) (httpRequest, httpContext) -> requestCounter++)
.addInterceptorLast((HttpResponseInterceptor) (httpRequest, httpContext) -> { throw new IOException(); })
.disableAutomaticRetries()
.build();
}
@Test
public void givenDefaultConfiguration_whenReceivedIOException_thenRetriesPerformed() {
createFailingHttpClient();
assertThrows(IOException.class, () -> httpClient.execute(new HttpGet("https://httpstat.us/200")));
assertThat(requestCounter).isEqualTo(4);
}
@Test
public void givenDefaultConfiguration_whenDomainNameNotResolved_thenNoRetryApplied() {
createDefaultApacheHttpClient();
HttpGet request = new HttpGet(URI.create("http://domain.that.does.not.exist:80/api/v1"));
assertThrows(UnknownHostException.class, () -> httpClient.execute(request));
assertThat(requestCounter).isEqualTo(1);
}
@Test
public void givenDefaultConfiguration_whenGotInternalServerError_thenNoRetryLogicApplied() throws IOException {
createDefaultApacheHttpClient();
HttpGet request = new HttpGet(URI.create("https://httpstat.us/500"));
CloseableHttpResponse response = assertDoesNotThrow(() -> httpClient.execute(request));
assertThat(response.getStatusLine().getStatusCode()).isEqualTo(500);
assertThat(requestCounter).isEqualTo(1);
response.close();
}
@Test
public void givenDefaultConfiguration_whenHttpPatchRequest_thenRetryIsNotApplied() {
createFailingHttpClient();
HttpPatch request = new HttpPatch(URI.create("https://httpstat.us/500"));
assertThrows(IOException.class, () -> httpClient.execute(request));
assertThat(requestCounter).isEqualTo(1);
}
@Test
public void givenDefaultConfiguration_whenHttpPutRequest_thenRetryIsNotApplied() {
createFailingHttpClient();
HttpPut request = new HttpPut(URI.create("https://httpstat.us/500"));
assertThrows(IOException.class, () -> httpClient.execute(request));
assertThat(requestCounter).isEqualTo(1);
}
@Test
public void givenConfiguredRetryHandler_whenHttpPostRequest_thenRetriesPerformed() {
createHttpClientWithRetryHandler();
HttpPost request = new HttpPost(URI.create("https://httpstat.us/200"));
assertThrows(IOException.class, () -> httpClient.execute(request));
assertThat(requestCounter).isEqualTo(7);
}
@Test
public void givenCustomRetryHandler_whenUnknownHostException_thenRetryAnyway() {
createHttpClientWithCustomRetryHandler();
HttpGet request = new HttpGet(URI.create("https://domain.that.does.not.exist/200"));
assertThrows(IOException.class, () -> httpClient.execute(request));
assertThat(requestCounter).isEqualTo(5);
}
@Test
public void givenDisabledRetries_whenExecutedHttpRequestEndUpWithIOException_thenRetryIsNotApplied() {
createHttpClientWithRetriesDisabled();
HttpGet request = new HttpGet(URI.create("https://httpstat.us/200"));
assertThrows(IOException.class, () -> httpClient.execute(request));
assertThat(requestCounter).isEqualTo(1);
}
}

View File

@ -171,7 +171,8 @@
<configuration>
<argLine>
--add-opens java.base/java.time=ALL-UNNAMED
--add-opens java.base/java.nio=ALL-UNNAMED
--add-opens
java.base/java.nio=ALL-UNNAMED
--add-opens java.base/java.util=ALL-UNNAMED
</argLine>
</configuration>
@ -179,8 +180,6 @@
</plugins>
</build>
<properties>
<kafka.version>3.4.0</kafka.version>
<testcontainers-kafka.version>1.15.3</testcontainers-kafka.version>

View File

@ -7,7 +7,7 @@ import org.junit.Test;
import com.baeldung.apache.beam.intro.WordCount;
public class WordCountUnitTest {
public class WordCountIntegrationTest {
@Test
public void givenInputFile_whenWordCountRuns_thenJobFinishWithoutError() {

View File

@ -7,7 +7,6 @@
<version>1.0-SNAPSHOT</version>
<name>apache-spark</name>
<packaging>jar</packaging>
<url>http://maven.apache.org</url>
<parent>
<groupId>com.baeldung</groupId>

View File

@ -2,7 +2,6 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.baeldung</groupId>
<artifactId>ShippingFunction</artifactId>
<version>1.0</version>
<name>ShippingFunction</name>

View File

@ -1,6 +1,6 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>helloworld</groupId>
<artifactId>ToDoFunction</artifactId>

View File

@ -103,7 +103,8 @@
<configuration>
<argLine>
--add-opens java.base/java.util=ALL-UNNAMED
--add-opens java.base/java.util.concurrent=ALL-UNNAMED
--add-opens
java.base/java.util.concurrent=ALL-UNNAMED
</argLine>
</configuration>
</plugin>

View File

@ -7,7 +7,6 @@
<version>1.0-SNAPSHOT</version>
<name>checker-plugin</name>
<packaging>jar</packaging>
<url>http://maven.apache.org</url>
<parent>
<groupId>com.baeldung</groupId>

View File

@ -4,7 +4,6 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>core-groovy-2</artifactId>
<version>1.0-SNAPSHOT</version>
<name>core-groovy-2</name>
<packaging>jar</packaging>
@ -153,14 +152,6 @@
</plugins>
</build>
<repositories>
<repository>
<id>maven_central</id>
<name>Maven Central</name>
<url>https://repo.maven.apache.org/maven2/</url>
</repository>
</repositories>
<properties>
<groovy-wslite.version>1.1.3</groovy-wslite.version>
<assembly.plugin.version>3.4.2</assembly.plugin.version>

View File

@ -4,7 +4,6 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>core-groovy-collections</artifactId>
<version>1.0-SNAPSHOT</version>
<name>core-groovy-collections</name>
<packaging>jar</packaging>
@ -111,13 +110,4 @@
</plugins>
</build>
<repositories>
<repository>
<id>maven_central</id>
<name>Maven Central</name>
<url>https://repo.maven.apache.org/maven2/</url>
</repository>
</repositories>
</project>

View File

@ -4,7 +4,6 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>core-groovy-strings</artifactId>
<version>1.0-SNAPSHOT</version>
<name>core-groovy-strings</name>
<packaging>jar</packaging>
@ -101,12 +100,4 @@
</plugins>
</build>
<repositories>
<repository>
<id>maven_central</id>
<name>Maven Central</name>
<url>https://repo.maven.apache.org/maven2/</url>
</repository>
</repositories>
</project>

View File

@ -3,9 +3,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>core-groovy</artifactId>
<version>1.0-SNAPSHOT</version>
<name>core-groovy</name>
<packaging>jar</packaging>
@ -102,12 +100,4 @@
</plugins>
</build>
<repositories>
<repository>
<id>maven_central</id>
<name>Maven Central</name>
<url>https://repo.maven.apache.org/maven2/</url>
</repository>
</repositories>
</project>

View File

@ -4,7 +4,6 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>core-java-10</artifactId>
<version>0.1.0-SNAPSHOT</version>
<name>core-java-10</name>
<packaging>jar</packaging>

View File

@ -4,7 +4,6 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>core-java-11-2</artifactId>
<version>0.1.0-SNAPSHOT</version>
<name>core-java-11-2</name>
<packaging>jar</packaging>

View File

@ -4,7 +4,6 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>core-java-11-3</artifactId>
<version>0.1.0-SNAPSHOT</version>
<name>core-java-11-3</name>
<packaging>jar</packaging>
@ -14,7 +13,7 @@
<version>1.0.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<dependencies>
<dependency>
<groupId>com.google.code.gson</groupId>

View File

@ -4,10 +4,8 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>core-java-11</artifactId>
<version>0.1.0-SNAPSHOT</version>
<name>core-java-11</name>
<packaging>jar</packaging>
<url>http://maven.apache.org</url>
<parent>
<groupId>com.baeldung</groupId>

View File

@ -4,10 +4,8 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>core-java-12</artifactId>
<version>0.1.0-SNAPSHOT</version>
<name>core-java-12</name>
<packaging>jar</packaging>
<url>http://maven.apache.org</url>
<parent>
<groupId>com.baeldung</groupId>

View File

@ -3,12 +3,9 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.baeldung</groupId>
<artifactId>core-java-13</artifactId>
<version>0.1.0-SNAPSHOT</version>
<name>core-java-13</name>
<packaging>jar</packaging>
<url>http://maven.apache.org</url>
<parent>
<groupId>com.baeldung</groupId>

View File

@ -6,7 +6,6 @@
<artifactId>core-java-14</artifactId>
<name>core-java-14</name>
<packaging>jar</packaging>
<url>http://maven.apache.org</url>
<parent>
<groupId>com.baeldung</groupId>

View File

@ -6,7 +6,6 @@
<artifactId>core-java-15</artifactId>
<name>core-java-15</name>
<packaging>jar</packaging>
<url>http://maven.apache.org</url>
<parent>
<groupId>com.baeldung</groupId>

View File

@ -4,10 +4,8 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>core-java-16</artifactId>
<version>0.1.0-SNAPSHOT</version>
<name>core-java-16</name>
<packaging>jar</packaging>
<url>http://maven.apache.org</url>
<parent>
<groupId>com.baeldung</groupId>

View File

@ -4,10 +4,8 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>core-java-17</artifactId>
<version>0.1.0-SNAPSHOT</version>
<name>core-java-17</name>
<packaging>jar</packaging>
<url>http://maven.apache.org</url>
<parent>
<groupId>com.baeldung</groupId>

View File

@ -1,21 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>core-java-19</artifactId>
<name>core-java-19</name>
<parent>
<groupId>com.baeldung.core-java-modules</groupId>
<artifactId>core-java-modules</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>core-java-19</artifactId>
<properties>
<maven.compiler.source>19</maven.compiler.source>
<maven.compiler.target>19</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
@ -30,4 +26,10 @@
</plugins>
</build>
<properties>
<maven.compiler.source>19</maven.compiler.source>
<maven.compiler.target>19</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>

View File

@ -0,0 +1,20 @@
package com.baeldung.highcpu;
import java.util.LinkedList;
import java.util.List;
import java.util.function.IntUnaryOperator;
import java.util.stream.IntStream;
public class Application {
static List<Integer> generateList() {
return IntStream.range(0, 10000000).parallel().map(IntUnaryOperator.identity()).collect(LinkedList::new, List::add, List::addAll);
}
public static void main(String[] args) {
List<Integer> list = generateList();
long start = System.nanoTime();
int value = list.get(9500000);
System.out.printf("Found value %d in %d nanos\n", value, (System.nanoTime() - start));
}
}

View File

@ -4,7 +4,6 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>core-java-8-2</artifactId>
<version>0.1.0-SNAPSHOT</version>
<name>core-java-8-2</name>
<packaging>jar</packaging>

View File

@ -0,0 +1,40 @@
package com.baeldung.helpervsutilityclasses;
class MyHelperClass {
public double discount;
public MyHelperClass(double discount) {
if (discount > 0 && discount < 1) {
this.discount = discount;
}
}
public double discountedPrice(double price) {
return price - (price * discount);
}
public static int getMaxNumber(int[] numbers) {
if (numbers.length == 0) {
throw new IllegalArgumentException("Ensure array is not empty");
}
int max = numbers[0];
for (int i = 1; i < numbers.length; i++) {
if (numbers[i] > max) {
max = numbers[i];
}
}
return max;
}
public static int getMinNumber(int[] numbers) {
if (numbers.length == 0) {
throw new IllegalArgumentException("Ensure array is not empty");
}
int min = numbers[0];
for (int i = 1; i < numbers.length; i++) {
if (numbers[i] < min) {
min = numbers[i];
}
}
return min;
}
}

View File

@ -0,0 +1,19 @@
package com.baeldung.helpervsutilityclasses;
public final class MyUtilityClass {
private MyUtilityClass(){}
public static String returnUpperCase(String stringInput) {
return stringInput.toUpperCase();
}
public static String returnLowerCase(String stringInput) {
return stringInput.toLowerCase();
}
public static String[] splitStringInput(String stringInput, String delimiter) {
return stringInput.split(delimiter);
}
}

View File

@ -0,0 +1,20 @@
package com.baeldung.helpervsutilityclasses;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;
class MyHelperClassUnitTest {
@Test
void whenCreatingHelperObject_thenHelperObjectShouldBeCreated() {
MyHelperClass myHelperClassObject = new MyHelperClass(0.10);
int[] numberArray = {15, 23, 66, 3, 51, 79};
assertNotNull(myHelperClassObject);
assertEquals(90, myHelperClassObject.discountedPrice(100.00));
assertEquals( 79, MyHelperClass.getMaxNumber(numberArray));
assertEquals(3, MyHelperClass.getMinNumber(numberArray));
}
}

View File

@ -0,0 +1,15 @@
package com.baeldung.helpervsutilityclasses;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;
class MyUtilityClassUnitTest {
@Test
void whenUsingUtilityMethods_thenAccessMethodsViaClassName(){
assertEquals( "INIUBONG", MyUtilityClass.returnUpperCase("iniubong"));
assertEquals("accra", MyUtilityClass.returnLowerCase("AcCrA"));
}
}

View File

@ -4,7 +4,6 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>core-java-8-datetime-2</artifactId>
<version>${project.parent.version}</version>
<name>core-java-8-datetime-2</name>
<packaging>jar</packaging>

View File

@ -4,7 +4,6 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>core-java-8-datetime</artifactId>
<version>${project.parent.version}</version>
<name>core-java-8-datetime</name>
<packaging>jar</packaging>

View File

@ -4,7 +4,6 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>core-java-8</artifactId>
<version>0.1.0-SNAPSHOT</version>
<name>core-java-8</name>
<packaging>jar</packaging>

View File

@ -4,7 +4,6 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>core-java-9-improvements</artifactId>
<version>0.2-SNAPSHOT</version>
<name>core-java-9-improvements</name>
<parent>

View File

@ -4,7 +4,6 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>core-java-9-jigsaw</artifactId>
<version>0.2-SNAPSHOT</version>
<name>core-java-9-jigsaw</name>
<parent>

View File

@ -4,7 +4,6 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>core-java-9-new-features</artifactId>
<version>0.2-SNAPSHOT</version>
<name>core-java-9-new-features</name>
<parent>

View File

@ -4,7 +4,6 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>core-java-9-streams</artifactId>
<version>0.1.0-SNAPSHOT</version>
<name>core-java-9-streams</name>
<packaging>jar</packaging>

View File

@ -5,7 +5,6 @@ This module contains articles about Java 9 core features
### Relevant Articles:
- [Method Handles in Java](https://www.baeldung.com/java-method-handles)
- [Introduction to Chronicle Queue](https://www.baeldung.com/java-chronicle-queue)
- [Iterate Through a Range of Dates in Java](https://www.baeldung.com/java-iterate-date-range)
- [Initialize a HashMap in Java](https://www.baeldung.com/java-initialize-hashmap)
- [Immutable ArrayList in Java](https://www.baeldung.com/java-immutable-list)

View File

@ -4,7 +4,6 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>core-java-9</artifactId>
<version>0.2-SNAPSHOT</version>
<name>core-java-9</name>
<parent>

View File

@ -4,7 +4,6 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>core-java-annotations</artifactId>
<version>0.1.0-SNAPSHOT</version>
<name>core-java-annotations</name>
<packaging>jar</packaging>
@ -24,4 +23,12 @@
</resources>
</build>
<dependencies>
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<version>1.3.2</version>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,6 @@
## Core Java Booleans
This module contains articles about Java Booleans.
### Relevant Articles:
- [Convert Boolean to String in Java](https://www.baeldung.com/java-convert-boolean-to-string)

View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>core-java-booleans</artifactId>
<name>core-java-booleans</name>
<packaging>jar</packaging>
<parent>
<groupId>com.baeldung.core-java-modules</groupId>
<artifactId>core-java-modules</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
</project>

View File

@ -0,0 +1,48 @@
package com.baeldung.booleans;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
public class BooleanToStringUnitTest {
String optionToString(String optionName, boolean optionValue) {
return String.format("The option '%s' is %s.", optionName, optionValue ? "Enabled" : "Disabled");
}
@Test
void givenPrimitiveBoolean_whenConvertingUsingTernaryOperator_thenSuccess() {
boolean primitiveBoolean = true;
assertEquals("true", primitiveBoolean ? "true" : "false");
primitiveBoolean = false;
assertEquals("false", primitiveBoolean ? "true" : "false");
assertEquals("The option 'IgnoreWarnings' is Enabled.", optionToString("IgnoreWarnings", true));
}
@Test
void givenBooleanObject_whenConvertingUsingBooleanToString_thenSuccess() {
Boolean myBoolean = Boolean.TRUE;
assertEquals("true", myBoolean.toString());
myBoolean = Boolean.FALSE;
assertEquals("false", myBoolean.toString());
Boolean nullBoolean = null;
assertThrows(NullPointerException.class, () -> nullBoolean.toString());
}
@Test
void givenBooleanObject_whenConvertingUsingStringValueOf_thenSuccess() {
Boolean myBoolean = Boolean.TRUE;
assertEquals("true", String.valueOf(myBoolean));
myBoolean = Boolean.FALSE;
assertEquals("false", String.valueOf(myBoolean));
Boolean nullBoolean = null;
assertEquals("null", String.valueOf(nullBoolean));
}
}

View File

@ -4,7 +4,6 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>core-java-char</artifactId>
<version>0.1.0-SNAPSHOT</version>
<name>core-java-char</name>
<packaging>jar</packaging>

View File

@ -4,7 +4,6 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>core-java-collections-3</artifactId>
<version>0.1.0-SNAPSHOT</version>
<name>core-java-collections-3</name>
<packaging>jar</packaging>

View File

@ -4,7 +4,6 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>core-java-collections-4</artifactId>
<version>0.1.0-SNAPSHOT</version>
<name>core-java-collections-4</name>
<packaging>jar</packaging>

View File

@ -1,10 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>core-java-collections-5</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>core-java-collections-5</name>
<packaging>jar</packaging>
@ -55,4 +54,5 @@
<roaringbitmap.version>0.9.38</roaringbitmap.version>
<jmh.version>1.36</jmh.version>
</properties>
</project>

View File

@ -4,34 +4,6 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>core-java-collections-array-list</artifactId>
<version>0.1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${maven-compiler-plugin.source}</source>
<target>${maven-compiler-plugin.target}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${surefire.plugin.version}</version>
<configuration>
<argLine>
--add-opens java.base/java.util=ALL-UNNAMED
</argLine>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<maven-compiler-plugin.source>16</maven-compiler-plugin.source>
<maven-compiler-plugin.target>16</maven-compiler-plugin.target>
<surefire.plugin.version>3.0.0-M3</surefire.plugin.version>
</properties>
<name>core-java-collections-array-list</name>
<packaging>jar</packaging>
@ -55,4 +27,33 @@
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${maven-compiler-plugin.source}</source>
<target>${maven-compiler-plugin.target}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${surefire.plugin.version}</version>
<configuration>
<argLine>
--add-opens java.base/java.util=ALL-UNNAMED
</argLine>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<maven-compiler-plugin.source>16</maven-compiler-plugin.source>
<maven-compiler-plugin.target>16</maven-compiler-plugin.target>
<surefire.plugin.version>3.0.0-M3</surefire.plugin.version>
</properties>
</project>

View File

@ -4,7 +4,6 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>core-java-collections-conversions-2</artifactId>
<version>0.1.0-SNAPSHOT</version>
<name>core-java-collections-conversions-2</name>
<packaging>jar</packaging>

View File

@ -9,6 +9,7 @@ import java.util.Collection;
*/
public class UserList {
public UserList() {}
private Collection<User> users;
public Collection<User> getUsers() {

View File

@ -4,7 +4,6 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>core-java-collections-conversions</artifactId>
<version>0.1.0-SNAPSHOT</version>
<name>core-java-collections-conversions</name>
<packaging>jar</packaging>

View File

@ -4,7 +4,6 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>core-java-collections-list-2</artifactId>
<version>0.1.0-SNAPSHOT</version>
<name>core-java-collections-list-2</name>
<packaging>jar</packaging>

View File

@ -4,7 +4,6 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>core-java-collections-list-3</artifactId>
<version>0.1.0-SNAPSHOT</version>
<name>core-java-collections-list-3</name>
<packaging>jar</packaging>

View File

@ -4,7 +4,6 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>core-java-collections-list-4</artifactId>
<version>0.1.0-SNAPSHOT</version>
<name>core-java-collections-list-4</name>
<packaging>jar</packaging>

View File

@ -4,7 +4,6 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>core-java-collections-list-5</artifactId>
<version>0.1.0-SNAPSHOT</version>
<name>core-java-collections-list-5</name>
<packaging>jar</packaging>

View File

@ -4,7 +4,6 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>core-java-collections-list</artifactId>
<version>0.1.0-SNAPSHOT</version>
<name>core-java-collections-list</name>
<packaging>jar</packaging>

View File

@ -6,6 +6,7 @@ import com.baeldung.java_8_features.Person;
import org.junit.Test;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.NoSuchElementException;
@ -71,4 +72,17 @@ public class Java8MaxMinUnitTest {
assertEquals(bugatti, maxBySpeed);
}
@Test
public void givenIntegerList_whenGetMinAndIndex_thenSuccess() {
final List<Integer> listOfIntegers = Arrays.asList(11, 13, 9, 20, 7, 3, 30);
final Integer expectedMinValue = 3;
final Integer expectedMinIndex = 5;
Integer minValue = Collections.min(listOfIntegers);
Integer minIndex = listOfIntegers.indexOf(minValue);
assertEquals(minValue, expectedMinValue);
assertEquals(minIndex, expectedMinIndex);
}
}

View File

@ -4,7 +4,6 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>core-java-collections-maps-2</artifactId>
<version>0.1.0-SNAPSHOT</version>
<name>core-java-collections-maps-2</name>
<packaging>jar</packaging>

View File

@ -4,7 +4,6 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>core-java-collections-maps-3</artifactId>
<version>0.1.0-SNAPSHOT</version>
<name>core-java-collections-maps-3</name>
<packaging>jar</packaging>

View File

@ -4,7 +4,6 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>core-java-collections-maps-4</artifactId>
<version>0.1.0-SNAPSHOT</version>
<name>core-java-collections-maps-4</name>
<packaging>jar</packaging>

View File

@ -4,7 +4,6 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>core-java-collections-maps-5</artifactId>
<version>0.1.0-SNAPSHOT</version>
<name>core-java-collections-maps-5</name>
<packaging>jar</packaging>

View File

@ -1,17 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>core-java-collections-maps-6</artifactId>
<version>0.1.0-SNAPSHOT</version>
<name>core-java-collections-maps-6</name>
<packaging>jar</packaging>
<parent>
<artifactId>core-java-modules</artifactId>
<groupId>com.baeldung.core-java-modules</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<properties>
<spring.version>5.2.5.RELEASE</spring.version>

View File

@ -4,7 +4,6 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>core-java-collections-maps</artifactId>
<version>0.1.0-SNAPSHOT</version>
<name>core-java-collections-maps</name>
<packaging>jar</packaging>

View File

@ -4,7 +4,6 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>core-java-collections-set-2</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>core-java-collections-set-2</name>
<packaging>jar</packaging>

View File

@ -4,7 +4,6 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>core-java-collections-set</artifactId>
<version>0.1.0-SNAPSHOT</version>
<name>core-java-collections-set</name>
<packaging>jar</packaging>

View File

@ -4,7 +4,6 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>core-java-collections</artifactId>
<version>0.1.0-SNAPSHOT</version>
<name>core-java-collections</name>
<packaging>jar</packaging>

View File

@ -4,7 +4,6 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>core-java-concurrency-2</artifactId>
<version>0.1.0-SNAPSHOT</version>
<name>core-java-concurrency-2</name>
<packaging>jar</packaging>

View File

@ -4,7 +4,6 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>core-java-concurrency-advanced-2</artifactId>
<version>0.1.0-SNAPSHOT</version>
<name>core-java-concurrency-advanced-2</name>
<packaging>jar</packaging>

View File

@ -2,7 +2,8 @@ package com.baeldung.concurrent.prioritytaskexecution;
import org.junit.Test;
public class PriorityJobSchedulerUnitTest {
//Converted to ManualTest due to thread sleep
public class PriorityJobSchedulerManualTest {
private static final int POOL_SIZE = 1;
private static final int QUEUE_SIZE = 10;

View File

@ -4,7 +4,6 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>core-java-concurrency-advanced-3</artifactId>
<version>0.1.0-SNAPSHOT</version>
<name>core-java-concurrency-advanced-3</name>
<packaging>jar</packaging>

View File

@ -4,7 +4,6 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>core-java-concurrency-advanced-4</artifactId>
<version>0.1.0-SNAPSHOT</version>
<name>core-java-concurrency-advanced-4</name>
<packaging>jar</packaging>
@ -14,9 +13,6 @@
<version>0.0.1-SNAPSHOT</version>
</parent>
<dependencies>
</dependencies>
<build>
<finalName>core-java-concurrency-advanced-4</finalName>
<plugins>

View File

@ -4,7 +4,6 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>core-java-concurrency-advanced</artifactId>
<version>0.1.0-SNAPSHOT</version>
<name>core-java-concurrency-advanced</name>
<packaging>jar</packaging>

View File

@ -1,9 +1,14 @@
package com.baeldung.concurrent.countdownlatch;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.List;
import java.util.concurrent.CountDownLatch;
public class Worker implements Runnable {
private static Logger log = LoggerFactory.getLogger(Worker.class);
private final List<String> outputScraper;
private final CountDownLatch countDownLatch;
@ -15,7 +20,7 @@ public class Worker implements Runnable {
@Override
public void run() {
// Do some work
System.out.println("Doing some logic");
log.debug("Doing some logic");
outputScraper.add("Counted down");
countDownLatch.countDown();
}

View File

@ -1,8 +1,13 @@
package com.baeldung.concurrent.phaser;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.concurrent.Phaser;
class LongRunningAction implements Runnable {
private static Logger log = LoggerFactory.getLogger(LongRunningAction.class);
private String threadName;
private Phaser ph;
@ -14,18 +19,18 @@ class LongRunningAction implements Runnable {
@Override
public void run() {
System.out.println("This is phase " + ph.getPhase());
System.out.println("Thread " + threadName + " before long running action");
log.info("This is phase {}", ph.getPhase());
log.info("Thread {} before long running action", threadName);
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println("Thread " + threadName + " action completed and waiting for others");
log.debug("Thread {} action completed and waiting for others", threadName);
ph.arriveAndAwaitAdvance();
System.out.println("Thread " + threadName + " proceeding in phase " + ph.getPhase());
log.debug("Thread {} proceeding in phase {}", threadName, ph.getPhase());
ph.arriveAndDeregister();
}

View File

@ -4,6 +4,9 @@ import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runners.MethodSorters;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Phaser;
@ -13,6 +16,8 @@ import static junit.framework.TestCase.assertEquals;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class PhaserUnitTest {
private static Logger log = LoggerFactory.getLogger(PhaserUnitTest.class);
@Test
public void givenPhaser_whenCoordinateWorksBetweenThreads_thenShouldCoordinateBetweenMultiplePhases() {
//given
@ -26,19 +31,19 @@ public class PhaserUnitTest {
executorService.submit(new LongRunningAction("thread-3", ph));
//then
System.out.println("Thread " + Thread.currentThread().getName() + " waiting for others");
log.debug("Thread {} waiting for others", Thread.currentThread().getName());
ph.arriveAndAwaitAdvance();
System.out.println("Thread " + Thread.currentThread().getName() + " proceeding in phase " + ph.getPhase());
log.debug("Thread {} proceeding in phase {}", Thread.currentThread().getName(), ph.getPhase());
assertEquals(1, ph.getPhase());
//and
executorService.submit(new LongRunningAction("thread-4", ph));
executorService.submit(new LongRunningAction("thread-5", ph));
System.out.println("Thread " + Thread.currentThread().getName() + " waiting for others");
log.debug("Thread {} waiting for others", Thread.currentThread().getName());
ph.arriveAndAwaitAdvance();
System.out.println("Thread " + Thread.currentThread().getName() + " proceeding in phase " + ph.getPhase());
log.debug("Thread {} proceeding in phase {}", Thread.currentThread().getName(), ph.getPhase());
assertEquals(2, ph.getPhase());

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
</pattern>
</encoder>
</appender>
<logger name="org.springframework" level="WARN" />
<logger name="org.springframework.transaction" level="WARN" />
<!-- in order to debug some marshalling issues, this needs to be TRACE -->
<logger name="org.springframework.web.servlet.mvc" level="WARN" />
<root level="INFO">
<appender-ref ref="STDOUT" />
</root>
</configuration>

View File

@ -4,7 +4,6 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>core-java-concurrency-basic-2</artifactId>
<version>0.1.0-SNAPSHOT</version>
<name>core-java-concurrency-basic-2</name>
<packaging>jar</packaging>

View File

@ -4,7 +4,6 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>core-java-concurrency-basic-3</artifactId>
<version>0.1.0-SNAPSHOT</version>
<name>core-java-concurrency-basic-3</name>
<packaging>jar</packaging>
@ -14,6 +13,15 @@
<version>0.0.1-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
<version>${awaitility.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>core-java-concurrency-basic-3</finalName>
<resources>
@ -28,12 +36,4 @@
<awaitility.version>4.2.0</awaitility.version>
</properties>
<dependencies>
<dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
<version>${awaitility.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

@ -4,7 +4,6 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>core-java-concurrency-basic</artifactId>
<version>0.1.0-SNAPSHOT</version>
<name>core-java-concurrency-basic</name>
<packaging>jar</packaging>

View File

@ -3,7 +3,6 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>core-java-concurrency-collections-2</artifactId>
<version>0.1.0-SNAPSHOT</version>
<name>core-java-concurrency-collections-2</name>
<packaging>jar</packaging>

View File

@ -4,7 +4,6 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>core-java-concurrency-collections</artifactId>
<version>0.1.0-SNAPSHOT</version>
<name>core-java-concurrency-collections</name>
<packaging>jar</packaging>

View File

@ -3,7 +3,6 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>core-java-concurrency-simple</artifactId>
<version>0.1.0-SNAPSHOT</version>
<name>core-java-concurrency-simple</name>
<packaging>jar</packaging>

View File

@ -4,7 +4,6 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>core-java-console</artifactId>
<version>0.1.0-SNAPSHOT</version>
<name>core-java-console</name>
<packaging>jar</packaging>

View File

@ -4,7 +4,6 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>core-java-date-operations-1</artifactId>
<version>${project.parent.version}</version>
<name>core-java-date-operations-1</name>
<packaging>jar</packaging>

View File

@ -4,7 +4,6 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>core-java-date-operations-2</artifactId>
<version>${project.parent.version}</version>
<name>core-java-date-operations-2</name>
<packaging>jar</packaging>

View File

@ -5,4 +5,5 @@ This module contains articles about date operations in Java.
- [Create Date From Unix Timestamp in Java](https://www.baeldung.com/java-date-unix-timestamp)
- [Convert java.util.Date to java.sql.Date](https://www.baeldung.com/java-convert-util-date-to-sql)
- [How to Determine Date of the First Day of the Week Using LocalDate in Java](https://www.baeldung.com/java-first-day-of-the-week)
- [[<-- Prev]](/core-java-modules/core-java-date-operations-2)

View File

@ -4,7 +4,6 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>core-java-date-operations-3</artifactId>
<version>${project.parent.version}</version>
<name>core-java-date-operations-3</name>
<packaging>jar</packaging>
@ -14,10 +13,4 @@
<version>0.0.1-SNAPSHOT</version>
</parent>
<dependencies>
</dependencies>
<properties>
</properties>
</project>

View File

@ -4,7 +4,6 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>core-java-datetime-string-2</artifactId>
<version>${project.parent.version}</version>
<name>core-java-datetime-string-2</name>
<packaging>jar</packaging>

View File

@ -4,7 +4,6 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>core-java-datetime-string</artifactId>
<version>${project.parent.version}</version>
<name>core-java-datetime-string</name>
<packaging>jar</packaging>
@ -20,7 +19,6 @@
<artifactId>commons-lang3</artifactId>
<version>${commons-lang3.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-validator/commons-validator -->
<dependency>
<groupId>commons-validator</groupId>
<artifactId>commons-validator</artifactId>

View File

@ -5,8 +5,6 @@
<artifactId>core-java-exceptions-2</artifactId>
<name>core-java-exceptions-2</name>
<packaging>jar</packaging>
<description> </description>
<url>http://maven.apache.org</url>
<parent>
<groupId>com.baeldung.core-java-modules</groupId>

View File

@ -3,9 +3,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.baeldung.exceptions</groupId>
<artifactId>core-java-exceptions-3</artifactId>
<version>0.1.0-SNAPSHOT</version>
<name>core-java-exceptions-3</name>
<packaging>jar</packaging>

View File

@ -3,9 +3,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.baeldung.exceptions</groupId>
<artifactId>core-java-exceptions-4</artifactId>
<version>0.1.0-SNAPSHOT</version>
<name>core-java-exceptions-4</name>
<packaging>jar</packaging>

View File

@ -3,9 +3,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.baeldung.exceptions</groupId>
<artifactId>core-java-exceptions</artifactId>
<version>0.1.0-SNAPSHOT</version>
<name>core-java-exceptions</name>
<packaging>jar</packaging>

View File

@ -4,7 +4,6 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>core-java-function</artifactId>
<version>0.1.0-SNAPSHOT</version>
<name>core-java-function</name>
<packaging>jar</packaging>

View File

@ -4,7 +4,6 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>core-java-functional</artifactId>
<version>0.1.0-SNAPSHOT</version>
<name>core-java-functional</name>
<packaging>jar</packaging>

Some files were not shown because too many files have changed in this diff Show More