crail-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From PepperJo <...@git.apache.org>
Subject [GitHub] incubator-crail pull request #25: Make default configuration easier to run
Date Wed, 20 Jun 2018 12:33:26 GMT
Github user PepperJo commented on a diff in the pull request:

    https://github.com/apache/incubator-crail/pull/25#discussion_r196755299
  
    --- Diff: client/src/main/java/org/apache/crail/memory/MappedBufferCache.java ---
    @@ -53,13 +53,17 @@ public MappedBufferCache() throws IOException {
     			id = "" + System.currentTimeMillis();
     			directory = CrailUtils.getCacheDirectory(id);
     			dir = new File(directory);
    -			if (!dir.exists()){
    -				if (!dir.mkdirs()) {
    -					throw new IOException("Cannot create cache directory [crail.cachepath] set to path
" + directory + ", check if crail.cachepath exists and has write permissions");
    +			try {
    +				if (!dir.exists()){
    +					if (!dir.mkdirs()) {
    +						throw new IOException("Cannot create cache directory [crail.cachepath] set to path
" + directory + ", check if crail.cachepath exists and has write permissions");
    +					}
     				}
    -			}
    -			for (File child : dir.listFiles()) {
    -				child.delete();
    +				for (File child : dir.listFiles()) {
    +					child.delete();
    +				}
    +			} catch(SecurityException e) {
    +				throw new IOException("Security exception when trying to access " + directory + ",
please check the directory permissions", e);
    --- End diff --
    
    If the dir is not accessable but it exists and has no children this runs through but the
creation of the RandomAccessFile will fail. We should also check if the creation was successful
in allocateRegion and print a meaningful error message. Or check here if dir is accessible
and if it is a dir in the first place, e.g. dir.isDirectory() and dir.canWrite() (I have not
tested this).


---

Mime
View raw message