You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@struts.apache.org by "MFAshby (via GitHub)" <gi...@apache.org> on 2025/08/07 21:45:07 UTC
[PR] Fixup StrutsConverterFactory [struts]
MFAshby opened a new pull request, #1309:
URL: https://github.com/apache/struts/pull/1309
It should delegate back to ObjectFactory#buildBean instead of directly calling Container#inject, otherwise overrides of buildBean in subclasses of ObjectFactory e.g. SpringObjectFactory are skipped; meaning that TypeConverters cannot make use of Spring dependency injection
Fixes: https://issues.apache.org/jira/projects/WW/issues/WW-5524
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@struts.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] WW-5524 Fixup StrutsConverterFactory [struts]
Posted by "lukaszlenart (via GitHub)" <gi...@apache.org>.
lukaszlenart commented on PR #1309:
URL: https://github.com/apache/struts/pull/1309#issuecomment-3204175768
Cherry picked #1316
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@struts.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] WW-5524 Fixup StrutsConverterFactory [struts]
Posted by "lukaszlenart (via GitHub)" <gi...@apache.org>.
lukaszlenart merged PR #1309:
URL: https://github.com/apache/struts/pull/1309
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@struts.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] WW-5524 Fixup StrutsConverterFactory [struts]
Posted by "MFAshby (via GitHub)" <gi...@apache.org>.
MFAshby commented on PR #1309:
URL: https://github.com/apache/struts/pull/1309#issuecomment-3202397952
> @MFAshby do you want to port this change into 6.x?
Thanks for looking @lukaszlenart ,
I don't need this backporting for my current project (I'm migrating to 7.x) but others might find it useful. I leave the decision to you.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@struts.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] WW-5524 Fixup StrutsConverterFactory [struts]
Posted by "MFAshby (via GitHub)" <gi...@apache.org>.
MFAshby commented on code in PR #1309:
URL: https://github.com/apache/struts/pull/1309#discussion_r2286441992
##########
core/src/main/java/org/apache/struts2/factory/StrutsConverterFactory.java:
##########
@@ -18,31 +18,30 @@
*/
package org.apache.struts2.factory;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.apache.struts2.ObjectFactory;
import org.apache.struts2.conversion.TypeConverter;
-import org.apache.struts2.inject.Container;
import org.apache.struts2.inject.Inject;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.LogManager;
import java.util.Map;
/**
* Default implementation
*/
public class StrutsConverterFactory implements ConverterFactory {
-
private static final Logger LOG = LogManager.getLogger(StrutsConverterFactory.class);
- private Container container;
+ private ObjectFactory objectFactory;
@Inject
- public void setContainer(Container container) {
- this.container = container;
+ public void setObjectFactory(ObjectFactory objectFactory) {
+ this.objectFactory = objectFactory;
}
+ @Override
public TypeConverter buildConverter(Class<? extends TypeConverter> converterClass, Map<String, Object> extraContext) throws Exception {
LOG.debug("Creating converter of type [{}]", converterClass.getCanonicalName());
- return container.inject(converterClass);
+ return (TypeConverter)objectFactory.buildBean(converterClass, extraContext);
Review Comment:
This is incorrect, copilot. `objectFactory.buildBean` declares it's return type as `Object` so the cast is fully necessary for the code to compile.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@struts.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] WW-5524 Fixup StrutsConverterFactory [struts]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #1309:
URL: https://github.com/apache/struts/pull/1309#discussion_r2282688230
##########
core/src/main/java/org/apache/struts2/factory/StrutsConverterFactory.java:
##########
@@ -18,31 +18,30 @@
*/
package org.apache.struts2.factory;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.apache.struts2.ObjectFactory;
import org.apache.struts2.conversion.TypeConverter;
-import org.apache.struts2.inject.Container;
import org.apache.struts2.inject.Inject;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.LogManager;
import java.util.Map;
/**
* Default implementation
*/
public class StrutsConverterFactory implements ConverterFactory {
-
private static final Logger LOG = LogManager.getLogger(StrutsConverterFactory.class);
- private Container container;
+ private ObjectFactory objectFactory;
@Inject
- public void setContainer(Container container) {
- this.container = container;
+ public void setObjectFactory(ObjectFactory objectFactory) {
+ this.objectFactory = objectFactory;
}
+ @Override
public TypeConverter buildConverter(Class<? extends TypeConverter> converterClass, Map<String, Object> extraContext) throws Exception {
LOG.debug("Creating converter of type [{}]", converterClass.getCanonicalName());
- return container.inject(converterClass);
+ return (TypeConverter)objectFactory.buildBean(converterClass, extraContext);
Review Comment:
The explicit cast to TypeConverter is unnecessary since the method signature already declares the return type as TypeConverter and converterClass is bounded by Class<? extends TypeConverter>. Consider removing the cast for cleaner code.
```suggestion
return objectFactory.buildBean(converterClass, extraContext);
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@struts.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] WW-5524 Fixup StrutsConverterFactory [struts]
Posted by "lukaszlenart (via GitHub)" <gi...@apache.org>.
lukaszlenart commented on PR #1309:
URL: https://github.com/apache/struts/pull/1309#issuecomment-3199250032
@MFAshby do you want to port this change into 6.x?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@struts.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org