Skip to content

Minor Bugs Fixes - #3246

Closed
prosgarz35 wants to merge 3 commits into
apache:masterfrom
prosgarz35:master
Closed

prosgarz35 wants to merge 3 commits into
apache:masterfrom
prosgarz35:master

Conversation

@prosgarz35

Copy link
Copy Markdown
Contributor

Have a look

@chibenwa

Copy link
Copy Markdown
Contributor

registerMBean(): hides a real error instead of fixing it

If the MBean name (org.apache.james:type=server,name=) is already registered, the PR unregisters the existing MBean and registers its own in its place. The problems:

  • It hides misconfiguration. In production, a collision means two servers share the same jmxName, for example two smtpserver entries in smtpserver.xml. Today startup fails with a clear error. With this PR, the second server silently replaces the first in JMX, and the first one can no longer be managed.
  • It breaks shutdown. The first server's destroy() calls unregisterMBean(), which removes the second server's MBean. The second server's destroy() then hits InstanceNotFoundException, which gets wrapped in a RuntimeException inside @PreDestroy.
  • synchronized (mbeanServer) protects nothing. It's the JVM-wide PlatformMBeanServer. Nothing else synchronizes on it (not the jmx/*Stats classes, not other components), so the isRegistered → unregister → register race is still there.
  • The catch (InstanceAlreadyExistsException) just repeats the same steps. It runs the same unregister/register sequence again, and it uses a fully qualified class name instead of an import.

Could you describe the issue you hit ?We'd rather fail fast with a clearer error message, or fix the lifecycle that leaks the registration.

Comment on lines -484 to +486
// enable tcp keep-alives
// enable tcp keep-alives and disable Nagle's algorithm for low latency
bootstrap.childOption(ChannelOption.SO_KEEPALIVE, true);
bootstrap.childOption(ChannelOption.TCP_NODELAY, true);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does nothing new.

super.configureBootstrap(bootstrap) already sets it in protocols/netty/src/main/java/org/apache/james/protocols/netty/AbstractAsyncServer.java:182

The added line sets it a second time, and the new comment wrongly suggests it wasn't set before.

@prosgarz35

Copy link
Copy Markdown
Contributor Author

Yeah looks like i made mistake

@prosgarz35 prosgarz35 closed this Oct 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants