chibenwa commented on code in PR #2490:
URL: https://github.com/apache/james-project/pull/2490#discussion_r1832523781


##########
mailet/standard/src/main/java/org/apache/james/transport/mailets/FoldLongLines.java:
##########
@@ -40,25 +44,45 @@
  */
 public class FoldLongLines extends GenericMailet {
     public static final String MAX_CHARACTERS_PARAMETER_NAME = "maxCharacters";
+    public static final String HEADER_SEPARATOR = ": ";
 
     private static final int DEFAULT_MAX_CHARACTERS = 998;
+    private static final String SEPARATE_LINE_REGEX = "\r\n|\n";
 
     private Integer maxCharacters;
 
     @Override
     public void init() throws MessagingException {
-        maxCharacters = 
getInitParameterAsOptional(MAX_CHARACTERS_PARAMETER_NAME).map(Integer::parseInt).orElse(DEFAULT_MAX_CHARACTERS);
+        Integer maxCharacters = 
getInitParameterAsOptional(MAX_CHARACTERS_PARAMETER_NAME).map(Integer::parseInt).orElse(DEFAULT_MAX_CHARACTERS);
+        Preconditions.checkArgument(maxCharacters > 0, "maxCharacters must be 
positive");
+        this.maxCharacters = maxCharacters;
     }
 
     @Override
     public void service(Mail mail) throws MessagingException {
-        List<Header> foldedHeaders = 
Streams.of(mail.getMessage().getAllHeaders().asIterator()).map(this::fold).toList();
-        foldedHeaders.forEach(Throwing.consumer(header -> 
mail.getMessage().setHeader(header.getName(), header.getValue())));
+        // get all header names of headers that exceed line limit
+        Set<String> longHeaders = 
Streams.of(mail.getMessage().getAllHeaders().asIterator()).filter(this::exceedLineLimit).map(Header::getName).collect(ImmutableSet.toImmutableSet());

Review Comment:
   Extract to a submethod and indent



-- 
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-unsubscr...@james.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org
For additional commands, e-mail: notifications-h...@james.apache.org

Reply via email to