From 7efff00b389da94c62576f32f1deba4b20b27db8 Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Fri, 6 Feb 2026 19:34:06 +0100 Subject: [PATCH] Code-Listings mit einem von ChatGPT erzeugtem akw-Skript korrigiert MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit ```bash for i in `find content/blog/archive/ -type f`; do awk 'BEGIN { inblock = 0 } { line = $0 # START eines kaputten Codeblocks: # - beginnt (evtl. eingerückt) mit genau einem Backtick # - enthält danach KEINEN weiteren Backtick if (!inblock && match(line, /^[[:space:]]*`[^`]*$/)) { inblock = 1 # führende Spaces + erstes Backtick entfernen sub(/^[[:space:]]*`/, "", line) print "```" print line next } # ENDE eines kaputten Codeblocks: # Zeile enthält nur ein Backtick (evtl. eingerückt) if (inblock && match(line, /^[[:space:]]*`[[:space:]]*$/)) { inblock = 0 print "```" next } # Alles andere unverändert ausgeben print line } ' $i | sponge $i; done ``` --- .../hibernate4-maven-plugin-1-0-1-released.md | 5 +++-- .../2013/hibernate4-maven-plugin-1-0-2-release.md | 5 +++-- .../hibernate4-maven-plugin-1-0-3-released.md | 5 +++-- .../hibernate4-maven-plugin-1-0-4-released.md | 5 +++-- .../hibernate4-maven-plugin-1-0-5-released.md | 5 +++-- .../hibernate4-maven-plugin-1-1-0-released.md | 5 +++-- ...icating-partitioned-data-with-kafka-streams.md | 15 +++++++++------ ...ring-boot-based-on-configuration-properties.md | 15 +++++++++------ .../testing-exception-handling-in-spring-mvc.md | 3 ++- 9 files changed, 38 insertions(+), 25 deletions(-) diff --git a/content/blog/archive/2013/hibernate4-maven-plugin-1-0-1-released.md b/content/blog/archive/2013/hibernate4-maven-plugin-1-0-1-released.md index 11ca42a7..ea77ee21 100644 --- a/content/blog/archive/2013/hibernate4-maven-plugin-1-0-1-released.md +++ b/content/blog/archive/2013/hibernate4-maven-plugin-1-0-1-released.md @@ -24,7 +24,8 @@ Appart from two bugfixes, this version includes some minor improvements, which m ## Release notes: - ` +``` + commit 4b507b15b0122ac180e44b8418db8d9143ae9c3a Author: Kai Moritz Date: Tue Jan 15 23:09:01 2013 +0100 @@ -126,4 +127,4 @@ commit 2f3807b9fbde5c1230e3a22010932ddec722871b Author: Kai Moritz Date: Thu Nov 29 18:23:59 2012 +0100 Found annotated classes get logged now -` +``` diff --git a/content/blog/archive/2013/hibernate4-maven-plugin-1-0-2-release.md b/content/blog/archive/2013/hibernate4-maven-plugin-1-0-2-release.md index 15f38403..c76bfabd 100644 --- a/content/blog/archive/2013/hibernate4-maven-plugin-1-0-2-release.md +++ b/content/blog/archive/2013/hibernate4-maven-plugin-1-0-2-release.md @@ -28,7 +28,8 @@ This release includes: ## Release notes: - ` +``` + commit 4edef457d2b747d939a141de24bec5e32abbc0c7 Author: Kai Moritz Date: Fri Aug 2 00:37:40 2013 +0200 @@ -63,4 +64,4 @@ Date: Mon Feb 25 22:35:33 2013 +0100 Integration of the maven-plugin-plugin for automated helpmojo-generation Thanks to Adriano Machado, who contributed this patch! -` +``` diff --git a/content/blog/archive/2014/hibernate4-maven-plugin-1-0-3-released.md b/content/blog/archive/2014/hibernate4-maven-plugin-1-0-3-released.md index cccab9cb..3b3d35d5 100644 --- a/content/blog/archive/2014/hibernate4-maven-plugin-1-0-3-released.md +++ b/content/blog/archive/2014/hibernate4-maven-plugin-1-0-3-released.md @@ -36,7 +36,8 @@ Many thanks also to Stephen Johnson and Eduard Szente, who pointed out bugs and ## Release notes: - ` +``` + commit adb20bc4da63d4cec663ca68648db0f808e3d181 Author: Kai Moritz Date: Fri Oct 18 01:52:27 2013 +0200 @@ -163,4 +164,4 @@ Date: Sat Aug 31 08:51:03 2013 +0200 Best regards, Eduard -` +``` diff --git a/content/blog/archive/2014/hibernate4-maven-plugin-1-0-4-released.md b/content/blog/archive/2014/hibernate4-maven-plugin-1-0-4-released.md index bb97a4ba..129d50fb 100644 --- a/content/blog/archive/2014/hibernate4-maven-plugin-1-0-4-released.md +++ b/content/blog/archive/2014/hibernate4-maven-plugin-1-0-4-released.md @@ -27,7 +27,8 @@ If you have some special small-sized (example) use-cases for the plugin, we woul ## Release notes: - ` +``` + commit f3dabc0e6e3676244986b5bbffdb67d427c8383c Author: Kai Moritz Date: Mon Jun 2 10:31:12 2014 +0200 @@ -130,4 +131,4 @@ commit e44434257040745e66e0596b262dd0227b085729 Author: Kai Moritz Date: Fri Oct 18 01:55:11 2013 +0200 [maven-release-plugin] prepare for next development iteration -` +``` diff --git a/content/blog/archive/2015/hibernate4-maven-plugin-1-0-5-released.md b/content/blog/archive/2015/hibernate4-maven-plugin-1-0-5-released.md index 96262556..0c371b99 100644 --- a/content/blog/archive/2015/hibernate4-maven-plugin-1-0-5-released.md +++ b/content/blog/archive/2015/hibernate4-maven-plugin-1-0-5-released.md @@ -35,7 +35,8 @@ _If you stumble across any problems, please let me know!_ ## Release notes: - ` +``` + commit ec30af2068f2d12a9acf65474ca1a4cdc1aa7122 Author: Kai Moritz Date: Tue Nov 11 15:28:12 2014 +0100 @@ -95,4 +96,4 @@ commit 3dd832edbd50b1499ea6d53e4bcd0ad4c79640ed Author: Kai Moritz Date: Mon Jun 2 10:31:13 2014 +0200 [maven-release-plugin] prepare for next development iteration -` +``` diff --git a/content/blog/archive/2015/hibernate4-maven-plugin-1-1-0-released.md b/content/blog/archive/2015/hibernate4-maven-plugin-1-1-0-released.md index fc535ec4..6c23931e 100644 --- a/content/blog/archive/2015/hibernate4-maven-plugin-1-1-0-released.md +++ b/content/blog/archive/2015/hibernate4-maven-plugin-1-1-0-released.md @@ -37,7 +37,8 @@ This release also fixes a bug, that occured on some platforms, if the path to th ## Release notes: - ` +``` + commit 94e6b2e93fe107e75c9d20aa1eb3126e78a5ed0a Author: Kai Moritz Date: Sat May 16 14:14:44 2015 +0200 @@ -196,4 +197,4 @@ Date: Sun Mar 15 15:42:01 2015 +0100 Added support for m2e Thanks to Andreas Khutz -` +``` diff --git a/content/blog/archive/2020/deduplicating-partitioned-data-with-kafka-streams.md b/content/blog/archive/2020/deduplicating-partitioned-data-with-kafka-streams.md index 9776256e..bca5ca65 100644 --- a/content/blog/archive/2020/deduplicating-partitioned-data-with-kafka-streams.md +++ b/content/blog/archive/2020/deduplicating-partitioned-data-with-kafka-streams.md @@ -28,7 +28,8 @@ The order, in which these messages are send, is crucial with respect to the ince Resending the messages in correct order after a failure (or downtime) is no problem. But some of the messages may be send twice (or more often), because the producer does not know exactly, which messages were send successful. -`Incident A - { id: 1, data: "ab583cc8f8" } +``` +Incident A - { id: 1, data: "ab583cc8f8" } Incident B - { id: 2, data: "83ccc8f8f8" } Incident C - { id: 3, data: "115tab5b58" } Incident C - { id: 4, data: "83caac564b" } @@ -44,7 +45,7 @@ Incident A - { id: 8, data: "930fce58f3" } Incident B - { id: 9, data: "7583ab93ab" } Incident C - { id: 10, data: "7583aab583" } Incident B - { id: 11, data: "b583075830" } -` +``` Since eache message has a unique ID, all messages are inherently idempotent: **Deduplication is no problem, if the receiver keeps track of the messages, he has already seen.** @@ -96,7 +97,8 @@ That is, our message stream is simply a mapping from names to unique sequence nu In this simplified setup, the implementation effectively boils down to the following method-override: -`@Override +``` +@Override public Iterable transform(String value) { Integer partition = context.partition(); @@ -109,7 +111,7 @@ public Iterable transform(String value) } return Collections.emptyList(); } -` +``` - We can get the active partition from the `ProcessorContext`, that is handed to our Instance in the constructor, which is not shown here for brevity. - Parsing the `String`-value of the message as `long` corresponds to the extraction of the sequence number from the value of the message in our simplified setup. @@ -123,7 +125,8 @@ public Iterable transform(String value) We can use our `ValueTransformer` with **`flatTransformValues()`**, to let Kafka Streams drop the detected duplicate values: -`streamsBuilder +``` +streamsBuilder .stream("input") .flatTransformValues( new ValueTransformerSupplier() @@ -136,7 +139,7 @@ to let Kafka Streams drop the detected duplicate values: }, "SequenceNumbers") .to("output"); -` +``` One has to register an appropriate store to the `StreamsBuilder` under the referenced name. diff --git a/content/blog/archive/2020/how-to-instantiatiate-multiple-beans-dinamically-in-spring-boot-based-on-configuration-properties.md b/content/blog/archive/2020/how-to-instantiatiate-multiple-beans-dinamically-in-spring-boot-based-on-configuration-properties.md index 4fdd5da3..914fbfe3 100644 --- a/content/blog/archive/2020/how-to-instantiatiate-multiple-beans-dinamically-in-spring-boot-based-on-configuration-properties.md +++ b/content/blog/archive/2020/how-to-instantiatiate-multiple-beans-dinamically-in-spring-boot-based-on-configuration-properties.md @@ -29,7 +29,8 @@ We will: Additionally Beans can be added programatically very easy with the help of an `ApplicationContextInitializer`: -`@AllArgsConstructor +``` +@AllArgsConstructor public class MultipleBeansApplicationContextInitializer implements ApplicationContextInitializer @@ -48,7 +49,7 @@ public class MultipleBeansApplicationContextInitializer } } } -` +``` This simplified example is configured with a list of strings that should be registered as controllers with the `DispatcherServlet`. All "sites" are insances of the same controller `SiteController`, which are instanciated and registered dynamically. @@ -76,7 +77,8 @@ _The initializer cannot be instantiated and autowired by Spring!_ If you write an **`EnvironmentPostProcessor`**, you will get access to an instance of `ConfigurableEnvironment`, that contains a complete list of all `PropertySource`'s, that are configured for your Spring-Boot-App. -`public class MultipleBeansEnvironmentPostProcessor +``` +public class MultipleBeansEnvironmentPostProcessor implements EnvironmentPostProcessor { @@ -95,7 +97,7 @@ If you write an **`EnvironmentPostProcessor`**, you will get access to an instan .toArray(size -> new String[size]))); } } -` +``` **The Bad News:** Unfortunately, you have to scan all property-sources for the parameters, that you are interested in. @@ -110,9 +112,10 @@ The property names are consistently represented in standard Java-Properties-Nota Finally, you have to [register](https://docs.spring.io/spring-boot/docs/current/reference/html/howto.html#howto-customize-the-environment-or-application-context "Read more on details and/or alternatives of the mechanism") the `EnvironmentPostProcessor` with your Spring-Boot-App. This is done in the **`META-INF/spring.factories`**: -`org.springframework.boot.env.EnvironmentPostProcessor=\ +``` +org.springframework.boot.env.EnvironmentPostProcessor=\ de.juplo.demos.multiplebeans.MultipleBeansEnvironmentPostProcessor -` +``` **That's it, your done!** diff --git a/content/blog/archive/2020/testing-exception-handling-in-spring-mvc.md b/content/blog/archive/2020/testing-exception-handling-in-spring-mvc.md index ca2a6ca3..0d4967cb 100644 --- a/content/blog/archive/2020/testing-exception-handling-in-spring-mvc.md +++ b/content/blog/archive/2020/testing-exception-handling-in-spring-mvc.md @@ -40,7 +40,8 @@ It enables us, to mock away the other layers of the application and concentrate Consider the following controller, that defines a request-handling and an accompanying exception-handler, for an `IllegalArgumentException`, that may by thrown in the business-logic: -`@Controller +``` +@Controller public class ExampleController { @Autowired -- 2.39.5