This is an automated email from the ASF dual-hosted git repository.
kunalkapoor pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/carbondata.git
The following commit(s) were added to refs/heads/master by this push:
new 56a1667 [CARBONDATA-3499] Fix insert failure with customFileProvider
56a1667 is described below
commit 56a1667127aff1e8aff4e55ae669483e42b7a975
Author: ajantha-bhat <[email protected]>
AuthorDate: Thu Aug 22 17:42:12 2019 +0530
[CARBONDATA-3499] Fix insert failure with customFileProvider
Problem:
Below exception is thrown when the custom file system is used with
first time insert randomly. IllegalArgumentException("Path belongs to
unsupported file system") from FileFactory.getFileType()
Cause:
DefaultFileTypeProvider.initializeCustomFileProvider is called concurrently
during insert. Hence one thread got the provider and other thread didn't get
as flag is set to true. so other thread failed as it tried with default
provider.
Solution:
synchronize the initialization of custom file provider.
This closes #3362
---
.../datastore/impl/DefaultFileTypeProvider.java | 31 +++++++++++++---------
1 file changed, 19 insertions(+), 12 deletions(-)
diff --git
a/core/src/main/java/org/apache/carbondata/core/datastore/impl/DefaultFileTypeProvider.java
b/core/src/main/java/org/apache/carbondata/core/datastore/impl/DefaultFileTypeProvider.java
index cdb1a20..4572cc4 100644
---
a/core/src/main/java/org/apache/carbondata/core/datastore/impl/DefaultFileTypeProvider.java
+++
b/core/src/main/java/org/apache/carbondata/core/datastore/impl/DefaultFileTypeProvider.java
@@ -43,7 +43,9 @@ public class DefaultFileTypeProvider implements
FileTypeInterface {
*/
protected FileTypeInterface customFileTypeProvider = null;
- protected boolean customFileTypeProviderInitialized = false;
+ protected Boolean customFileTypeProviderInitialized = false;
+
+ private final Object lock = new Object();
public DefaultFileTypeProvider() {
}
@@ -52,17 +54,22 @@ public class DefaultFileTypeProvider implements
FileTypeInterface {
* This method is required apart from Constructor to handle the below
circular dependency.
* CarbonProperties-->FileFactory-->DefaultTypeProvider-->CarbonProperties
*/
- private void initializeCustomFileprovider() {
+ private void initializeCustomFileProvider() {
if (!customFileTypeProviderInitialized) {
- customFileTypeProviderInitialized = true;
- String customFileProvider =
-
CarbonProperties.getInstance().getProperty(CarbonCommonConstants.CUSTOM_FILE_PROVIDER);
- if (customFileProvider != null && !customFileProvider.trim().isEmpty()) {
- try {
- customFileTypeProvider =
- (FileTypeInterface)
Class.forName(customFileProvider).newInstance();
- } catch (Exception e) {
- LOGGER.error("Unable load configured FileTypeInterface class.
Ignored.", e);
+ // This initialization can happen in concurrent threads.
+ synchronized (lock) {
+ if (!customFileTypeProviderInitialized) {
+ String customFileProvider = CarbonProperties.getInstance()
+ .getProperty(CarbonCommonConstants.CUSTOM_FILE_PROVIDER);
+ if (customFileProvider != null &&
!customFileProvider.trim().isEmpty()) {
+ try {
+ customFileTypeProvider =
+ (FileTypeInterface)
Class.forName(customFileProvider).newInstance();
+ } catch (Exception e) {
+ LOGGER.error("Unable load configured FileTypeInterface class.
Ignored.", e);
+ }
+ customFileTypeProviderInitialized = true;
+ }
}
}
}
@@ -77,7 +84,7 @@ public class DefaultFileTypeProvider implements
FileTypeInterface {
* @return true if supported by the custom
*/
@Override public boolean isPathSupported(String path) {
- initializeCustomFileprovider();
+ initializeCustomFileProvider();
if (customFileTypeProvider != null) {
return customFileTypeProvider.isPathSupported(path);
}