You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ts...@apache.org on 2019/08/22 03:45:27 UTC

[camel] branch master updated: Revert "CAMEL-13886: camel-servlet + camel-http4 with null body causes "Stream closed" IOException"

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

tsato pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/master by this push:
     new 83031b6  Revert "CAMEL-13886: camel-servlet + camel-http4 with null body causes "Stream closed" IOException"
83031b6 is described below

commit 83031b6205d77b735fd9647734af80d88d476f42
Author: Tadayoshi Sato <sa...@gmail.com>
AuthorDate: Thu Aug 22 12:44:16 2019 +0900

    Revert "CAMEL-13886: camel-servlet + camel-http4 with null body causes "Stream closed" IOException"
    
    This reverts commit 4b9b619138d779e7f55743f20bfad68f394d1d15.
    This causes test failures in camel-jetty and camel-servlet.
---
 components/camel-http-common/pom.xml               |  5 ---
 .../org/apache/camel/http/common/HttpHelper.java   |  4 +-
 .../apache/camel/http/common/HttpHelperTest.java   | 50 ----------------------
 3 files changed, 2 insertions(+), 57 deletions(-)

diff --git a/components/camel-http-common/pom.xml b/components/camel-http-common/pom.xml
index d92f43e..242b1be 100644
--- a/components/camel-http-common/pom.xml
+++ b/components/camel-http-common/pom.xml
@@ -95,10 +95,5 @@
             <version>${assertj-version}</version>
             <scope>test</scope>
         </dependency>
-        <dependency>
-            <groupId>org.mockito</groupId>
-            <artifactId>mockito-core</artifactId>
-            <scope>test</scope>
-        </dependency>
     </dependencies>
 </project>
diff --git a/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpHelper.java b/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpHelper.java
index 31d8c8d..d647ea4 100644
--- a/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpHelper.java
+++ b/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpHelper.java
@@ -200,7 +200,7 @@ public final class HttpHelper {
      * @throws IOException is thrown if error reading response body
      */
     public static Object readRequestBodyFromInputStream(InputStream is, Exchange exchange) throws IOException {
-        if (is == null || is.available() <= 0) {
+        if (is == null) {
             return null;
         }
         boolean disableStreamCaching = !exchange.getContext().isStreamCaching();
@@ -224,7 +224,7 @@ public final class HttpHelper {
      * @throws IOException is thrown if error reading response body
      */
     public static Object readResponseBodyFromInputStream(InputStream is, Exchange exchange) throws IOException {
-        if (is == null || is.available() <= 0) {
+        if (is == null) {
             return null;
         }
         // convert the input stream to StreamCache if the stream cache is not disabled
diff --git a/components/camel-http-common/src/test/java/org/apache/camel/http/common/HttpHelperTest.java b/components/camel-http-common/src/test/java/org/apache/camel/http/common/HttpHelperTest.java
deleted file mode 100644
index f2d518c..0000000
--- a/components/camel-http-common/src/test/java/org/apache/camel/http/common/HttpHelperTest.java
+++ /dev/null
@@ -1,50 +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.camel.http.common;
-
-import java.io.IOException;
-import javax.servlet.ServletInputStream;
-import javax.servlet.http.HttpServletRequest;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.Exchange;
-import org.apache.camel.impl.DefaultCamelContext;
-import org.apache.camel.support.DefaultExchange;
-import org.junit.Test;
-
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-public class HttpHelperTest {
-
-    @Test
-    public void readRequestBodyFromServletRequest() throws IOException {
-        HttpServletRequest request = mock(HttpServletRequest.class);
-        ServletInputStream is = mock(ServletInputStream.class);
-        when(request.getInputStream()).thenReturn(is);
-        when(is.available()).thenReturn(0);
-
-        CamelContext context = new DefaultCamelContext();
-        Exchange exchange = new DefaultExchange(context);
-
-        assertNull(HttpHelper.readRequestBodyFromServletRequest(null, exchange));
-        assertNull(HttpHelper.readRequestBodyFromServletRequest(request, exchange));
-    }
-
-}