Author: tv
Date: Mon Jul 27 14:10:54 2026
New Revision: 1936638

Log:
Modernize code

Modified:
   db/torque/trunk/pom.xml
   
db/torque/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/outlet/CopyOutletSaxHandlerFactory.java
   
db/torque/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/outlet/JavaOutletSaxHandlerFactory.java
   
db/torque/trunk/torque-generator/src/main/java/org/apache/torque/generator/processor/string/WrapReservedJavaWords.java
   
db/torque/trunk/torque-generator/src/main/java/org/apache/torque/generator/template/velocity/VelocityOutlet.java
   
db/torque/trunk/torque-generator/src/main/java/org/apache/torque/generator/template/velocity/VelocityTemplateFilter.java
   
db/torque/trunk/torque-runtime/src/main/java/org/apache/torque/sql/whereclausebuilder/NoReplacementsPreparedStatementPart.java
   
db/torque/trunk/torque-runtime/src/main/java/org/apache/torque/util/LargeSelect.java
   
db/torque/trunk/torque-runtime/src/main/java/org/apache/torque/util/SummaryHelper.java

Modified: db/torque/trunk/pom.xml
==============================================================================
--- db/torque/trunk/pom.xml     Mon Jul 27 13:49:48 2026        (r1936637)
+++ db/torque/trunk/pom.xml     Mon Jul 27 14:10:54 2026        (r1936638)
@@ -852,8 +852,6 @@
 
     <properties>
         <project.build.sourceEncoding>ISO-8859-1</project.build.sourceEncoding>
-        <maven.compiler.source>17</maven.compiler.source>
-        <maven.compiler.target>17</maven.compiler.target>
         <maven.compiler.release>17</maven.compiler.release>
         <dependency.check.skip>true</dependency.check.skip>
         <java.version>17</java.version>

Modified: 
db/torque/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/outlet/CopyOutletSaxHandlerFactory.java
==============================================================================
--- 
db/torque/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/outlet/CopyOutletSaxHandlerFactory.java
    Mon Jul 27 13:49:48 2026        (r1936637)
+++ 
db/torque/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/outlet/CopyOutletSaxHandlerFactory.java
    Mon Jul 27 14:10:54 2026        (r1936638)
@@ -20,7 +20,7 @@ package org.apache.torque.generator.conf
  */
 
 import java.util.Collection;
-import java.util.Collections;
+import java.util.List;
 
 import org.apache.torque.generator.configuration.ConfigurationHandlers;
 import org.apache.torque.generator.configuration.ConfigurationProvider;
@@ -62,7 +62,7 @@ implements TypedOutletSaxHandlerFactory
     @Override
     public Collection<String> getTemplatesFilenameExtensionsForScan()
     {
-        return Collections.emptyList();
+        return List.of();
     }
 
     /**

Modified: 
db/torque/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/outlet/JavaOutletSaxHandlerFactory.java
==============================================================================
--- 
db/torque/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/outlet/JavaOutletSaxHandlerFactory.java
    Mon Jul 27 13:49:48 2026        (r1936637)
+++ 
db/torque/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/outlet/JavaOutletSaxHandlerFactory.java
    Mon Jul 27 14:10:54 2026        (r1936638)
@@ -20,7 +20,7 @@ package org.apache.torque.generator.conf
  */
 
 import java.util.Collection;
-import java.util.Collections;
+import java.util.List;
 
 import org.apache.torque.generator.configuration.ConfigurationHandlers;
 import org.apache.torque.generator.configuration.ConfigurationProvider;
@@ -62,7 +62,7 @@ implements TypedOutletSaxHandlerFactory
     @Override
     public Collection<String> getTemplatesFilenameExtensionsForScan()
     {
-        return Collections.emptyList();
+        return List.of();
     }
 
     /**

Modified: 
db/torque/trunk/torque-generator/src/main/java/org/apache/torque/generator/processor/string/WrapReservedJavaWords.java
==============================================================================
--- 
db/torque/trunk/torque-generator/src/main/java/org/apache/torque/generator/processor/string/WrapReservedJavaWords.java
      Mon Jul 27 13:49:48 2026        (r1936637)
+++ 
db/torque/trunk/torque-generator/src/main/java/org/apache/torque/generator/processor/string/WrapReservedJavaWords.java
      Mon Jul 27 14:10:54 2026        (r1936638)
@@ -1,25 +1,5 @@
 package org.apache.torque.generator.processor.string;
 
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.HashSet;
 import java.util.Set;
 
 /**
@@ -42,61 +22,57 @@ public class WrapReservedJavaWords imple
     /**
      * the set of reserved words.
      */
-    private static final Set<String> RESERVED_WORDS = new HashSet<>();
-
-    static
-    {
-        RESERVED_WORDS.add("abstract");
-        RESERVED_WORDS.add("assert");
-        RESERVED_WORDS.add("boolean");
-        RESERVED_WORDS.add("break");
-        RESERVED_WORDS.add("byte");
-        RESERVED_WORDS.add("case");
-        RESERVED_WORDS.add("catch");
-        RESERVED_WORDS.add("char");
-        RESERVED_WORDS.add("class");
-        RESERVED_WORDS.add("const");
-        RESERVED_WORDS.add("continue");
-        RESERVED_WORDS.add("default");
-        RESERVED_WORDS.add("do");
-        RESERVED_WORDS.add("double");
-        RESERVED_WORDS.add("else");
-        RESERVED_WORDS.add("enum");
-        RESERVED_WORDS.add("extends");
-        RESERVED_WORDS.add("final");
-        RESERVED_WORDS.add("finally");
-        RESERVED_WORDS.add("float");
-        RESERVED_WORDS.add("for");
-        RESERVED_WORDS.add("goto");
-        RESERVED_WORDS.add("if");
-        RESERVED_WORDS.add("implements");
-        RESERVED_WORDS.add("import");
-        RESERVED_WORDS.add("instanceof");
-        RESERVED_WORDS.add("int");
-        RESERVED_WORDS.add("interface");
-        RESERVED_WORDS.add("long");
-        RESERVED_WORDS.add("native");
-        RESERVED_WORDS.add("new");
-        RESERVED_WORDS.add("package");
-        RESERVED_WORDS.add("private");
-        RESERVED_WORDS.add("protected");
-        RESERVED_WORDS.add("public");
-        RESERVED_WORDS.add("return");
-        RESERVED_WORDS.add("short");
-        RESERVED_WORDS.add("static");
-        RESERVED_WORDS.add("strictfp");
-        RESERVED_WORDS.add("super");
-        RESERVED_WORDS.add("switch");
-        RESERVED_WORDS.add("synchronized");
-        RESERVED_WORDS.add("this");
-        RESERVED_WORDS.add("throw");
-        RESERVED_WORDS.add("throws");
-        RESERVED_WORDS.add("transient");
-        RESERVED_WORDS.add("try");
-        RESERVED_WORDS.add("void");
-        RESERVED_WORDS.add("volatile");
-        RESERVED_WORDS.add("while");
-    }
+    private static final Set<String> RESERVED_WORDS = Set.of(
+        "abstract",
+        "assert",
+        "boolean",
+        "break",
+        "byte",
+        "case",
+        "catch",
+        "char",
+        "class",
+        "const",
+        "continue",
+        "default",
+        "do",
+        "double",
+        "else",
+        "enum",
+        "extends",
+        "final",
+        "finally",
+        "float",
+        "for",
+        "goto",
+        "if",
+        "implements",
+        "import",
+        "instanceof",
+        "int",
+        "interface",
+        "long",
+        "native",
+        "new",
+        "package",
+        "private",
+        "protected",
+        "public",
+        "return",
+        "short",
+        "static",
+        "strictfp",
+        "super",
+        "switch",
+        "synchronized",
+        "this",
+        "throw",
+        "throws",
+        "transient",
+        "try",
+        "void",
+        "volatile",
+        "while");
 
     /**
      * Sets the prefix to be prepended if the input is a reserved word.

Modified: 
db/torque/trunk/torque-generator/src/main/java/org/apache/torque/generator/template/velocity/VelocityOutlet.java
==============================================================================
--- 
db/torque/trunk/torque-generator/src/main/java/org/apache/torque/generator/template/velocity/VelocityOutlet.java
    Mon Jul 27 13:49:48 2026        (r1936637)
+++ 
db/torque/trunk/torque-generator/src/main/java/org/apache/torque/generator/template/velocity/VelocityOutlet.java
    Mon Jul 27 14:10:54 2026        (r1936638)
@@ -247,14 +247,13 @@ public class VelocityOutlet extends Temp
 
             Context context = createVelocityContext(controllerState);
 
-            Writer writer = new StringWriter();
-            try
+            try (Writer writer = new StringWriter())
             {
                 Velocity.evaluate(context, writer,
                         "VelocityTemplateOutlet:" + getName(),
                         getContent(controllerState));
                 writer.flush();
-                writer.close();
+                return new OutletResult(writer.toString());
             }
             catch (Exception e)
             {
@@ -269,8 +268,6 @@ public class VelocityOutlet extends Temp
                                 + e.getMessage(),
                                 e);
             }
-
-            return new OutletResult(writer.toString());
         }
         finally
         {

Modified: 
db/torque/trunk/torque-generator/src/main/java/org/apache/torque/generator/template/velocity/VelocityTemplateFilter.java
==============================================================================
--- 
db/torque/trunk/torque-generator/src/main/java/org/apache/torque/generator/template/velocity/VelocityTemplateFilter.java
    Mon Jul 27 13:49:48 2026        (r1936637)
+++ 
db/torque/trunk/torque-generator/src/main/java/org/apache/torque/generator/template/velocity/VelocityTemplateFilter.java
    Mon Jul 27 14:10:54 2026        (r1936638)
@@ -27,6 +27,7 @@ import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.OutputStreamWriter;
 import java.io.Writer;
+import java.nio.charset.Charset;
 import java.nio.charset.StandardCharsets;
 
 import org.apache.torque.generator.template.TemplateFilter;
@@ -60,93 +61,76 @@ public class VelocityTemplateFilter impl
     public InputStream filter(InputStream resource, String encoding)
             throws IOException
     {
-        InputStreamReader streamReader;
-        if (encoding == null)
-        {
-               // default to UTF 8 otherwise FindBugs complains of 
DM_DEFAULT_ENCODING
-            streamReader = new InputStreamReader(resource, 
StandardCharsets.UTF_8);
-        }
-        else
-        {
-            streamReader = new InputStreamReader(resource, encoding);
-        }
-        BufferedReader bufferedReader = new BufferedReader(streamReader);
-        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
-        Writer outputStreamWriter = null;
-        if (encoding == null)
-        {
-               // default to UTF 8 otherwise FindBugs complains of 
DM_DEFAULT_ENCODING
-            outputStreamWriter = new OutputStreamWriter(outputStream, 
StandardCharsets.UTF_8);
-        }
-        else
-        {
-            outputStreamWriter = new OutputStreamWriter(outputStream, 
encoding);
-        }
-
+        Charset encodingToUse = encoding == null ? StandardCharsets.UTF_8 : 
Charset.forName(encoding);
         boolean onlySpacesInLineSoFar = true;
         StringBuilder startLineBuffer = new StringBuilder();
-        while (true)
-        {
-            int readChar = bufferedReader.read();
 
-            if (readChar == -1)
-            {
-                break;
-            }
-            if (!onlySpacesInLineSoFar)
-            {
-                outputStreamWriter.write(readChar);
-                if ('\r' == readChar || '\n' == readChar)
-                {
-                    onlySpacesInLineSoFar = true;
-                }
-            }
-            else
+        try (InputStreamReader streamReader = new InputStreamReader(resource, 
encodingToUse);
+            BufferedReader bufferedReader = new BufferedReader(streamReader);
+            ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+            Writer outputStreamWriter = new OutputStreamWriter(outputStream, 
encodingToUse))
+        {
+            while (true)
             {
-                if (' ' == readChar)
-                {
-                    startLineBuffer.append((char) readChar);
-                }
-                else if ('\t' == readChar)
+                int readChar = bufferedReader.read();
+
+                if (readChar == -1)
                 {
-                    startLineBuffer.append(TAB_REPLACEMENT);
+                    break;
                 }
-                else if ('#' == readChar)
+                if (!onlySpacesInLineSoFar)
                 {
-                    if (startLineBuffer.length() != 0)
-                    {
-                        startLineBuffer = new StringBuilder();
-                    }
                     outputStreamWriter.write(readChar);
-                    onlySpacesInLineSoFar = false;
-                }
-                else if ('\r' == readChar || '\n' == readChar)
-                {
-                    if (startLineBuffer.length() != 0)
+                    if ('\r' == readChar || '\n' == readChar)
                     {
-                        outputStreamWriter.write(startLineBuffer.toString());
-                        startLineBuffer = new StringBuilder();
+                        onlySpacesInLineSoFar = true;
                     }
-                    outputStreamWriter.write(readChar);
                 }
                 else
                 {
-                    if (startLineBuffer.length() != 0)
+                    if (' ' == readChar)
                     {
-                        outputStreamWriter.write(startLineBuffer.toString());
-                        startLineBuffer = new StringBuilder();
+                        startLineBuffer.append((char) readChar);
                     }
-                    outputStreamWriter.write(readChar);
-                    onlySpacesInLineSoFar = false;
+                    else if ('\t' == readChar)
+                    {
+                        startLineBuffer.append(TAB_REPLACEMENT);
+                    }
+                    else if ('#' == readChar)
+                    {
+                        if (startLineBuffer.length() != 0)
+                        {
+                            startLineBuffer = new StringBuilder();
+                        }
+                        outputStreamWriter.write(readChar);
+                        onlySpacesInLineSoFar = false;
+                    }
+                    else if ('\r' == readChar || '\n' == readChar)
+                    {
+                        if (startLineBuffer.length() != 0)
+                        {
+                            
outputStreamWriter.write(startLineBuffer.toString());
+                            startLineBuffer = new StringBuilder();
+                        }
+                        outputStreamWriter.write(readChar);
+                    }
+                    else
+                    {
+                        if (startLineBuffer.length() != 0)
+                        {
+                            
outputStreamWriter.write(startLineBuffer.toString());
+                            startLineBuffer = new StringBuilder();
+                        }
+                        outputStreamWriter.write(readChar);
+                        onlySpacesInLineSoFar = false;
 
+                    }
                 }
             }
-        }
-        outputStreamWriter.write(startLineBuffer.toString());
+            outputStreamWriter.write(startLineBuffer.toString());
+            outputStreamWriter.flush();
 
-        outputStreamWriter.flush();
-        outputStreamWriter.close();
-
-        return new ByteArrayInputStream(outputStream.toByteArray());
+            return new ByteArrayInputStream(outputStream.toByteArray());
+        }
     }
 }

Modified: 
db/torque/trunk/torque-runtime/src/main/java/org/apache/torque/sql/whereclausebuilder/NoReplacementsPreparedStatementPart.java
==============================================================================
--- 
db/torque/trunk/torque-runtime/src/main/java/org/apache/torque/sql/whereclausebuilder/NoReplacementsPreparedStatementPart.java
      Mon Jul 27 13:49:48 2026        (r1936637)
+++ 
db/torque/trunk/torque-runtime/src/main/java/org/apache/torque/sql/whereclausebuilder/NoReplacementsPreparedStatementPart.java
      Mon Jul 27 14:10:54 2026        (r1936638)
@@ -19,7 +19,6 @@ package org.apache.torque.sql.whereclaus
  * under the License.
  */
 
-import java.util.Collections;
 import java.util.List;
 
 import org.apache.torque.criteria.PreparedStatementPart;
@@ -62,6 +61,6 @@ public class NoReplacementsPreparedState
     @Override
     public List<Object> getPreparedStatementReplacements()
     {
-        return Collections.emptyList();
+        return List.of();
     }
 }

Modified: 
db/torque/trunk/torque-runtime/src/main/java/org/apache/torque/util/LargeSelect.java
==============================================================================
--- 
db/torque/trunk/torque-runtime/src/main/java/org/apache/torque/util/LargeSelect.java
        Mon Jul 27 13:49:48 2026        (r1936637)
+++ 
db/torque/trunk/torque-runtime/src/main/java/org/apache/torque/util/LargeSelect.java
        Mon Jul 27 14:10:54 2026        (r1936638)
@@ -24,13 +24,13 @@ import java.io.ObjectInputStream;
 import java.io.Serializable;
 import java.text.MessageFormat;
 import java.util.ArrayList;
-import java.util.Hashtable;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.CopyOnWriteArrayList;
 
-import org.apache.logging.log4j.Logger;
 import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
 import org.apache.torque.Torque;
 import org.apache.torque.TorqueException;
 import org.apache.torque.criteria.Criteria;
@@ -838,7 +838,7 @@ public class LargeSelect<T> implements R
      * </ul>
      * <p>
      * Localized example in German:<br>
-     * <pre>Datens�tze {0} bis {1} von {2,choice,0#mehr als |1#}{3}</pre>
+     * <pre>Datens�tze {0} bis {1} von {2,choice,0#mehr als |1#}{3}</pre>
      *
      * @param recordProgressTextPattern
      */
@@ -1076,7 +1076,7 @@ public class LargeSelect<T> implements R
             {
                 if (null == params)
                 {
-                    params = new Hashtable<>();
+                    params = new HashMap<>();
                 }
                 params.put(name, value);
             }

Modified: 
db/torque/trunk/torque-runtime/src/main/java/org/apache/torque/util/SummaryHelper.java
==============================================================================
--- 
db/torque/trunk/torque-runtime/src/main/java/org/apache/torque/util/SummaryHelper.java
      Mon Jul 27 13:49:48 2026        (r1936637)
+++ 
db/torque/trunk/torque-runtime/src/main/java/org/apache/torque/util/SummaryHelper.java
      Mon Jul 27 14:10:54 2026        (r1936638)
@@ -26,10 +26,9 @@ import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
-import java.util.Vector;
 
-import org.apache.logging.log4j.Logger;
 import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
 import org.apache.torque.Column;
 import org.apache.torque.ColumnImpl;
 import org.apache.torque.Torque;
@@ -365,7 +364,7 @@ public class SummaryHelper
     {
         if (groupByColumns == null)
         {
-            groupByColumns = new Vector<>();
+            groupByColumns = new ArrayList<>();
         }
         return groupByColumns;
     }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to