[ 
https://issues.apache.org/jira/browse/WW-5334?focusedWorklogId=876752&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-876752
 ]

ASF GitHub Bot logged work on WW-5334:
--------------------------------------

                Author: ASF GitHub Bot
            Created on: 17/Aug/23 09:02
            Start Date: 17/Aug/23 09:02
    Worklog Time Spent: 10m 
      Work Description: kusalk commented on code in PR #731:
URL: https://github.com/apache/struts/pull/731#discussion_r1296902785


##########
plugins/velocity/src/main/java/org/apache/struts2/views/velocity/VelocityManager.java:
##########
@@ -488,62 +468,18 @@ private void applyDefaultConfiguration(ServletContext 
context, Properties proper
         properties.setProperty("strutsclass.resource.loader.cache", "true");
 
         // components
-        StringBuilder sb = new StringBuilder();
-
-        for (TagLibraryDirectiveProvider tagLibrary : tagLibraries) {
-            List<Class<?>> directives = tagLibrary.getDirectiveClasses();
-            for (Class<?> directive : directives) {
-                addDirective(sb, directive);
-            }
-        }
-
-        String directives = sb.toString();
+        String directives = 
tagLibraries.stream().map(TagLibraryDirectiveProvider::getDirectiveClasses).flatMap(
+                Collection::stream).map(directive -> directive.getName() + 
",").collect(joining());
 
         String userdirective = properties.getProperty("userdirective");
-        if ((userdirective == null) || userdirective.trim().equals("")) {
+        if (userdirective == null || userdirective.trim().isEmpty()) {
             userdirective = directives;
         } else {
             userdirective = userdirective.trim() + "," + directives;
         }
-
         properties.setProperty("userdirective", userdirective);
     }
 
-    private void addDirective(StringBuilder sb, Class<?> clazz) {
-        sb.append(clazz.getName()).append(",");
-    }
-
-    private static String replace(String string, String oldString, String 
newString) {

Review Comment:
   This must be ancient code to be implementing String#replace from scratch





Issue Time Tracking
-------------------

    Worklog Id:     (was: 876752)
    Time Spent: 0.5h  (was: 20m)

> Misc VelocityManager code cleanup
> ---------------------------------
>
>                 Key: WW-5334
>                 URL: https://issues.apache.org/jira/browse/WW-5334
>             Project: Struts 2
>          Issue Type: Improvement
>          Components: Plugin - Velocity
>            Reporter: Kusal Kithul-Godage
>            Priority: Minor
>             Fix For: 6.4.0
>
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>




--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to