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

ASF GitHub Bot logged work on HADOOP-17745:
-------------------------------------------

                Author: ASF GitHub Bot
            Created on: 23/Jun/21 20:32
            Start Date: 23/Jun/21 20:32
    Worklog Time Spent: 10m 
      Work Description: steveloughran commented on a change in pull request 
#3076:
URL: https://github.com/apache/hadoop/pull/3076#discussion_r657439098



##########
File path: 
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestIOUtilsWrapExceptionSuite.java
##########
@@ -0,0 +1,60 @@
+/**
+ * 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.hadoop.io;
+
+import java.io.IOException;
+import java.io.InterruptedIOException;
+
+import static junit.framework.TestCase.assertEquals;
+import static junit.framework.TestCase.assertTrue;
+import org.apache.hadoop.test.AbstractHadoopTestBase;
+import org.assertj.core.api.Assertions;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class TestIOUtilsWrapExceptionSuite extends AbstractHadoopTestBase {
+    @Test
+    public void testWrapExceptionWithInterruptedException() throws Exception {
+        InterruptedIOException inputException = new 
InterruptedIOException("message");
+        NullPointerException causeException = new 
NullPointerException("cause");
+        inputException.initCause(causeException);
+        Exception outputException = IOUtils.wrapException("path", 
"methodName", inputException);
+
+        // The new exception should retain the input message, cause, and type
+        
Assertions.assertThat(outputException).isInstanceOf(InterruptedIOException.class);
+        
Assertions.assertThat(outputException.getCause()).isInstanceOf(NullPointerException.class);

Review comment:
       can you add a .describedAs("inner cause")

##########
File path: 
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestIOUtilsWrapExceptionSuite.java
##########
@@ -0,0 +1,60 @@
+/**
+ * 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.hadoop.io;
+
+import java.io.IOException;
+import java.io.InterruptedIOException;
+
+import static junit.framework.TestCase.assertEquals;

Review comment:
       nit: can you copy the import ordering of (most) of the hadoop code.
   
   java*
   
   non-org.apache. (though we are hadoop shaded guava is now in there too)
   
   org.apache.*
   
   static *
   
   thanks

##########
File path: 
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestIOUtilsWrapExceptionSuite.java
##########
@@ -0,0 +1,60 @@
+/**
+ * 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.hadoop.io;
+
+import java.io.IOException;
+import java.io.InterruptedIOException;
+
+import static junit.framework.TestCase.assertEquals;
+import static junit.framework.TestCase.assertTrue;
+import org.apache.hadoop.test.AbstractHadoopTestBase;
+import org.assertj.core.api.Assertions;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class TestIOUtilsWrapExceptionSuite extends AbstractHadoopTestBase {
+    @Test
+    public void testWrapExceptionWithInterruptedException() throws Exception {
+        InterruptedIOException inputException = new 
InterruptedIOException("message");
+        NullPointerException causeException = new 
NullPointerException("cause");
+        inputException.initCause(causeException);
+        Exception outputException = IOUtils.wrapException("path", 
"methodName", inputException);
+
+        // The new exception should retain the input message, cause, and type
+        
Assertions.assertThat(outputException).isInstanceOf(InterruptedIOException.class);
+        
Assertions.assertThat(outputException.getCause()).isInstanceOf(NullPointerException.class);
+        assertEquals(outputException.getMessage(), 
inputException.getMessage());
+        assertEquals(outputException.getCause(), inputException.getCause());
+    }
+
+    @Test
+    public void testWrapExceptionWithInterruptedCauseException() throws 
Exception {
+        IOException inputException = new IOException("message");
+        InterruptedException causeException = new 
InterruptedException("cause");
+        inputException.initCause(causeException);
+        Exception outputException = IOUtils.wrapException("path", 
"methodName", inputException);
+
+        // The new exception should retain the input message and cause
+        // but be an InterruptedIOException because the cause was an 
InterruptedException
+        
Assertions.assertThat(outputException).isInstanceOf(InterruptedIOException.class);
+        
Assertions.assertThat(outputException.getCause()).isInstanceOf(InterruptedException.class);
+        assertEquals(outputException.getMessage(), 
inputException.getMessage());

Review comment:
       can you add "getMessage()" as the string message of this; something 
similar for below. I need to know what assert is failing without looking up the 
source tree to find what was at line 57, especially as that can move




-- 
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.

For queries about this service, please contact Infrastructure at:
[email protected]


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

    Worklog Id:     (was: 614213)
    Time Spent: 1h 20m  (was: 1h 10m)

> ADLS client can throw an IOException when it should throw an 
> InterruptedIOException
> -----------------------------------------------------------------------------------
>
>                 Key: HADOOP-17745
>                 URL: https://issues.apache.org/jira/browse/HADOOP-17745
>             Project: Hadoop Common
>          Issue Type: Bug
>            Reporter: Eric Maynard
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 1h 20m
>  Remaining Estimate: 0h
>
> The Azure client sometimes throws an IOException with an InterruptedException 
> cause which can be converted to an InterruptedIOException. This is important 
> for downstream consumers that rely on an InterruptedIOException to gracefully 
> close.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

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

Reply via email to