[
https://issues.apache.org/jira/browse/HADOOP-17745?focusedWorklogId=608761&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-608761
]
ASF GitHub Bot logged work on HADOOP-17745:
-------------------------------------------
Author: ASF GitHub Bot
Created on: 08/Jun/21 21:20
Start Date: 08/Jun/21 21:20
Worklog Time Spent: 10m
Work Description: steveloughran commented on a change in pull request
#3076:
URL: https://github.com/apache/hadoop/pull/3076#discussion_r647799533
##########
File path:
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/IOUtils.java
##########
@@ -482,6 +482,12 @@ public static IOException wrapException(final String path,
if (exception instanceof InterruptedIOException
|| exception instanceof PathIOException) {
return exception;
+ } else if (exception.getCause() != null
+ && exception.getCause() instanceof InterruptedException) {
Review comment:
you can get rid of the !=null check, as L486 does that implicitly
##########
File path:
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestIOUtilsWrapExceptionSuite.java
##########
@@ -0,0 +1,56 @@
+/**
+ * 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 org.junit.Assert;
+import org.junit.Test;
+
+public class TestIOUtilsWrapExceptionSuite extends Assert {
Review comment:
extends AbstractHadoopTestBase ; this sets up a timeout and names the
test thread
##########
File path:
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestIOUtilsWrapExceptionSuite.java
##########
@@ -0,0 +1,56 @@
+/**
+ * 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 org.junit.Assert;
+import org.junit.Test;
+
+public class TestIOUtilsWrapExceptionSuite extends Assert {
+ @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
+ assertTrue(outputException instanceof InterruptedIOException);
+ assertTrue(outputException.getCause() instanceof NullPointerException);
+ 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
+ assertTrue(outputException instanceof InterruptedIOException);
Review comment:
same here, embrace AssertJ. It's better, mostly.
##########
File path:
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestIOUtilsWrapExceptionSuite.java
##########
@@ -0,0 +1,56 @@
+/**
+ * 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 org.junit.Assert;
+import org.junit.Test;
+
+public class TestIOUtilsWrapExceptionSuite extends Assert {
+ @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
+ assertTrue(outputException instanceof InterruptedIOException);
Review comment:
Can you use AssertJ assertions here? They'll fail with useful error messages
rather than just an "assert failed" which isn't any use debugging why something
failed.
```java
Assertions.assertThat(outputException)
.isInstanceOf(IOException.class);
```
--
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: 608761)
Time Spent: 1h 10m (was: 1h)
> 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 10m
> 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]