TIL - Today I Learned: QEMU/KVM Guest unacceptable slow however having modern CPU?

Added by Komorek, Kamil about 4 years ago

Man, that was...

Trying to fluid run Windows 7 second day on QEMU/KVM Debian Bullseye host. Already enabled all kind hardware supports, tunned guest almost in any available for me possibility... But wtf, why on my brand new Ryzen 3700X guest OS works much worse than on my old i5-4570...

The last little thing was wrong in my VM definition:

<domain type='qemu'>

should be
<domain type='kvm'>


TIL - Today I Learned: Debian / Cinnamon monitor framerate limited to lowest

Added by Komorek, Kamil over 4 years ago

I've two displays:
  • 2k 144Hz monitor
  • FHD 60Hz monitor

connected to nVidia RTX2060 DP + HDMI.

nVidia Config shows, that first display (same like its OSD) works at 144Hz, however I see... it's not! FPS games it's also not so smooth, as they should be.

Searched on boards to change "Force Composition Pipeline" / "Force Full" or change "Sync to VBlank" or "Allow Flipping" - doesn't changes anything.

Today I accidentally changed in Cinnamon -> General Settings -> "Composition options" a "VSync method" from "Presentation mode" to "None" and it's finally works on real 144Hz!

TIL - Today I Learned: App won't start on Tomcat, no errors, JDK13 preview features

Added by Komorek, Kamil over 4 years ago

Got very annoying problem last night. I've implemented big feature which adds many framework libraries to master branch.
I've also used "preview features" from JDK13, especially Text Blocks preview (read here, I love it).

Everything works fine running main @SpringBootApplication class. Manually tested, ok, it's great, may go to my little home-production.

However when I merged changes, which triggered CI/CD... the app silently dies just after startup on Apache Tomcat 9.

No logs, no errors, nothing. Just one row in localhost.YYYY-MM-DD.log:

12-Jan-2020 00:44:29.506 INFO [main] org.apache.catalina.core.ApplicationContext.log 1 Spring WebApplicationInitializers detected on classpath

I thought my liquibase changeset's didn't ran on Postgres database (I'm testing on H2).

Next I was thinking that added libraries already not works with JDK13, and became to compare with old build / removed jars. No luck.

Next I thought my last logging cleanup changes broke completely logging - nope, old war works.
Maybe one of libraries adds own logging library and overwrites mine bridges?
Moving forward I tried to add Log4j2 to my app, believing that default Logback makes me idiot. Didn't helped.

Finally I've changed Tomcat's conf/ from FINE and INFO to ALL and that finally gave me a hint.

12-Jan-2020 21:48:08.006 FINE [main] org.apache.catalina.util.Introspection.loadClass Failed to load class [pl.dexterxx.myapp.ServletInitializer]
        java.lang.UnsupportedClassVersionError: Preview features are not enabled for pl/dexterxx/myapp/ServletInitializer (class file version 57.65535). Try running with '--enable-preview' (unable to load class [pl.dexterxx.myapp.ServletInitializer])
                at org.apache.catalina.loader.WebappClassLoaderBase.findClassInternal(
                at org.apache.catalina.loader.WebappClassLoaderBase.findClass(
                at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(
                at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(
                at org.apache.catalina.util.Introspection.loadClass(

Add to bin/

export CATALINA_OPTS="$CATALINA_OPTS --enable-preview" 

In maven project I've already did that, read more here. Forgot about Tomcat.

TIL - Today I Learned: Using Map's putIfAbsent method of implementors is risky...

Added by Komorek, Kamil over 4 years ago

Damn, what a find.

I've code:

return this.cachedConnections.putIfAbsent(
        new FooBar(foo)

Looking at default Map implementation:

default V putIfAbsent(K key, V value) {
    V v = get(key);
    if (v == null) {
        v = put(key, value);

    return v;

Logic. If null put and return / a'ka defaultObject.

However I'm getting NullPointerException while trying to use returned object... why?!

Solution because putIfAbsent implementation in eg. HashMap which I'm using is totally different... and returns null/old value in that call.

TIL - Today I Learned: Java Pattern group "No matches found"...

Added by Komorek, Kamil over 4 years ago

Got regexp and pattern:

final String VALUE_REGEXP = "(\\d+):(\\d+)";
final Pattern VALUE_PATTERN = Pattern.compile(VALUE_REGEXP)

I'm getting "No match found" on below code:
final Matcher matcher = VALUE_PATTERN.matcher(input);
final String number =;

Solution is to call matcher.matches() before group extraction, like below:
final Matcher matcher = VALUE_PATTERN.matcher(input);

matcher.matches()      // returns boolean, ofc check result...

final String number =;

TIL - Today I Learned: Liquibase with H2 database in PostgreSQL MODE

Added by Komorek, Kamil over 4 years ago


Table "databasechangelog" already exists;

after reusing database created with connection string:

Suggested by h2database official site to use MODE Postgres with DATABASE_TO_LOWER... but don't with liquibase.

New database created without lowering doesn't make problems


TIL - Today I Learned: H2 remote connection to database with AUTO_SERVER mode

Added by Komorek, Kamil over 4 years ago

Even using AUTO_SERVER switch in H2 database:


I could not connect to it getting "Database may be already in use".
I've used connection string:

Solution is to use also AUTO_SERVER=TRUE on remote/client side, below connection string allows to connect without errors.


I'm not sure does other params are necessary, but AUTO_SERVER is mandatory.


    Also available in: Atom