This is an automated email from the ASF dual-hosted git repository.
abhishek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/druid.git
The following commit(s) were added to refs/heads/master by this push:
new 1d1f53e7d5 Improve error messages when URI points to a file that
doesn't exist (#12490)
1d1f53e7d5 is described below
commit 1d1f53e7d5c3cd7f0e3c9e8e189b063be0fc50ac
Author: Tejaswini Bandlamudi <[email protected]>
AuthorDate: Sun May 1 11:26:16 2022 +0530
Improve error messages when URI points to a file that doesn't exist (#12490)
---
.../input/impl/InputEntityIteratingReader.java | 4 ++-
.../input/impl/InputEntityIteratingReaderTest.java | 31 ++++++++++++++++++++++
2 files changed, 34 insertions(+), 1 deletion(-)
diff --git
a/core/src/main/java/org/apache/druid/data/input/impl/InputEntityIteratingReader.java
b/core/src/main/java/org/apache/druid/data/input/impl/InputEntityIteratingReader.java
index d52097c318..0354bea279 100644
---
a/core/src/main/java/org/apache/druid/data/input/impl/InputEntityIteratingReader.java
+++
b/core/src/main/java/org/apache/druid/data/input/impl/InputEntityIteratingReader.java
@@ -78,7 +78,9 @@ public class InputEntityIteratingReader implements
InputSourceReader
return reader.read();
}
catch (IOException e) {
- throw new RuntimeException(e);
+ throw new RuntimeException(entity.getUri() != null ?
+ "Error occured while trying to read uri: "
+ entity.getUri() :
+ "Error occured while reading input", e);
}
});
}
diff --git
a/core/src/test/java/org/apache/druid/data/input/impl/InputEntityIteratingReaderTest.java
b/core/src/test/java/org/apache/druid/data/input/impl/InputEntityIteratingReaderTest.java
index 37b35f1498..355e9f33e7 100644
---
a/core/src/test/java/org/apache/druid/data/input/impl/InputEntityIteratingReaderTest.java
+++
b/core/src/test/java/org/apache/druid/data/input/impl/InputEntityIteratingReaderTest.java
@@ -35,6 +35,8 @@ import org.junit.rules.TemporaryFolder;
import java.io.File;
import java.io.IOException;
import java.io.Writer;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.ArrayList;
@@ -95,4 +97,33 @@ public class InputEntityIteratingReaderTest
Assert.assertEquals(numFiles, i);
}
}
+
+ @Test
+ public void testIncorrectURI() throws IOException, URISyntaxException
+ {
+ final InputEntityIteratingReader firehose = new InputEntityIteratingReader(
+ new InputRowSchema(
+ new TimestampSpec(null, null, null),
+ new DimensionsSpec(
+ DimensionsSpec.getDefaultSchemas(ImmutableList.of("time",
"name", "score"))
+ ),
+ ColumnsFilter.all()
+ ),
+ new CsvInputFormat(
+ ImmutableList.of("time", "name", "score"),
+ null,
+ null,
+ false,
+ 0
+ ),
+ ImmutableList.of(
+ new HttpEntity(new URI("testscheme://some/path"), null, null)
+ ).iterator(),
+ temporaryFolder.newFolder()
+ );
+ String expectedMessage = "Error occured while trying to read uri:
testscheme://some/path";
+ Exception exception = Assert.assertThrows(RuntimeException.class,
firehose::read);
+
+ Assert.assertTrue(exception.getMessage().contains(expectedMessage));
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]