javacodegeeks.com

Minimize turnaround times with Open Liberty’s dev mode

I’ve uploaded a video in which I show how to reduce the turnaround times while writing Enterprise Java applications that are deployed on Open Liberty. The liberty:dev goal of the Maven plugin watches for file changes and applies the changes instantly, without the need to rebuild the whole deployment artifact.I’ll show how Open Liberty can keep running while we’re changing source code, configuration, server features, or project dependencies. Running system tests against the already-running application also vastly reduces waiting...

javacodegeeks.com

Checking What’s Thrown in Java Tests

Someone came up with the idea of using try and catch blocks in unit tests in Java:12345678@Testpublic void test() {   try {      callSomeCode();   } catch (Exception e) {      assertEquals("foo", e.getMessage());   }}The above is tempting, but doesn’t work. If the code under test didn’t throw, then no assertion would be performed.So to fix it:0102030405060708091011@Testpublic void test() {   try...

javacodegeeks.com

The potential traps in Kotlin's Data Classes

The aim of this post is not to point out some massive flaws in Kotlin’s design of data classes and show you how to get passed them. Actually, it is quite the opposite. The contents of this post are clearly documented in the Kotlin docs. I am merely here to highlight this information to anyone who has not noticed precisely how their data classes are working.Data classes are convenient for us developers, especially those of us coming over from Java. They provide several generated functions allowing you to write a fully functional class with...

javacodegeeks.com

Java: ChronicleMap Part 3, Fast Microservices

Standard Java Maps needs to be initialized upon startup. Learn how to leverage ChronicleMaps that is initializable from a file and reduce microservice startup times significantly and how to share Maps between JVMs.The built-in Map implementations, such as HashMap and ConcurrentHashMap are fast but they must be initialized with mappings before they can be used for looking up values. Also, they are limited in size by practical means such as heap and RAM size. Lastly, they are local to the JVM it runs in.The initialization process can slow down...

javacodegeeks.com

Java: ChronicleMap Part 2, Super RAM Maps

The standard Java Maps, such as the ubiquitous HashMap, are ultimately limited by the available RAM. Read this article and learn how you can create Java Maps with virtually unlimited sizes even exceeding the target machine’s RAM size.The built-in Map implementations, such as HashMap and ConcurrentHashMap work fine as long as they are relatively small. In all cases, they are limited by the available heap and therefore eventually the available RAM size. ChronicleMap can store its contents in files, thereby circumventing this limitation,...

javacodegeeks.com

Java: ChronicleMap Part 1, Go Off-Heap

Filling up a HashMap with millions of objects will quickly lead to problems such as inefficient memory usage, low performance and garbage collection problems. Learn how to use off-heap CronicleMap that can contain billions of objects with little or no heap impact.The built-in Map implementations, such as HashMap and ConcurrentHashMap are excellent tools when we want to work with small to medium-sized data sets. However, as the amount of data grows, theseMap implementations are deteriorating and start to exhibit a number of unpleasant drawbacks...

javacodegeeks.com

Verifying a Contract with CSV data

Attachments in Corda can be more than just PDFs sent along with a transaction. They can actually be used programmatically when running a flow or even inside of a contract’s verify function. Why would you want to do that though? 🤔 The answer makes a lot of sense when you think about it. Let’s take an attachment containing CSV data as an example. Actually, that is what this post is about. Anyway. The attachment could contain all the valid IDs (or whatever else) that a state is allowed to have. Now, that could be done within your code, but...

javacodegeeks.com

JEP 358: Helpful NullPointerExceptions

In the post “Better Default NullPointerException Messages Coming to Java?“, I summarized background details related to a draft JEP (at that time) regarding making some types of NullPointerException‘s (NPE’s) messages more useful. It was nice to see last week that this JEP is now a candidate JEP (JEP 358: “Helpful NullPointerExceptions”). In this post, I highlight aspects of JEP 358 that I find particularly interesting.What is JEP 358?JEP 358‘s current “Summary” succinctly describes this...

javacodegeeks.com

Connecting a Ktor web server to a Corda node

The preparation for this blog post began several weeks ago (probably over a month by now). Before I could write about melding Corda and Ktor together, I first needed to lay the groundwork and focus solely on Ktor. That is where my blog post, Ktor – a Kotlin web framework came into existence. If you haven’t used or seen Ktor before, I recommend taking a browse at that post either before or after reading this post. Reading it in advance is probably a better idea, but you are in control of your own life 🤷.This post will focus on...