This is an automated email from the ASF dual-hosted git repository.

lukaszlenart pushed a commit to branch WW-5537-classloader-leak-fixes
in repository https://gitbox.apache.org/repos/asf/struts.git

commit b56ea78c1bb5a135ca6ede51c1ee3cca4ad457b4
Author: Lukasz Lenart <[email protected]>
AuthorDate: Mon Mar 23 10:08:49 2026 +0100

    WW-5537 Dispatcher.destroyObjectFactory: add early return on null, use 
pattern matching
    
    Co-Authored-By: Claude Opus 4.6 <[email protected]>
---
 core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java 
b/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java
index 0bf74917e..2e579c35d 100644
--- a/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java
+++ b/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java
@@ -473,10 +473,11 @@ public class Dispatcher {
     protected void destroyObjectFactory() {
         if (objectFactory == null) {
             LOG.warn("Object Factory is null, something is seriously wrong, no 
clean up will be performed");
+            return;
         }
-        if (objectFactory instanceof ObjectFactoryDestroyable) {
+        if (objectFactory instanceof ObjectFactoryDestroyable ofd) {
             try {
-                ((ObjectFactoryDestroyable) objectFactory).destroy();
+                ofd.destroy();
             } catch (Exception e) {
                 LOG.error("Exception occurred while destroying ObjectFactory 
[{}]", objectFactory.toString(), e);
             }

Reply via email to