MVStore: Accessing Old Versions
A while back I blogged about MVStore basics. Let’s look at the way MVStore keeps old revisions around. First, MVStore maps have a .getVersion() method and a .openVersion() method pair. With that, you can access old version previous values. A new version of the map is created on (auto-) commit.
Bastel Proxy: HTTPS and reverse proxy for development environments
I tend to work on web applications and services which are interconnected. Different parts of the website and the services run as separate processes. In production something like NGINX does the HTTPS termination and unifies the services to a single domain. I found it useful to have HTTPS and a reverse proxy in my development environment too. Browsers complain about plain HTTPS sites and even disable certain features. Further, if your website is split across different processes and one part runs on http://localhost:8080 and other on http://localhost:8081, you can run into cross-domain issues. Also, I found it less error-prone to mirror the domain structure than having tons of localhost:{port} pointing to each other.
One option is to run a production reverse proxy like NGINX. However, it requires quite a bit of configuration and you have to provide it the HTTPS certificates etc. I wanted a solution specific for developments which tries to minimize setup time.
OpenJDK's Flight-Recorder and Mission Control
Flight Recorder is a low overhead profiler and diagnostics events recorder for the Hotspot JVM. Java Mission Control is
a software to visualize these events. It has been included for years in the Oracle JDK but used to be a commercial
feature. To use it you needed to add -XX:+UnlockCommercialFeatures -XX:+FlightRecorder
flags and you were not allowed
to use it in production unless you paid a license.
Oracle donated the code to the OpenJDK project and it is now included in OpenJDK 11 or newer builds. However, if you look at your JDK there is no Mission Control, so where it is? It is part of the OpenJDK but is built separately. You can download binaries from AdoptOpenJDK or Azul, which rebranded it as Zulu Mission Control.
Mystery Jetty Threads Due To Failed Startup
Yesterday I had an app with an embedded Jetty Server which didn’t shut down properly. The main thread exited and the
app had called .stop()
on the Jetty server. However, the app kept running.
// App setup
// Then the app runs until the user stops it:
System.out.println("Press any key to stop");
while (System.in.available() <= 0) {
Thread.sleep(1000);
}
jetty.stop();
System.out.println("Stopped");
// App doesn't quit here. It keeps running.
Create HTTPS Certificates in Java with Bouncy Castle
Multiple times I needed to create HTTPS certificates programmatically. For example to create test certificates for HTTPS in development without complicated setup. There is surprisingly little information out there about how to create certificates programmatically in Java. Most guides OpenSSL or another command-line tool. I wanted to avoid to run an external program but wanted to do it programmatically.
In the past, I used a hacky way to do in Java by using JDK internals. However, as I moved to Java 11+ I needed a better way, since the API’s changed and are now inaccessible due to the module system.