<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Java on tty4.dev</title>
    <link>https://tty4.dev/tags/java/</link>
    <description>Recent content in Java on tty4.dev</description>
    <generator>Hugo</generator>
    <language>en-us</language>
    <copyright>© Dennis Kawurek</copyright>
    <lastBuildDate>Fri, 20 Dec 2024 19:34:11 +0100</lastBuildDate>
    <atom:link href="https://tty4.dev/tags/java/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Hexagonal Architecture: The Good And The Hard Parts</title>
      <link>https://tty4.dev/development/hexagonal-architecture-the-good-and-hard-parts/</link>
      <pubDate>Fri, 20 Dec 2024 19:34:11 +0100</pubDate>
      <guid>https://tty4.dev/development/hexagonal-architecture-the-good-and-hard-parts/</guid>
      <description>&lt;p&gt;There&amp;rsquo;s a lot of stuff written about Hexagonal Architecture. I also wrote some things about it, but covered just the basics.&lt;/p&gt;&#xA;&lt;p&gt;Now with more experience of using the Hexagonal Architecture style in Java with Spring Boot, I thought it&amp;rsquo;s time to reflect what are the good and the hard parts of it.&lt;/p&gt;&#xA;&lt;h2 id=&#34;few-words-for-the-beginning&#34;&gt;Few Words For The Beginning&lt;/h2&gt;&#xA;&lt;p&gt;You may notice that I don&amp;rsquo;t write &amp;ldquo;The Good And The Bad Parts&amp;rdquo;. That&amp;rsquo;s because on one side I really like the application of Hexagonal Architecture in the context of professional work. On the other side I found that the &amp;ldquo;hard parts&amp;rdquo; are a challenge in nearly every architecture style and not just in Hexagonal Architecture.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Define An Extensible Or Generic JPA Repository</title>
      <link>https://tty4.dev/development/spring-jpa-generic-repository/</link>
      <pubDate>Sun, 20 Oct 2024 11:22:29 +0200</pubDate>
      <guid>https://tty4.dev/development/spring-jpa-generic-repository/</guid>
      <description>&lt;p&gt;The &lt;code&gt;@NoRepositoryBean&lt;/code&gt; annotation allows to define an extensible / generic JPA repository in Spring Boot:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-java&#34; data-lang=&#34;java&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;@NoRepositoryBean&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;public&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;interface&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;BaseAnimalRepository&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;&amp;lt;&lt;/span&gt;T&lt;span style=&#34;color:#f92672&#34;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;extends&lt;/span&gt; JpaRepository&lt;span style=&#34;color:#f92672&#34;&gt;&amp;lt;&lt;/span&gt;T, Long&lt;span style=&#34;color:#f92672&#34;&gt;&amp;gt;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;From the &lt;a href=&#34;https://docs.spring.io/spring-data/commons/docs/current/api/org/springframework/data/repository/NoRepositoryBean.html&#34;&gt;documentation&lt;/a&gt; of the &lt;code&gt;@NoRepositoryBean&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;This will typically be used when providing an extended base interface for all repositories in combination with a custom repository base class to implement methods declared in that intermediate interface. In this case you typically derive your concrete repository interfaces from the intermediate one but don&amp;rsquo;t want to create a Spring bean for the intermediate interface.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Capture Logs In Spring Boot Tests</title>
      <link>https://tty4.dev/development/spring-capture-logs/</link>
      <pubDate>Fri, 11 Oct 2024 20:01:10 +0200</pubDate>
      <guid>https://tty4.dev/development/spring-capture-logs/</guid>
      <description>&lt;p&gt;To assert that a specific message is logged in a Spring Boot application, the &lt;a href=&#34;https://docs.spring.io/spring-boot/api/java/org/springframework/boot/test/system/OutputCaptureExtension.html&#34;&gt;&lt;code&gt;OutputCaptureExtension&lt;/code&gt;&lt;/a&gt; can be used.&lt;/p&gt;&#xA;&lt;p&gt;Here&amp;rsquo;s an example test:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-java&#34; data-lang=&#34;java&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;@ExtendWith&lt;/span&gt;(OutputCaptureExtension.&lt;span style=&#34;color:#a6e22e&#34;&gt;class&lt;/span&gt;)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;public&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;class&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;MyServiceTest&lt;/span&gt; {&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#66d9ef&#34;&gt;private&lt;/span&gt; MyService myService &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;new&lt;/span&gt; MyService();&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#66d9ef&#34;&gt;private&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;static&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;final&lt;/span&gt; String MESSAGE &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Hello World!&amp;#34;&lt;/span&gt;;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#a6e22e&#34;&gt;@Test&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#66d9ef&#34;&gt;public&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;void&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;testLogMessage&lt;/span&gt;(CapturedOutput output) {&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        myService.&lt;span style=&#34;color:#a6e22e&#34;&gt;logMessage&lt;/span&gt;(MESSAGE);&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        assertThat(output.&lt;span style=&#34;color:#a6e22e&#34;&gt;getOut&lt;/span&gt;()).&lt;span style=&#34;color:#a6e22e&#34;&gt;contains&lt;/span&gt;(MESSAGE);&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    }&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;}&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The &lt;a href=&#34;https://docs.spring.io/spring-boot/api/java/org/springframework/boot/test/system/CapturedOutput.html&#34;&gt;&lt;code&gt;CapturedOutput&lt;/code&gt;&lt;/a&gt; API serves different methods to get the output.&lt;/p&gt;</description>
    </item>
    <item>
      <title>About: How Netflix Really Uses Java</title>
      <link>https://tty4.dev/development/about-how-netflix-really-uses-java/</link>
      <pubDate>Fri, 01 Mar 2024 20:26:10 +0100</pubDate>
      <guid>https://tty4.dev/development/about-how-netflix-really-uses-java/</guid>
      <description>&lt;p&gt;&lt;a href=&#34;https://www.infoq.com/presentations/netflix-java/&#34;&gt;This talk about &amp;ldquo;How Netflix Really Uses Java&amp;rdquo;&lt;/a&gt; by Paul Bakker at QCon gives some interesting insights.&lt;/p&gt;&#xA;&lt;p&gt;Especially the first ~20 minutes about the overall architecture and how it evolved is nice to see.&lt;/p&gt;&#xA;&lt;p&gt;But, beside of that there were some other think pieces about using Java at higher scale:&lt;/p&gt;&#xA;&lt;p&gt;Netflix tries to save resources and money, by leveraging configurable Java features like Garbage Collection.&lt;/p&gt;&#xA;&lt;p&gt;Also, Netflix seemed to be trying to use &lt;code&gt;RxJava&lt;/code&gt;, but found some downsides, as many devs did: It is really hard to understand and debug. Some people say it&amp;rsquo;s hard to develop, because you need to exactly think about what &lt;em&gt;could&lt;/em&gt; happen in beforehand.&#xA;But this can also slow down development.&lt;/p&gt;</description>
    </item>
    <item>
      <title>How Spring MVC Handles Requests: A Detailed View</title>
      <link>https://tty4.dev/development/spring/spring-mvc-request-handling-detail/</link>
      <pubDate>Sun, 04 Feb 2024 20:54:10 +0100</pubDate>
      <guid>https://tty4.dev/development/spring/spring-mvc-request-handling-detail/</guid>
      <description>&lt;p&gt;In my last post I already about the high-level view of &lt;a href=&#34;https://tty4.dev/development/spring/spring-mvc-high-level-view&#34;&gt;how Spring MVC handles incoming requests&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;h2 id=&#34;foreword&#34;&gt;Foreword&lt;/h2&gt;&#xA;&lt;p&gt;This post provides a more detailed view of how Spring handles requests like this:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-java&#34; data-lang=&#34;java&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;@PostMapping&lt;/span&gt;(value &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;login&amp;#34;&lt;/span&gt;, consumes &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; MediaType.&lt;span style=&#34;color:#a6e22e&#34;&gt;APPLICATION_JSON_VALUE&lt;/span&gt;)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;public&lt;/span&gt; String &lt;span style=&#34;color:#a6e22e&#34;&gt;login&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;@RequestBody&lt;/span&gt; User user)  {&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Logged in!&amp;#34;&lt;/span&gt;;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;}&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;However, please note: It pertains to version 6.1 of the Spring Framework and may change in the future. Furthermore, it only covers the request processing from the filter chain until the resolution of the request body.&lt;/p&gt;</description>
    </item>
    <item>
      <title>The high-level view of how Spring MVC handles requests</title>
      <link>https://tty4.dev/development/spring/spring-mvc-high-level-view/</link>
      <pubDate>Sat, 03 Feb 2024 19:01:10 +0100</pubDate>
      <guid>https://tty4.dev/development/spring/spring-mvc-high-level-view/</guid>
      <description>&lt;p&gt;In the recent days I tried to understand how Spring Boot handles requests like this:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-java&#34; data-lang=&#34;java&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;@PostMapping&lt;/span&gt;(value &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;login&amp;#34;&lt;/span&gt;, consumes &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; MediaType.&lt;span style=&#34;color:#a6e22e&#34;&gt;APPLICATION_JSON_VALUE&lt;/span&gt;)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;public&lt;/span&gt; String &lt;span style=&#34;color:#a6e22e&#34;&gt;login&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;@RequestBody&lt;/span&gt; User user)  {&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Logged in!&amp;#34;&lt;/span&gt;;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;}&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Spring MVC is responsible for the handling.&lt;/p&gt;&#xA;&lt;p&gt;The result is this high-level overview of it which separates its work in three blocks:&lt;/p&gt;&#xA;&lt;p&gt;&lt;img src=&#34;https://tty4.dev/spring/high_level_view_request_mapping_spring_boot.svg&#34; alt=&#34;&#34;&gt;&lt;/p&gt;&#xA;&lt;p&gt;A post with a more detailed view follows, but the main block with the component which controls everything is shown in the image: The &lt;a href=&#34;https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/web/servlet/DispatcherServlet.html&#34;&gt;DispatcherServlet&lt;/a&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Spring: Bind values in x-www-form-urlencoded requests</title>
      <link>https://tty4.dev/development/spring/spring-boot-bind-param/</link>
      <pubDate>Tue, 30 Jan 2024 19:59:10 +0100</pubDate>
      <guid>https://tty4.dev/development/spring/spring-boot-bind-param/</guid>
      <description>&lt;p&gt;In Spring Boot it&amp;rsquo;s not possible to map request field names to property fields with &lt;code&gt;@JsonProperty&lt;/code&gt; when a request method is consuming &lt;code&gt;application/x-www-form-urlencoded&lt;/code&gt; type of requests. The reason is that there&amp;rsquo;s no JSON payload in the body to consume.&lt;/p&gt;&#xA;&lt;p&gt;To resolve this &lt;a href=&#34;https://docs.spring.io/spring-framework/docs/6.1.x/javadoc-api/org/springframework/web/bind/annotation/BindParam.html&#34;&gt;&lt;code&gt;@BindParam&lt;/code&gt;&lt;/a&gt; has to be used.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt; This feature is available since Spring 6.1. and Spring Boot 3.2.0.&lt;/p&gt;&#xA;&lt;p&gt;Check the following working example:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-java&#34; data-lang=&#34;java&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;@RestController&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;@RequestMapping&lt;/span&gt;(path &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;/user/&amp;#34;&lt;/span&gt;)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;public&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;class&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;UserController&lt;/span&gt; {&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#a6e22e&#34;&gt;@PostMapping&lt;/span&gt;(value &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;login&amp;#34;&lt;/span&gt;, consumes &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; MediaType.&lt;span style=&#34;color:#a6e22e&#34;&gt;APPLICATION_FORM_URLENCODED_VALUE&lt;/span&gt;)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#66d9ef&#34;&gt;public&lt;/span&gt; String &lt;span style=&#34;color:#a6e22e&#34;&gt;login&lt;/span&gt;(User user)  {&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#75715e&#34;&gt;// user.username is not null&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Logged in!&amp;#34;&lt;/span&gt;;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    }&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#a6e22e&#34;&gt;@Data&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#a6e22e&#34;&gt;@AllArgsConstructor&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#66d9ef&#34;&gt;public&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;static&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;class&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;User&lt;/span&gt; {&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#a6e22e&#34;&gt;@BindParam&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;user_name&amp;#34;&lt;/span&gt;)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#66d9ef&#34;&gt;private&lt;/span&gt; String username;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#66d9ef&#34;&gt;private&lt;/span&gt; String password;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    }&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;}&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The &lt;code&gt;username&lt;/code&gt; property will get the value of the &lt;code&gt;user_name&lt;/code&gt; field passed in the request. That behaves the same as using the &lt;code&gt;@JsonProperty&lt;/code&gt; in requests of the type &lt;code&gt;application/json&lt;/code&gt; with Jackson.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Aggregate exceptions in Spring with ControllerAdvice</title>
      <link>https://tty4.dev/development/spring-controlleradvice/</link>
      <pubDate>Sun, 21 Jan 2024 15:26:10 +0100</pubDate>
      <guid>https://tty4.dev/development/spring-controlleradvice/</guid>
      <description>&lt;p&gt;Exceptions can affect the readability of code in a negative way. One way to mitigate this is to handle exceptions in one central place.&lt;/p&gt;&#xA;&lt;p&gt;In Spring Boot you can use &lt;code&gt;@ControllerAdvice&lt;/code&gt; for this.&lt;/p&gt;&#xA;&lt;p&gt;I&amp;rsquo;ll show an example, but keep in mind that there&amp;rsquo;s more than shown here. So, read up the Javadoc for &lt;a href=&#34;https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/web/bind/annotation/ControllerAdvice.html&#34;&gt;ControllerAdvice&lt;/a&gt; to get more information on the features and ways to configure it.&lt;/p&gt;&#xA;&lt;h2 id=&#34;the-problem&#34;&gt;The problem&lt;/h2&gt;&#xA;&lt;p&gt;Let&amp;rsquo;s say the following exception is thrown anywhere in the code:&lt;/p&gt;</description>
    </item>
    <item>
      <title>Javadoc Generation Error: Bad HTML Entity</title>
      <link>https://tty4.dev/development/javadoc-use-ampersand/</link>
      <pubDate>Sun, 07 Jan 2024 12:24:10 +0100</pubDate>
      <guid>https://tty4.dev/development/javadoc-use-ampersand/</guid>
      <description>&lt;p&gt;Recently when I tried to generate some Javadoc I got an error like this:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-fallback&#34; data-lang=&#34;fallback&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;error: bad HTML entity&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     * Get the current date &amp;amp; time.&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The generation fails as Javadoc tries to get the character entity although an ampersand character (&lt;code&gt;&amp;amp;&lt;/code&gt;) is no character entity.&lt;/p&gt;&#xA;&lt;p&gt;I think of 3 different solutions for it.&lt;/p&gt;&#xA;&lt;h2 id=&#34;use-the-character-entity&#34;&gt;Use the character entity&lt;/h2&gt;&#xA;&lt;p&gt;One solution for it can be to just use the character entity:&lt;/p&gt;</description>
    </item>
    <item>
      <title>Suppressing unchecked cast warnings with Spring CastUtils</title>
      <link>https://tty4.dev/development/spring/spring-castutils/</link>
      <pubDate>Sun, 17 Dec 2023 23:24:10 +0100</pubDate>
      <guid>https://tty4.dev/development/spring/spring-castutils/</guid>
      <description>&lt;p&gt;Let&amp;rsquo;s say there are classes which are types of &lt;code&gt;Vehicle&lt;/code&gt;. For example:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-java&#34; data-lang=&#34;java&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;public&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;class&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;Bike&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;extends&lt;/span&gt; Vehicle {}&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;public&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;class&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;Car&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;extends&lt;/span&gt; Vehicle {}&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now, when there&amp;rsquo;s a class with a method that returns a &lt;code&gt;T&lt;/code&gt; it may look like this:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-java&#34; data-lang=&#34;java&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;public&lt;/span&gt; T &lt;span style=&#34;color:#a6e22e&#34;&gt;getVehicle&lt;/span&gt;(String type) {&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#66d9ef&#34;&gt;if&lt;/span&gt; (Objects.&lt;span style=&#34;color:#a6e22e&#34;&gt;equals&lt;/span&gt;(type, &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;car&amp;#34;&lt;/span&gt;)) {&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; carWorker.&lt;span style=&#34;color:#a6e22e&#34;&gt;get&lt;/span&gt;();&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    }&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; bikeWorker.&lt;span style=&#34;color:#a6e22e&#34;&gt;get&lt;/span&gt;();&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;}&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;small&gt;&lt;em&gt;Note&lt;/em&gt;: That&amp;rsquo;s a simplified method to focus on the problem.&lt;/small&gt;&lt;/p&gt;&#xA;&lt;p&gt;The IDE will show directly the error that &lt;code&gt;Vehicle&lt;/code&gt; or &lt;code&gt;Car&lt;/code&gt; is not of type &lt;code&gt;T&lt;/code&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Clone before use: preventing TOCTOU attacks</title>
      <link>https://tty4.dev/development/prevent-toctou-attacks/</link>
      <pubDate>Sun, 17 Dec 2023 17:24:10 +0100</pubDate>
      <guid>https://tty4.dev/development/prevent-toctou-attacks/</guid>
      <description>&lt;p&gt;Mutable variables can lead to vulnerabilities or unexpected behavior.&lt;/p&gt;&#xA;&lt;p&gt;Consider the following piece of code as a demonstration:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-Java&#34; data-lang=&#34;Java&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;public&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;boolean&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;checkDomain&lt;/span&gt;(HttpCookie httpCookie) {&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#66d9ef&#34;&gt;if&lt;/span&gt; (httpCookie &lt;span style=&#34;color:#f92672&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;null&lt;/span&gt;) {&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#66d9ef&#34;&gt;throw&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;new&lt;/span&gt; NullPointerException();&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    }&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#66d9ef&#34;&gt;if&lt;/span&gt; (httpCookie.&lt;span style=&#34;color:#a6e22e&#34;&gt;hasExpired&lt;/span&gt;()) {&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#75715e&#34;&gt;// throw exception&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    }&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; isDomainValid(httpCookie.&lt;span style=&#34;color:#a6e22e&#34;&gt;getDomain&lt;/span&gt;());&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;}&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;What could go wrong here? The problem with this code is that the method doesn&amp;rsquo;t has any control about what happens with the &lt;code&gt;httpCookie&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;So, the value of it could change between the check (&lt;code&gt;if&lt;/code&gt;-clause) and the use (&lt;code&gt;return&lt;/code&gt; statement). E.g. the cookie&amp;rsquo;s domain could be changed before it is checked.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Using VSCode as a Java IDE</title>
      <link>https://tty4.dev/development/vscode-as-java-ide/</link>
      <pubDate>Sat, 16 Dec 2023 10:30:00 +0100</pubDate>
      <guid>https://tty4.dev/development/vscode-as-java-ide/</guid>
      <description>&lt;p&gt;Some unsorted thoughts about using VSCode as a Java development environment.&lt;/p&gt;&#xA;&lt;p&gt;I tried more than once to use VSCode as my Java editor, but it didn&amp;rsquo;t give me the same experience as IntelliJ IDEA.&lt;/p&gt;&#xA;&lt;p&gt;The UX was often really low and sometimes I just didn&amp;rsquo;t understand why I got error pop-ups or where I can find the settings for my use case.&lt;/p&gt;&#xA;&lt;p&gt;There is a lot more to say like the low debugging-experience in VSCode while IntelliJ is outstanding in many matters or how tight the integration of Java into IntelliJ is.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Bring Java CRaC into your IDE (VSCode and a little bit about IntelliJ IDEA)</title>
      <link>https://tty4.dev/development/crac-ide/</link>
      <pubDate>Fri, 15 Dec 2023 15:46:00 +0100</pubDate>
      <guid>https://tty4.dev/development/crac-ide/</guid>
      <description>&lt;p&gt;After &lt;a href=&#34;https://tty4.dev/development/java-crac&#34;&gt;looking at CRaC&lt;/a&gt; I thought it would be nice to create checkpoints from within an IDE.&#xA;It&amp;rsquo;s more comfortable, to do it from within the IDE then using the CLI.&#xA;Furthermore it may be easier to do it when you start your service every time with the &lt;code&gt;-XX:CRaCCheckpointTo&lt;/code&gt; command.&lt;/p&gt;&#xA;&lt;p&gt;The code is in &lt;a href=&#34;https://github.com/CRaC/example-spring-boot/compare/master...denniskawurek:crac-example-spring-boot:master&#34;&gt;this commit on GitHub&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;h2 id=&#34;key-takeaways&#34;&gt;Key takeaways&lt;/h2&gt;&#xA;&lt;p&gt;Before I show you how I did it for VSCode here are some takeaways:&lt;/p&gt;</description>
    </item>
    <item>
      <title>Java CRaC</title>
      <link>https://tty4.dev/development/java-crac/</link>
      <pubDate>Thu, 14 Dec 2023 16:46:00 +0100</pubDate>
      <guid>https://tty4.dev/development/java-crac/</guid>
      <description>&lt;p&gt;Java is not a language which is famous for its fast startup-time when using a framework like Spring.&#xA;Sometimes you need this when running time-sensitive applications or for example functions as a service which build on top of fast start-up times.&lt;/p&gt;&#xA;&lt;p&gt;Luckily there&amp;rsquo;s some work regarding this like GraalVM or CDS.&lt;/p&gt;&#xA;&lt;p&gt;Another feature which promises to solve this problem is built on top of Linux&amp;rsquo; &lt;a href=&#34;https://criu.org/Main_Page&#34;&gt;CRIU&lt;/a&gt; and is called &lt;em&gt;Coordinated Restore at Checkpoint&lt;/em&gt; or abbreviated &lt;strong&gt;CRaC&lt;/strong&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Java Generics: Upper Bounded and Lower Bounded Wildcards</title>
      <link>https://tty4.dev/development/upper-lower-bounded-wildcards/</link>
      <pubDate>Thu, 16 Nov 2023 22:09:10 +0100</pubDate>
      <guid>https://tty4.dev/development/upper-lower-bounded-wildcards/</guid>
      <description>&lt;p&gt;I already took a look at the &lt;a href=&#34;https://tty4.dev/development/wildcards-what&#34;&gt;difference between Wildcards and Types&lt;/a&gt; in Java.&lt;/p&gt;&#xA;&lt;p&gt;Now it&amp;rsquo;s time to take a closer look at Wildcards. Specifically, bounded and unbounded wildcards.&lt;/p&gt;&#xA;&lt;p&gt;You may sometimes came across this when seeing either this signature parameter or error message:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-java&#34; data-lang=&#34;java&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;List&lt;span style=&#34;color:#f92672&#34;&gt;&amp;lt;?&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;super&lt;/span&gt; Animal&lt;span style=&#34;color:#f92672&#34;&gt;&amp;gt;&lt;/span&gt; animals&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-gdscript3&#34; data-lang=&#34;gdscript3&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;capture of &lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;?&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;extends&lt;/span&gt; Animal&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Let&amp;rsquo;s see what this means.&lt;/p&gt;&#xA;&lt;h2 id=&#34;bounded-wildcards&#34;&gt;Bounded Wildcards&lt;/h2&gt;&#xA;&lt;p&gt;Generally, bounded wildcards can be used to relax or restrict wildcard variables.&lt;/p&gt;&#xA;&lt;p&gt;There are two of them: Lower Bounded Wildcards and Upper Bounded Wildcards.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Java Generics: When to use Wildcards and when to use Types?</title>
      <link>https://tty4.dev/development/wildcards-what/</link>
      <pubDate>Thu, 16 Nov 2023 22:09:00 +0100</pubDate>
      <guid>https://tty4.dev/development/wildcards-what/</guid>
      <description>&lt;p&gt;When reading &lt;em&gt;Effective Java&lt;/em&gt; by Joshua Bloch I came across the chapter about Generics and the difference between using Wildcards and Types.&lt;/p&gt;&#xA;&lt;p&gt;I did some further research to understand it more and this is the write up of it. Let it confuse you as much as me or let it be helpful.&lt;/p&gt;&#xA;&lt;h2 id=&#34;when-to-use-which&#34;&gt;When to use which&lt;/h2&gt;&#xA;&lt;p&gt;I found three statements which describe when to use what:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;&lt;em&gt;If a type parameter appears only once in the declaration, then replace it with a wildcard.&lt;/em&gt; (&lt;em&gt;Effective Java&lt;/em&gt; by Joshua Bloch)&lt;/p&gt;</description>
    </item>
    <item>
      <title>The crucial distinction between equals and compareTo in Java</title>
      <link>https://tty4.dev/development/java-equals-comparable/</link>
      <pubDate>Thu, 21 Sep 2023 20:35:00 +0200</pubDate>
      <guid>https://tty4.dev/development/java-equals-comparable/</guid>
      <description>&lt;p&gt;&amp;hellip; or: Why 1 is not equals 1.0 when using BigDecimal.&lt;/p&gt;&#xA;&lt;p&gt;Languages have sometimes their own special behavior, which you need to know when you want to use it right.&lt;/p&gt;&#xA;&lt;p&gt;Sometimes you forget about it and then you remember some specific behavior when you try to use it.Let&amp;rsquo;s take a look at the crucial difference between &lt;code&gt;equals&lt;/code&gt; and &lt;code&gt;compareTo&lt;/code&gt; in Java.&lt;/p&gt;&#xA;&lt;h2 id=&#34;equals-of-bigdecimal&#34;&gt;&lt;code&gt;equals&lt;/code&gt; of &lt;code&gt;BigDecimal&lt;/code&gt;&lt;/h2&gt;&#xA;&lt;p&gt;Look at this two &lt;code&gt;BigDecimal&lt;/code&gt;s:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-java&#34; data-lang=&#34;java&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;final&lt;/span&gt; BigDecimal BIG_DECIMAL_1 &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; BigDecimal.&lt;span style=&#34;color:#a6e22e&#34;&gt;valueOf&lt;/span&gt;(1);&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;final&lt;/span&gt; BigDecimal BIG_DECIMAL_1_0 &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; BigDecimal.&lt;span style=&#34;color:#a6e22e&#34;&gt;valueOf&lt;/span&gt;(1.&lt;span style=&#34;color:#a6e22e&#34;&gt;0&lt;/span&gt;);&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Normally you&amp;rsquo;d say that they have two equal values, and should be equal, because &lt;code&gt;1 = 1.0&lt;/code&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>How to get Spring STOMP to parse messages successfully</title>
      <link>https://tty4.dev/development/spring/2023-09-10-spring-stomp-parsing-troubleshooting/</link>
      <pubDate>Sun, 10 Sep 2023 15:04:00 +0200</pubDate>
      <guid>https://tty4.dev/development/spring/2023-09-10-spring-stomp-parsing-troubleshooting/</guid>
      <description>&lt;p&gt;Recently I updated my article about &lt;a href=&#34;https://tty4.dev/development/spring/spring-stomp-client&#34;&gt;STOMP in Spring Boot&lt;/a&gt; and faced some issues to get a running example with the latest Spring Boot and websocket version.&lt;/p&gt;&#xA;&lt;p&gt;I tested the code with Spring Boot 3 and the version &lt;code&gt;3.2.0-SNAPSHOT&lt;/code&gt; of the websocket library. My problem was that the message which I received wasn&amp;rsquo;t parsed correct.&lt;/p&gt;&#xA;&lt;p&gt;Here are some notes to attack and prevent some of the appeared problems. Maybe they&amp;rsquo;re helpful for someone (or me in the future).&lt;/p&gt;</description>
    </item>
    <item>
      <title>All Java 21</title>
      <link>https://tty4.dev/development/all-java-21/</link>
      <pubDate>Mon, 21 Aug 2023 02:00:00 -0100</pubDate>
      <guid>https://tty4.dev/development/all-java-21/</guid>
      <description>&lt;p&gt;Just few days left until Java 21 is generally available (September 19, 2023).&lt;/p&gt;&#xA;&lt;p&gt;I&amp;rsquo;ve read and collected resources which discuss all the features which 21 will bring.&lt;/p&gt;&#xA;&lt;p&gt;You can follow the schedule one the page of the &lt;a href=&#34;https://openjdk.org/projects/jdk/21/&#34;&gt;OpenJDK&lt;/a&gt; project.&lt;/p&gt;&#xA;&lt;h2 id=&#34;the-four-available-jeps&#34;&gt;The four available JEPs&lt;/h2&gt;&#xA;&lt;p&gt;Namely, there are 4 JEPs which are final and can be used in production:&lt;/p&gt;&#xA;&lt;h3 id=&#34;jep-431-sequenced-collectionshttpsopenjdkorgjeps431&#34;&gt;JEP 431: &lt;a href=&#34;https://openjdk.org/jeps/431&#34;&gt;Sequenced collections&lt;/a&gt;&lt;/h3&gt;&#xA;&lt;p&gt;Enhances the Java collection framework with a &lt;code&gt;Collection&lt;/code&gt; that contains elements in a particular order. The &lt;code&gt;SequencedCollection&lt;/code&gt; interface has been introduced for this.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Testcontainers in Spring Boot 3.1</title>
      <link>https://tty4.dev/development/2023-08-18-testcontainers-spring-boot-3/</link>
      <pubDate>Fri, 18 Aug 2023 09:00:00 -0100</pubDate>
      <guid>https://tty4.dev/development/2023-08-18-testcontainers-spring-boot-3/</guid>
      <description>&lt;p&gt;I already wrote two times about Testcontainers. Once I showed an example for the usage in &lt;a href=&#34;https://tty4.dev/development/testcontainers-simple-example/&#34;&gt;Spring Boot&lt;/a&gt;.&#xA;And the other time how to &lt;a href=&#34;https://tty4.dev/development/2022-11-25-testcontainers-revisited/&#34;&gt;manage the lifecycle state&lt;/a&gt; and tear the connection down.&lt;/p&gt;&#xA;&lt;p&gt;Spring Boot 3.1 changed the way how you &lt;em&gt;can&lt;/em&gt; use Testcontainers. There are a lot ways to use Testcontainers and now there&amp;rsquo;s another, far easier way to do it.&lt;/p&gt;&#xA;&lt;h2 id=&#34;before-spring-boot-31&#34;&gt;Before Spring Boot 3.1&lt;/h2&gt;&#xA;&lt;p&gt;Before Spring Boot 3.1 you had two ways to connect to a Testcontainer.&lt;/p&gt;</description>
    </item>
    <item>
      <title>JUnit 5: Annotations for @ParametrizedTest</title>
      <link>https://tty4.dev/development/parametrized-test/</link>
      <pubDate>Wed, 16 Aug 2023 02:00:00 -0100</pubDate>
      <guid>https://tty4.dev/development/parametrized-test/</guid>
      <description>&lt;p&gt;I like the idea of &lt;a href=&#34;https://junit.org/junit5/docs/current/user-guide/#writing-tests-parameterized-tests&#34;&gt;parametrized tests in JUnit 5&lt;/a&gt;. Instead of writing 5 methods for one method and just changing the arguments, write the test case once and serve the arguments as a stream.&lt;/p&gt;&#xA;&lt;p&gt;This makes refactoring and maintenance of test code far easier.&lt;/p&gt;&#xA;&lt;p&gt;But, when you want to implement a ParametrizedTest you need to use the correct annotations and sources for the arguments.&lt;/p&gt;&#xA;&lt;p&gt;Check the following example:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-java&#34; data-lang=&#34;java&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;@ExtendWith&lt;/span&gt;(SpringExtension.&lt;span style=&#34;color:#a6e22e&#34;&gt;class&lt;/span&gt;)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;@ContextConfiguration&lt;/span&gt;(classes &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; {DeviceService.&lt;span style=&#34;color:#a6e22e&#34;&gt;class&lt;/span&gt;})&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;public&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;class&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;DeviceServiceTest&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;{&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;   &lt;span style=&#34;color:#a6e22e&#34;&gt;@Autowired&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;   &lt;span style=&#34;color:#66d9ef&#34;&gt;private&lt;/span&gt; DeviceService deviceService;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;   &lt;span style=&#34;color:#66d9ef&#34;&gt;private&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;static&lt;/span&gt; Stream&lt;span style=&#34;color:#f92672&#34;&gt;&amp;lt;&lt;/span&gt;Arguments&lt;span style=&#34;color:#f92672&#34;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;deviceArgs&lt;/span&gt;() {&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; Stream.&lt;span style=&#34;color:#a6e22e&#34;&gt;of&lt;/span&gt;(&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            Arguments.&lt;span style=&#34;color:#a6e22e&#34;&gt;of&lt;/span&gt;(Device.&lt;span style=&#34;color:#a6e22e&#34;&gt;builder&lt;/span&gt;().&lt;span style=&#34;color:#a6e22e&#34;&gt;deviceId&lt;/span&gt;(1).&lt;span style=&#34;color:#a6e22e&#34;&gt;name&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Raspberry Pi&amp;#34;&lt;/span&gt;).&lt;span style=&#34;color:#a6e22e&#34;&gt;build&lt;/span&gt;()),&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            Arguments.&lt;span style=&#34;color:#a6e22e&#34;&gt;of&lt;/span&gt;(Device.&lt;span style=&#34;color:#a6e22e&#34;&gt;builder&lt;/span&gt;().&lt;span style=&#34;color:#a6e22e&#34;&gt;deviceId&lt;/span&gt;(2).&lt;span style=&#34;color:#a6e22e&#34;&gt;name&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Banana Pi&amp;#34;&lt;/span&gt;).&lt;span style=&#34;color:#a6e22e&#34;&gt;build&lt;/span&gt;())&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      );&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;   }&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;   &lt;span style=&#34;color:#a6e22e&#34;&gt;@ParameterizedTest&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;   &lt;span style=&#34;color:#a6e22e&#34;&gt;@MethodSource&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;deviceArgs&amp;#34;&lt;/span&gt;)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;   &lt;span style=&#34;color:#66d9ef&#34;&gt;public&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;void&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;storeDeviceTest&lt;/span&gt;(Device device) {&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      deviceService.&lt;span style=&#34;color:#a6e22e&#34;&gt;storeDevice&lt;/span&gt;(device);&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;   }&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;}&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;code&gt;streamDevices&lt;/code&gt; serves the Arguments. This method must be &lt;code&gt;static&lt;/code&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Event sourcing in Java: First steps</title>
      <link>https://tty4.dev/development/ddd/event-sourcing-java-approach/</link>
      <pubDate>Wed, 31 May 2023 10:00:00 -0100</pubDate>
      <guid>https://tty4.dev/development/ddd/event-sourcing-java-approach/</guid>
      <description>&lt;p&gt;This post belongs to a series about my &lt;a href=&#34;https://tty4.dev/development/ddd/ddd-journey&#34;&gt;DDD journey&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Check also: &lt;a href=&#34;https://tty4.dev/development/ddd/event-sourcing&#34;&gt;Concepts of Event Sourcing.&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;In this post I will write up my approach to implement event sourcing in a Java application. This sample application aims to give a feeling about the DDD building blocks and which challenges in event sourcing are coming up.&lt;/p&gt;&#xA;&lt;h2 id=&#34;the-service&#34;&gt;The service&lt;/h2&gt;&#xA;&lt;p&gt;Let&amp;rsquo;s assume that we shall build a service for a shop which contains clients and orders. As a first step we will build the service with the client model which applies event sourcing.&lt;/p&gt;</description>
    </item>
    <item>
      <title>A static search for my blog</title>
      <link>https://tty4.dev/development/static-search/</link>
      <pubDate>Sun, 30 Apr 2023 10:00:00 -0100</pubDate>
      <guid>https://tty4.dev/development/static-search/</guid>
      <description>&lt;p&gt;More than once I&amp;rsquo;ve been thinking about a static search for this blog.&lt;/p&gt;&#xA;&lt;p&gt;This site is using &lt;a href=&#34;https://gohugo.io&#34;&gt;Hugo&lt;/a&gt; as a site generator. There are some &lt;a href=&#34;https://gohugo.io/tools/search/&#34;&gt;search solutions&lt;/a&gt; for Hugo sites, but I thought it would be a fun project to work on and create a solution for my own.&lt;/p&gt;&#xA;&lt;p&gt;So I split the problem up in three parts:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Create a JSON-representation of my blog.&lt;/li&gt;&#xA;&lt;li&gt;Create an index out of this json representation.&lt;/li&gt;&#xA;&lt;li&gt;Search the index on the client-side.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;div class=&#34;mermaid&#34;&gt;flowchart LR&#xA;&#xA;subgraph js[&#39;Site generator&#39;]&#xA;    direction TB&#xA;    Blog(Page content)&#xA;    Blog --&gt; Hugo &#xA;    Hugo --&gt;|generate| JSON1(page.json)&#xA;end&#xA;&#xA;subgraph ig [&#39;Index generator&#39;]&#xA;    IG[Index Generator]&#xA;    JSON1 --&gt; IG&#xA;    IG --&gt;|generate| IDX(index.json)&#xA;end&#xA;&#xA;subgraph se[&#39;Search engine&#39;]&#xA;    IDX --&gt; SE[Search Engine]&#xA;    Terms(Search terms) --&gt; SE&#xA;    SE --&gt; |output| Res(Results)&#xA;end&#xA;&#xA;UI --&gt; Terms&#xA;  &lt;/div&gt;&#xA;  &lt;p&gt;The following sections are about the implementation and give insight to my thoughts.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Experiencing functional programming in Java</title>
      <link>https://tty4.dev/development/fp-java-idea/</link>
      <pubDate>Sun, 02 Apr 2023 01:00:00 -0100</pubDate>
      <guid>https://tty4.dev/development/fp-java-idea/</guid>
      <description>&lt;p&gt;In the recent days I&amp;rsquo;ve been working on my &lt;a href=&#34;https://tty4.dev/development/fp-java&#34;&gt;Functional Programming&lt;/a&gt; skills in Java.&lt;/p&gt;&#xA;&lt;p&gt;Reading about it and implementing small functions makes it easy to understand the basics. But it&amp;rsquo;s always better to have hands-on experience.&lt;/p&gt;&#xA;&lt;p&gt;So I gave myself the task to implement a service which creates a simple search index for this blog.&lt;/p&gt;&#xA;&lt;h2 id=&#34;the-idea&#34;&gt;The idea&lt;/h2&gt;&#xA;&lt;p&gt;The core idea is to realize the following flow:&lt;/p&gt;&#xA;&lt;div class=&#34;mermaid&#34;&gt;flowchart TD;&#xA;&#xA;PP(Pre process)&#xA;TK(Tokenize)&#xA;Syn(Add synonyms)&#xA;Idx(Add to index)&#xA;&#xA;subgraph Aggregate&#xA;&#xA;PP --&gt; |Processed page| TK --&gt; |Tokenized page| Syn --&gt; |Page with synonyms| Idx&#xA;end&#xA;&#xA;Trigger --&gt; |Page| PP&#xA;&#xA;Aggregate --&gt; Index&#xA;  &lt;/div&gt;&#xA;  &lt;p&gt;As you can see, this is already a pipe which can be realized through the chaining of functions:&lt;/p&gt;</description>
    </item>
    <item>
      <title>Functional Programming in Java</title>
      <link>https://tty4.dev/development/fp-java/</link>
      <pubDate>Sun, 12 Mar 2023 02:00:00 -0100</pubDate>
      <guid>https://tty4.dev/development/fp-java/</guid>
      <description>&lt;p&gt;Functional programming can be achieved in Java, though it needs a lot of discipline to not mix things up. This post discusses the different ways of doing things in a functional way in Java.&lt;/p&gt;&#xA;&lt;p&gt;When you know the basics of functional programming and want to start with that style in Java, you should keep the following interfaces in your mind:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-fallback&#34; data-lang=&#34;fallback&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;Supplier       ()    -&amp;gt; x&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;Consumer       x     -&amp;gt; ()&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;BiConsumer     x, y  -&amp;gt; ()&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;Callable       ()    -&amp;gt; x throws ex&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;Runnable       ()    -&amp;gt; ()&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;Function       x     -&amp;gt; y&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;BiFunction     x,y   -&amp;gt; z&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;Predicate      x     -&amp;gt; boolean&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;UnaryOperator  x1    -&amp;gt; x2&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;BinaryOperator x1,x2 -&amp;gt; x3&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;(&lt;a href=&#34;https://stackoverflow.com/questions/29945627/java-8-lambda-void-argument&#34;&gt;List from stackoverflow.com&lt;/a&gt;)&lt;/p&gt;</description>
    </item>
    <item>
      <title>The shift of thinking: Imperative vs. declarative programming</title>
      <link>https://tty4.dev/development/fp-imp-vs-decl/</link>
      <pubDate>Sat, 04 Mar 2023 02:00:00 -0100</pubDate>
      <guid>https://tty4.dev/development/fp-imp-vs-decl/</guid>
      <description>&lt;p&gt;A key characteristic of functional programming is the declarative way of describing how software shall behave.&lt;/p&gt;&#xA;&lt;p&gt;In contrast to that stands the imperative style, where you give step-by-step instructions what the program shall do.&lt;/p&gt;&#xA;&lt;h2 id=&#34;von-neumann-architecture&#34;&gt;Von Neumann Architecture&lt;/h2&gt;&#xA;&lt;p&gt;The reason why the imperative style lasts so long and is so old, lays in the way how computers work.&lt;/p&gt;&#xA;&lt;p&gt;The basis of our computers til today is the &lt;a href=&#34;https://en.wikipedia.org/wiki/Von_Neumann_architecture&#34;&gt;von Neumann architecture&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;In the von Neumann architecture the computer gets instructions which tell it how it should work.&#xA;So the algorithm is &lt;em&gt;imperative&lt;/em&gt; and tells which data should be loaded and which instruction shall be executed.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Java, Cloud, IoT Trends in 2023</title>
      <link>https://tty4.dev/no-category/trends-2023/</link>
      <pubDate>Tue, 03 Jan 2023 02:00:00 -0100</pubDate>
      <guid>https://tty4.dev/no-category/trends-2023/</guid>
      <description>&lt;p&gt;I hope you all had a good start into the new year! 2023 is just a few days old and it is not only time to look at the things that happened in the past year.&#xA;Here I want to give insights on to the trends which I think Cloud developers should keep an eye on. As my experience mainly lays in the cloud, java and IoT area, this is the part at which I&amp;rsquo;ll focus on here.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Testcontainers revisited: Managing the lifecycle of the database</title>
      <link>https://tty4.dev/development/2022-11-25-testcontainers-revisited/</link>
      <pubDate>Mon, 28 Nov 2022 02:00:00 -0100</pubDate>
      <guid>https://tty4.dev/development/2022-11-25-testcontainers-revisited/</guid>
      <description>&lt;div class=&#34;alert-low&#34;&gt;&#xA;&lt;p&gt;I created a follow-up for &lt;strong&gt;Spring Boot 3.1&lt;/strong&gt;. Check it &lt;a href=&#34;https://tty4.dev/development/2023-08-18-testcontainers-spring-boot-3/&#34;&gt;here&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Even when things changed, the concept of Testcontainers is the same and you can use it also in the way it is described here.&lt;/p&gt;&#xA;&lt;/div&gt;&#xA;&lt;p&gt;Few weeks ago I was &lt;a href=&#34;https://tty4.dev/development/testcontainers-simple-example&#34;&gt;taking a look at Testcontainers&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Two questions arrived:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;How to keep the database connection open and reuse it.&lt;/li&gt;&#xA;&lt;li&gt;Clean up the database between tests.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;The post was Spring Boot specific, but here I&amp;rsquo;ll also have a look at plain Java projects.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Using Testcontainers in a Spring Boot application with MariaDB</title>
      <link>https://tty4.dev/development/testcontainers-simple-example/</link>
      <pubDate>Sun, 13 Nov 2022 09:00:00 -0100</pubDate>
      <guid>https://tty4.dev/development/testcontainers-simple-example/</guid>
      <description>&lt;div class=&#34;alert-low&#34;&gt;&#xA;&lt;p&gt;I created a follow-up for &lt;strong&gt;Spring Boot 3.1&lt;/strong&gt;. Check it &lt;a href=&#34;https://tty4.dev/development/2023-08-18-testcontainers-spring-boot-3/&#34;&gt;here&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Even when things changed, the concept of Testcontainers is the same and you can use it also in the way it is described here.&lt;/p&gt;&#xA;&lt;/div&gt;&#xA;&lt;p&gt;When writing integration tests for a service one of the problems which need to be attacked is the database: You want to assure that an entry is really stored in the database.&lt;/p&gt;&#xA;&lt;p&gt;For that there are multiple ways, like using a test instance of a database, using a deployed database and use a prefix for all data for later deletion, a local database or an in-memory database like H2.&lt;/p&gt;</description>
    </item>
    <item>
      <title>How to use Mockito to test the behavior of a Java application - in a nutshell</title>
      <link>https://tty4.dev/development/mockito-unit-testing-nutshell/</link>
      <pubDate>Mon, 24 Oct 2022 02:00:00 -0100</pubDate>
      <guid>https://tty4.dev/development/mockito-unit-testing-nutshell/</guid>
      <description>&lt;p&gt;&lt;a href=&#34;https://site.mockito.org/&#34;&gt;Mockito&lt;/a&gt; is a really powerful tool. And even more: It&amp;rsquo;s documentation and logs are so good, that you don&amp;rsquo;t need to look at the documentation if you&amp;rsquo;re misusing it!&#xA;Here I&amp;rsquo;ll show some of the common functions I&amp;rsquo;m using with a small example.&lt;/p&gt;&#xA;&lt;h2 id=&#34;example-application&#34;&gt;Example application&lt;/h2&gt;&#xA;&lt;p&gt;I&amp;rsquo;ll show you an example application, which I&amp;rsquo;ll use within the next sections. The example may not to seem so logical, but it will show you the most important things.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Building and running a Docker container for a Java application</title>
      <link>https://tty4.dev/development/java-app-docker-locally/</link>
      <pubDate>Sat, 24 Sep 2022 09:00:00 -0100</pubDate>
      <guid>https://tty4.dev/development/java-app-docker-locally/</guid>
      <description>&lt;p&gt;There are different ways to build a Docker image locally of your Java application and start a container.&lt;/p&gt;&#xA;&lt;p&gt;This one is more of a step-by-step guide, which can also be automated by a local script. If you want you can also move the build steps into the Dockerfile, if it doesn&amp;rsquo;t give you any conflicts in a pipeline.&lt;/p&gt;&#xA;&lt;h2 id=&#34;the-dockerfile&#34;&gt;The Dockerfile&lt;/h2&gt;&#xA;&lt;p&gt;First, create a &lt;code&gt;Dockerfile&lt;/code&gt; in the root of your project. Consider to choose the right JDK version for your project.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Using DBRider for a clean state between JUnit tests</title>
      <link>https://tty4.dev/development/dbrider-for-clean-state-between-tests/</link>
      <pubDate>Fri, 05 Aug 2022 09:00:00 -0100</pubDate>
      <guid>https://tty4.dev/development/dbrider-for-clean-state-between-tests/</guid>
      <description>&lt;p&gt;Whenever you write Java/Spring Boot tests which are using database access (e.g. when running a &lt;code&gt;@SpringBootTest&lt;/code&gt;), you should clean up the database to have a clean state between your tests.&lt;/p&gt;&#xA;&lt;p&gt;In fact, this is not a trivial task as some of these problems can appear:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;You may need to check that you don&amp;rsquo;t insert or delete data between tests and provoke Unique Key or Foreign Key exceptions.&lt;/li&gt;&#xA;&lt;li&gt;You may tear down and set up the database between test runs.&lt;/li&gt;&#xA;&lt;li&gt;You could tend to define an order of test runs which works. But this is not good as this creates a &amp;lsquo;happy path&amp;rsquo; for your tests.&lt;/li&gt;&#xA;&lt;li&gt;You may tend to insert data always with already set primary keys. These primary keys are not allowed to be used by other tests. That&amp;rsquo;s not good as you need the knowledge of all these primary keys.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;But that&amp;rsquo;s not good! When you test the behavior of your application you should not implement extra database checks to make sure that before and after your test you have a good state of the database.&lt;/p&gt;</description>
    </item>
    <item>
      <title>How to fix H2 error: &#39;Syntax error in SQL statement ... expected identifier&#39;</title>
      <link>https://tty4.dev/development/fix-h2-error-expected-identifeir/</link>
      <pubDate>Sun, 29 May 2022 02:00:00 -0100</pubDate>
      <guid>https://tty4.dev/development/fix-h2-error-expected-identifeir/</guid>
      <description>&lt;p&gt;I had an Entity &lt;code&gt;User&lt;/code&gt; in my Spring Boot application and storing information with a &lt;code&gt;Repository&lt;/code&gt; to my MariaDB database worked fine.&lt;/p&gt;&#xA;&lt;p&gt;But when testing it with a H2 database, I got the following issue:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-fallback&#34; data-lang=&#34;fallback&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;Syntax error in SQL statement &amp;#34;select user0_.user_id as col_0_0_ from [*]user user0_ where user0_.email=? limit ?&amp;#34;; expected &amp;#34;identifier&amp;#34;; SQL statement:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;select user0_.user_id as col_0_0_ from user user0_ where user0_.email=? limit ? [42001-212]&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Well I know that H2 behaves sometimes different than MySQL even if you set the mode to MySQL. So I dig deeper.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Looking forward to Kotlin and Wasm</title>
      <link>https://tty4.dev/development/looking-forward-to-kotlin-and-wasm/</link>
      <pubDate>Tue, 05 Apr 2022 08:00:00 -0100</pubDate>
      <guid>https://tty4.dev/development/looking-forward-to-kotlin-and-wasm/</guid>
      <description>&lt;p&gt;Since 2018 I&amp;rsquo;m looking after the progress of &lt;a href=&#34;https://webassembly.org/&#34;&gt;WebAssembly&lt;/a&gt; as I think it is a quite interesting technology and can be the technology of the future.&lt;/p&gt;&#xA;&lt;p&gt;On the official Wasm page you can see which languages do &lt;a href=&#34;https://webassembly.org/getting-started/developers-guide/&#34;&gt;support the compilation to Wasm&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;However one very interesting thing for me is the support of Kotlin.&lt;/p&gt;&#xA;&lt;h2 id=&#34;the-current-state-of-kotlin-and-wasm&#34;&gt;The current state of Kotlin and Wasm&lt;/h2&gt;&#xA;&lt;p&gt;With the introduction of the new &lt;a href=&#34;https://blog.jetbrains.com/kotlin/2021/11/k2-compiler-kotlin-wasm-and-tooling-announcements-at-the-2021-kotlin-event/&#34;&gt;K2 compiler&lt;/a&gt; Kotlin also announced that there will be better and faster support for the compilation to Wasm.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Implementing a STOMP client in a Spring Boot application</title>
      <link>https://tty4.dev/development/spring/spring-stomp-client/</link>
      <pubDate>Sun, 13 Mar 2022 19:00:00 -0100</pubDate>
      <guid>https://tty4.dev/development/spring/spring-stomp-client/</guid>
      <description>&lt;p&gt;STOMP is a good and easy protocol to communicate in realtime via WebSockets.&lt;/p&gt;&#xA;&lt;p&gt;If you want to implement such a client in your Spring application, you can use  &lt;a href=&#34;https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/messaging/simp/stomp/package-summary.html&#34;&gt;Springs simp package&lt;/a&gt;, which provides all you need to start quickly.&lt;/p&gt;&#xA;&lt;h2 id=&#34;requirements&#34;&gt;Requirements&lt;/h2&gt;&#xA;&lt;p&gt;This article focuses on the STOMP client, so you need a server you can subscribe to and consume messages from. (See also: &lt;a href=&#34;https://tty4.dev/development/stomp-server-producer/&#34;&gt;A simple STOMP server &amp;amp; producer application&lt;/a&gt;)&lt;/p&gt;&#xA;&lt;p&gt;Also, you need the &lt;code&gt;spring-boot-starter-websocket&lt;/code&gt; library as a dependency. E.g. in Gradle:&lt;/p&gt;</description>
    </item>
    <item>
      <title>Output IntelliJ IDEA logs to a local file</title>
      <link>https://tty4.dev/development/intellij-logs-to-local-file/</link>
      <pubDate>Tue, 08 Mar 2022 16:00:00 -0100</pubDate>
      <guid>https://tty4.dev/development/intellij-logs-to-local-file/</guid>
      <description>&lt;p&gt;If you want to store logs of a Gradle run to a file, just add the filepath (including the name) via the UI.&lt;/p&gt;&#xA;&lt;p&gt;For this you need to follow these options:&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;RUN&lt;/code&gt; -&amp;gt; &lt;code&gt;Edit configurations&lt;/code&gt; -&amp;gt; &lt;code&gt;Application&lt;/code&gt; -&amp;gt; &lt;code&gt;Save console output to file...&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;This file is overwritten on every rerun.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Message ordering with Java Semaphores</title>
      <link>https://tty4.dev/development/java-semaphores-for-message-ordering/</link>
      <pubDate>Sun, 06 Mar 2022 22:00:00 -0100</pubDate>
      <guid>https://tty4.dev/development/java-semaphores-for-message-ordering/</guid>
      <description>&lt;p&gt;Semaphores are useful to limit the access of concurrent threads to a resource.&lt;/p&gt;&#xA;&lt;p&gt;This can be: A class instance, a variable or a method.&lt;/p&gt;&#xA;&lt;p&gt;You can use it to assert that in critical parts of your code no parallel requests are happening.&lt;/p&gt;&#xA;&lt;h2 id=&#34;example-use-case-ordered-messages&#34;&gt;Example use-case: Ordered messages&lt;/h2&gt;&#xA;&lt;p&gt;I used Semaphores in the financial world to assure, that time-sensitive messages had been send to an external resource in a specific order.&lt;/p&gt;&#xA;&lt;p&gt;Every message had an order number which was counted up on every send.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Spring @Scheduled annotation - fixedDelay vs. fixedRate</title>
      <link>https://tty4.dev/development/spring/spring-scheduled-fixeddelay-fixedrate/</link>
      <pubDate>Sun, 27 Feb 2022 08:00:00 -0100</pubDate>
      <guid>https://tty4.dev/development/spring/spring-scheduled-fixeddelay-fixedrate/</guid>
      <description>&lt;p&gt;Once I had some fun to debug a scheduled method which executes a request every 1 second.&lt;/p&gt;&#xA;&lt;p&gt;I got told, that it works fine, but the request seems to get missed now and then.&lt;/p&gt;&#xA;&lt;p&gt;We have been using Spring Boots &lt;code&gt;@Scheduled(fixedDelay = 1000)&lt;/code&gt; annotation:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-fallback&#34; data-lang=&#34;fallback&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;2022-01-24 11:13:47,974  INFO 160456 --- [   scheduling-1] c.m.n.controller.schedule.Scheduler   : Method executed!&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;2022-01-24 11:13:48,976  INFO 160456 --- [   scheduling-1] c.m.n.controller.schedule.Scheduler   : Method executed!&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;2022-01-24 11:13:49,991  INFO 160456 --- [   scheduling-1] c.m.n.controller.schedule.Scheduler   : Method executed!&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;2022-01-24 11:13:51,013  INFO 160456 --- [   scheduling-1] c.m.n.controller.schedule.Scheduler   : Method executed!&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;2022-01-24 11:13:52,016  INFO 160456 --- [   scheduling-1] c.m.n.controller.schedule.Scheduler   : Method executed!&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;2022-01-24 11:13:53,024  INFO 160456 --- [   scheduling-1] c.m.n.controller.schedule.Scheduler   : Method executed!&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You can see that the milliseconds counter rises. That is due the correct behavior of &lt;code&gt;fixedDelay&lt;/code&gt;: It executes the method every second after the last execution got finished.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Spring Boot and Kubernetes Configmaps</title>
      <link>https://tty4.dev/development/spring/spring-boot-kubernetes-configmap/</link>
      <pubDate>Thu, 17 Feb 2022 00:00:00 +0000</pubDate>
      <guid>https://tty4.dev/development/spring/spring-boot-kubernetes-configmap/</guid>
      <description>&lt;div class=&#34;alert-low&#34;&gt;&#xA;&lt;p&gt;This document was last revised on 2022-09-24 and updated for the usage with &lt;strong&gt;Spring Boot 3&lt;/strong&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Check the &lt;strong&gt;&lt;a href=&#34;https://github.com/denniskawurek/spring-boot-3-configmap-demo&#34;&gt;Repository&lt;/a&gt;&lt;/strong&gt; for an executable example.&lt;/p&gt;&#xA;&lt;/div&gt;&#xA;&lt;p&gt;Deploying your Spring Boot applications in a Kubernetes environment will bring you many benefits like for example the usage of Configmaps.&lt;/p&gt;&#xA;&lt;h2 id=&#34;what-are-configmaps&#34;&gt;What are Configmaps&lt;/h2&gt;&#xA;&lt;p&gt;Configmaps are API objects which store data in key-value pairs. This data can be consumed by your application as environment variables or CLI arguments.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Debugging with Gradle: See what happens during gradle builds</title>
      <link>https://tty4.dev/development/gradle-debug/</link>
      <pubDate>Mon, 17 Jan 2022 19:09:00 -0100</pubDate>
      <guid>https://tty4.dev/development/gradle-debug/</guid>
      <description>&lt;p&gt;Sometimes the normal &lt;code&gt;gradlew clean build&lt;/code&gt; doesn&amp;rsquo;t really help in the understanding why a gradle build fails.&lt;/p&gt;&#xA;&lt;p&gt;In my case this issue once occured when a build on a Jenkins server failed, but not on my local machine (&lt;em&gt;classic&lt;/em&gt;).&lt;/p&gt;&#xA;&lt;p&gt;So there are two things which can be really helpful when debugging failed gradle builds.&lt;/p&gt;&#xA;&lt;h1 id=&#34;being-very-verbose&#34;&gt;Being very verbose&lt;/h1&gt;&#xA;&lt;p&gt;The following command will print you information during the gradle build, which can help you during debugging.&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
