From e6c3215f45fd20671ca4d32fb282c24ffaa85678 Mon Sep 17 00:00:00 2001 From: Dmitry Kryukov Date: Thu, 13 Nov 2025 21:21:01 +0300 Subject: [PATCH] SYNAPSE-1134 Fixed calls of getClass() on instances of Class --- .../config/xml/POJOCommandMediatorSerializer.java | 2 +- .../mediators/ext/AnnotatedCommandMediator.java | 14 +++++++------- .../synapse/mediators/ext/POJOCommandMediator.java | 10 +++++----- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/modules/core/src/main/java/org/apache/synapse/config/xml/POJOCommandMediatorSerializer.java b/modules/core/src/main/java/org/apache/synapse/config/xml/POJOCommandMediatorSerializer.java index 43aedf8bb..99027de6a 100644 --- a/modules/core/src/main/java/org/apache/synapse/config/xml/POJOCommandMediatorSerializer.java +++ b/modules/core/src/main/java/org/apache/synapse/config/xml/POJOCommandMediatorSerializer.java @@ -42,7 +42,7 @@ public OMElement serializeSpecificMediator(Mediator m) { OMElement pojoCommand = fac.createOMElement("pojoCommand", synNS); saveTracingState(pojoCommand, mediator); - if (mediator.getCommand() != null && mediator.getCommand().getClass().getName() != null) { + if (mediator.getCommand() != null && mediator.getCommand().getName() != null) { pojoCommand.addAttribute(fac.createOMAttribute( "name", nullNS, mediator.getCommand().getName())); } else { diff --git a/modules/core/src/main/java/org/apache/synapse/mediators/ext/AnnotatedCommandMediator.java b/modules/core/src/main/java/org/apache/synapse/mediators/ext/AnnotatedCommandMediator.java index 0a36d8d10..70115bea1 100644 --- a/modules/core/src/main/java/org/apache/synapse/mediators/ext/AnnotatedCommandMediator.java +++ b/modules/core/src/main/java/org/apache/synapse/mediators/ext/AnnotatedCommandMediator.java @@ -58,7 +58,7 @@ public boolean mediate(MessageContext synCtx) { } if (synLog.isTraceOrDebugEnabled()) { - synLog.traceOrDebug("Creating a new instance of POJO class : " + getCommand().getClass()); + synLog.traceOrDebug("Creating a new instance of POJO class : " + getCommand()); } Object commandObject = null; @@ -67,7 +67,7 @@ public boolean mediate(MessageContext synCtx) { commandObject = getCommand().newInstance(); } catch (Exception e) { handleException("Error creating an instance of the POJO command class : " + - getCommand().getClass(), e, synCtx); + getCommand(), e, synCtx); } synLog.traceOrDebug("Instance created, setting static and dynamic properties"); @@ -86,7 +86,7 @@ public boolean mediate(MessageContext synCtx) { if (f.getType().equals(String.class)) { v = xpath.stringValueOf(synCtx); } else { - throw new UnsupportedOperationException("non-String types not supportted yet"); + throw new UnsupportedOperationException("non-String types not supported yet"); } try { f.set(commandObject, v); @@ -101,7 +101,7 @@ public boolean mediate(MessageContext synCtx) { if (m.getParameterTypes().length == 1 && m.getParameterTypes()[0].equals(String.class)) { v = xpath.stringValueOf(synCtx); } else { - throw new UnsupportedOperationException("non-String types not supportted yet"); + throw new UnsupportedOperationException("non-String types not supported yet"); } try { m.invoke(commandObject, v); @@ -118,7 +118,7 @@ public boolean mediate(MessageContext synCtx) { ((Command) commandObject).execute(); } catch (Exception e) { handleException("Error invoking POJO command class : " - + getCommand().getClass(), e, synCtx); + + getCommand(), e, synCtx); } } else { @@ -129,10 +129,10 @@ public boolean mediate(MessageContext synCtx) { exeMethod.invoke(commandObject, new Object[]{}); } catch (NoSuchMethodException e) { handleException("Cannot locate an execute() method on POJO class : " + - getCommand().getClass(), e, synCtx); + getCommand(), e, synCtx); } catch (Exception e) { handleException("Error invoking the execute() method on POJO class : " + - getCommand().getClass(), e, synCtx); + getCommand(), e, synCtx); } } diff --git a/modules/core/src/main/java/org/apache/synapse/mediators/ext/POJOCommandMediator.java b/modules/core/src/main/java/org/apache/synapse/mediators/ext/POJOCommandMediator.java index d402c289f..e04997678 100644 --- a/modules/core/src/main/java/org/apache/synapse/mediators/ext/POJOCommandMediator.java +++ b/modules/core/src/main/java/org/apache/synapse/mediators/ext/POJOCommandMediator.java @@ -103,7 +103,7 @@ public boolean mediate(MessageContext synCtx) { } if (synLog.isTraceOrDebugEnabled()) { - synLog.traceOrDebug("Creating a new instance of POJO class : " + command.getClass()); + synLog.traceOrDebug("Creating a new instance of POJO class : " + command); } Object commandObject = null; @@ -112,7 +112,7 @@ public boolean mediate(MessageContext synCtx) { commandObject = command.newInstance(); } catch (Exception e) { handleException("Error creating an instance of the POJO command class : " + - command.getClass(), e, synCtx); + command, e, synCtx); } synLog.traceOrDebug("Instance created, setting static and dynamic properties"); @@ -143,7 +143,7 @@ public boolean mediate(MessageContext synCtx) { ((Command) commandObject).execute(); } catch (Exception e) { handleException("Error invoking POJO command class : " - + command.getClass(), e, synCtx); + + command, e, synCtx); } } else { @@ -153,10 +153,10 @@ public boolean mediate(MessageContext synCtx) { exeMethod.invoke(commandObject); } catch (NoSuchMethodException e) { handleException("Cannot locate an execute() method on POJO class : " + - command.getClass(), e, synCtx); + command, e, synCtx); } catch (Exception e) { handleException("Error invoking the execute() method on POJO class : " + - command.getClass(), e, synCtx); + command, e, synCtx); } }