What's new in Apache Karaf OSGi runtime 4.4.3 ?

Apache Karaf OSGi runtime 4.4.3 has just been released. Let's take a quick look on the main highlights ;)
You can download Karaf here: https://karaf.apache.org/download.html.
The full release notes are available here: https://issues.apache.org/jira/secure/ReleaseNote.jspa?projectId=12311140&version=12352267.

Fix threads leak in karaf-maven-plugin:verify

The karaf-maven-plugin provides a convenient goal to verify Karaf features. It's simple way to verify that features:
  • are complete, with all requirements resolved
  • reference valid other features
  • can be installed on a runtime without issue
Karaf itself (and its subprojects) is using karaf-maven-plugin:verify to verify its own features.
You can easily use the verify goal in your project, like this in your pom.xml:

            <plugin>
                <groupId>org.apache.karaf.tooling</groupId>
                <artifactId>karaf-maven-plugin</artifactId>
                <version>4.2.2</version>
                <executions>
                    <execution>
                        <id>verify</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>verify</goal>
                        </goals>
                        <configuration>
                            <descriptors>
                                <descriptor>file:${project.build.directory}/feature/feature.xml</descriptor>
                                <descriptor>mvn:org.apache.karaf.features/framework/4.2.2/xml/features</descriptor>
                                <descriptor>mvn:org.apache.karaf.features/standard/4.2.2/xml/features</descriptor>
                                <!-- any other features repositories providing features you need in your own features -->
                            </descriptors>
                            <distribution>org.apache.karaf.features:framework</distribution>
                            <javase>9</javase>
                            <framework>
                                <feature>framework</feature>
                            </framework>
                            <features>
                                <feature>my-feature</feature>
                                <feature>my(.*)</feature>
                            </features>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

To verify, the karaf-maven-plugin creates several threads to check the transitive features, condition, etc. It does it using a thread executor with a pool of 8 threads. We have one threads pool per feature to verify. The problem was that each executor is never shutdown, meaning a accumulation of threads.
To give you an idea, with 400 features to verify, we observed 3200 threads leaking, up to out of memory issue.
We fixed this issue in 4.4.3 release by cleanly shutdown the threads executors.

Fix SSH client on Windows

Using Karar client (up to 4.4.2 version), you can encounter the following issue on Windows:

1375 [main] DEBUG org.apache.sshd.client.SshClient - close(SshClient[d6da883])[Immediately] closed
org.apache.sshd.common.SshException: DefaultOpenFuture[ChannelShell[id=0, recipient=-1]-ClientSessionImpl[karaf@localhost/127.0.0.1:8101]]: Failed (IllegalArgumentException) to execute: Invalid UINT32 value: -1
    at org.apache.sshd.common.future.AbstractSshFuture.lambda$verifyResult$1(AbstractSshFuture.java:132)
    at org.apache.sshd.common.future.AbstractSshFuture.formatExceptionMessage(AbstractSshFuture.java:190)
    at org.apache.sshd.common.future.AbstractSshFuture.verifyResult(AbstractSshFuture.java:131)
    at org.apache.sshd.client.future.DefaultOpenFuture.verify(DefaultOpenFuture.java:39)
    at org.apache.sshd.client.future.DefaultOpenFuture.verify(DefaultOpenFuture.java:32)
    at org.apache.sshd.common.future.VerifiableFuture.verify(VerifiableFuture.java:43)
    at org.apache.karaf.client.Main.main(Main.java:281)
Caused by: java.lang.IllegalArgumentException: Invalid UINT32 value: -1
    at org.apache.sshd.common.util.ValidateUtils.createFormattedException(ValidateUtils.java:213)
    at org.apache.sshd.common.util.ValidateUtils.throwIllegalArgumentException(ValidateUtils.java:179)
    at org.apache.sshd.common.util.ValidateUtils.checkTrue(ValidateUtils.java:162)
    at org.apache.sshd.common.util.buffer.BufferUtils.validateUint32Value(BufferUtils.java:703)
    at org.apache.sshd.common.util.buffer.Buffer.putUInt(Buffer.java:726)
    at org.apache.sshd.client.channel.PtyCapableChannelSession.lambda$doOpenPty$0(PtyCapableChannelSession.java:265)
    at java.base/java.util.HashMap.forEach(HashMap.java:1337)

The problem is that Karaf's SSH client is setting up terminal properties from JLine, but does not pay attention to JLine return values: Attributes.getControlChar() will return -1 when the ControlChar is not available, but Karaf does not pay attention to that, pushing -1 down to SSHD config.
With SSHD-1244, such control characters will get rejected because of the UInt check being introduced in the corresponding patch.
This renders bin/client inoperable in automated environments, which probably have terminals with fewer-than-expected PTY features available.
As such, this is a regression in functionality when compared to Karaf 4.4.1 or 4.3.7, but is not caused by a code change, but rather SSHD flushing out pre-existing badness.
We fixed this issue by registering the different PtyMode, checking the ControlChar retrieve by the client from the terminal.

Avoid overriding JMX stub IP by default

In KARAF-7096, we fixed the bind address on the RMIServerImpl_Stub.
The problem was that when RMIServerImpl_Stub is created at server side by org.apache.karaf.management.server bundle, the bind address of this remote object was not taken from rmiServerHost property of org.apache.karaf.management PID. It's taken from (top to bottom):
  • sun.rmi.transport.tcp.TCPEndpoint#getLocalEndpoint()
  • java.net.InetAddress#getLocalHost()
  • java.net.InetAddressImpl#getLocalHostName()
  • java.net.InetAddress#getAddressesFromNameService()
  • java.net.Inet6AddressImpl#lookupAllHostAddr()
  • getaddress() libc method
  • /etc/hosts
The fix we did was simply to do System.setProperty("java.rmi.server.hostname", rmiServerHost).
But this fix has a drawback: in some cases, users might want to define a custom java.rmi.server.hostname value (in etc/system.properties for instance), different from rmiServerHost value. It's especially true when using different network on Docker.
In that case, we should not overwrite the java.rmi.server.hostname if set by user.
That's the fix we did: if java.rmi.server.hostname is defined by the user, we don't overwrite it.

shell:alias and instance:package commands

We added two new shell commands in Karaf 4.4.3:
  • instance:package command create a zip file containing a Karaf instance (that you can list with instance:list command). It's a convenient way to "export" an instance, ready to copy somewhere else. It could be used in combination with the docker feature: you can configure an instance and easily create a docker image based on this instance.
  • shell:alias allows you to create an alias to another command. It could be a "complex" alias, like ldn = { log:display -n $args }. You can optionnally persist the alias in etc/shell.init.script using shell:alias -p

A bunch of dependency updates, especially Pax Web 8.0.5 and Apache Aries JAX-RS Whiteboard 2.0.2

As usual in any Karaf release, 4.4.3 includes a bunch of dependency updates.
In the update list, there are two major updates:
  • Pax Web 8.0.15 upgrades to Jetty 9.4.50.v20221201 , Tomcat Tomcat 9.0.70 and Undertow 2.2.22.Final. It also fixes a couple of issues.
  • Apache Aries JAX RS Whiteboard 2.0.2 includes a complete refactoring on the Karaf features repository. It's now working smoothly, better use of CXF.

Starting Karaf 4.5.x

We are now starting to prepare Karaf 4.5.x with major changes (JDK11+ required, Pax Web 9.x, Jetty 10.x, ...).
Apache Karaf 4.4.x will still be active. Karaf 4.3.9 release is in preparation and will probably be one of the last version on 4.3.x branch.

Comments

Popular posts from this blog

Apache Karaf runtime 4.4.0 has been released!

Apache ActiveMQ 5.16.4, reload4j and more

Apache ActiveMQ 5.16.3 has been released