This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit 4d5b1bb064aba7fb94f3f784a3c40b48e445820f
Author: Matthieu Baechler <[email protected]>
AuthorDate: Wed Apr 15 22:59:11 2020 +0200

    [Refactoring] deleting dead code (the cast was buggy and the 
CombinedInputStream is never instanciated)
---
 .../james/protocols/api/CombinedInputStream.java   | 70 ----------------------
 .../protocols/netty/NettyProtocolTransport.java    | 21 +------
 2 files changed, 1 insertion(+), 90 deletions(-)

diff --git 
a/protocols/api/src/main/java/org/apache/james/protocols/api/CombinedInputStream.java
 
b/protocols/api/src/main/java/org/apache/james/protocols/api/CombinedInputStream.java
deleted file mode 100644
index d0f4924..0000000
--- 
a/protocols/api/src/main/java/org/apache/james/protocols/api/CombinedInputStream.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/****************************************************************
- * 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.                                           *
- ****************************************************************/
-
-package org.apache.james.protocols.api;
-
-import java.io.InputStream;
-import java.io.SequenceInputStream;
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-
-/**
- * {@link SequenceInputStream} sub-class which allows direct access to the 
pair of {@link InputStream}'s.
- * 
- * When ever you need to "combine" two {@link InputStream}'s you should use 
this class as it may allow the Transport to optimize the transfer of it!
- */
-public class CombinedInputStream extends SequenceInputStream implements 
Iterable<InputStream> {
-
-    private final InputStream[] streams;
-
-    public CombinedInputStream(InputStream s1, InputStream s2) {
-        super(s1, s2);
-        streams = new InputStream[] {s1, s2};
-    }
-
-    @Override
-    public Iterator<InputStream> iterator() {
-        return new Iterator<InputStream>() {
-            private int count = 0;
-
-            @Override
-            public boolean hasNext() {
-                return count < streams.length;
-            }
-
-            @Override
-            public InputStream next() {
-                if (hasNext())  {
-                    return streams[count++];
-                } else {
-                    throw new NoSuchElementException();
-                }
-            }
-            
-            /**
-             * Read-Only
-             */
-            @Override
-            public void remove() {
-                throw new UnsupportedOperationException("Read-Only");
-            }
-        };
-    }
-
-}
diff --git 
a/protocols/netty/src/main/java/org/apache/james/protocols/netty/NettyProtocolTransport.java
 
b/protocols/netty/src/main/java/org/apache/james/protocols/netty/NettyProtocolTransport.java
index db95968..6d0b3b4 100644
--- 
a/protocols/netty/src/main/java/org/apache/james/protocols/netty/NettyProtocolTransport.java
+++ 
b/protocols/netty/src/main/java/org/apache/james/protocols/netty/NettyProtocolTransport.java
@@ -28,7 +28,6 @@ import java.nio.channels.FileChannel;
 import javax.net.ssl.SSLEngine;
 
 import org.apache.james.protocols.api.AbstractProtocolTransport;
-import org.apache.james.protocols.api.CombinedInputStream;
 import org.apache.james.protocols.api.ProtocolSession;
 import org.apache.james.protocols.api.handler.LineHandler;
 import org.jboss.netty.buffer.ChannelBuffers;
@@ -126,26 +125,8 @@ public class NettyProtocolTransport extends 
AbstractProtocolTransport {
                     channel.write(new ChunkedStream(new 
ExceptionInputStream(e)));
                 }
                 return;
-
-            } else if (in instanceof CombinedInputStream) {
-                for (InputStream pIn : (CombinedInputStream) in) {
-                    if (pIn instanceof FileInputStream) {
-                        FileChannel fChannel = ((FileInputStream) 
in).getChannel();
-                        try {
-                            channel.write(new DefaultFileRegion(fChannel, 0, 
fChannel.size(), true));
-                            return;
-
-                        } catch (IOException e) {
-                            // We handle this later
-                            channel.write(new ChunkedStream(new 
ExceptionInputStream(e)));
-                        }
-                    } else {
-                        channel.write(new ChunkedStream(in));
-                    }
-                }
-                return;
             }
-        } 
+        }
         channel.write(new ChunkedStream(in));
     }
 


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

Reply via email to