use of java.nio.file.AccessDeniedException in project buck by facebook.
the class ThrowableConsoleEventTest method throwableClassNameIsIncludedInDescription.
@Test
public void throwableClassNameIsIncludedInDescription() {
ThrowableConsoleEvent event = new ThrowableConsoleEvent(new AccessDeniedException("somefile"), "message");
assertTrue(event.getMessage().contains("AccessDeniedException"));
}
use of java.nio.file.AccessDeniedException in project hadoop by apache.
the class ITestS3AAWSCredentialsProvider method testBadCredentials.
@Test
public void testBadCredentials() throws Exception {
Configuration conf = new Configuration();
conf.set(AWS_CREDENTIALS_PROVIDER, BadCredentialsProvider.class.getName());
try {
createFailingFS(conf);
} catch (AccessDeniedException e) {
// expected
}
}
use of java.nio.file.AccessDeniedException in project hadoop by apache.
the class LogCLIHelpers method getOwnerForAppIdOrNull.
@Private
@VisibleForTesting
public static /**
* Return the owner for a given AppId
* @param remoteRootLogDir
* @param appId
* @param bestGuess
* @param conf
* @return the owner or null
* @throws IOException
*/
String getOwnerForAppIdOrNull(ApplicationId appId, String bestGuess, Configuration conf) throws IOException {
Path remoteRootLogDir = new Path(conf.get(YarnConfiguration.NM_REMOTE_APP_LOG_DIR, YarnConfiguration.DEFAULT_NM_REMOTE_APP_LOG_DIR));
String suffix = LogAggregationUtils.getRemoteNodeLogDirSuffix(conf);
Path fullPath = LogAggregationUtils.getRemoteAppLogDir(remoteRootLogDir, appId, bestGuess, suffix);
FileContext fc = FileContext.getFileContext(remoteRootLogDir.toUri(), conf);
String pathAccess = fullPath.toString();
try {
if (fc.util().exists(fullPath)) {
return bestGuess;
}
Path toMatch = LogAggregationUtils.getRemoteAppLogDir(remoteRootLogDir, appId, "*", suffix);
pathAccess = toMatch.toString();
FileStatus[] matching = fc.util().globStatus(toMatch);
if (matching == null || matching.length != 1) {
return null;
}
//fetch the user from the full path /app-logs/user[/suffix]/app_id
Path parent = matching[0].getPath().getParent();
//skip the suffix too
if (suffix != null && !StringUtils.isEmpty(suffix)) {
parent = parent.getParent();
}
return parent.getName();
} catch (AccessControlException | AccessDeniedException ex) {
logDirNoAccessPermission(pathAccess, bestGuess, ex.getMessage());
return null;
}
}
use of java.nio.file.AccessDeniedException in project neo4j by neo4j.
the class LoaderTest method shouldGiveAClearErrorMessageIfTheDestinationsParentDirectoryIsNotWritable.
@Test
public void shouldGiveAClearErrorMessageIfTheDestinationsParentDirectoryIsNotWritable() throws IOException, IncorrectFormat {
assumeFalse("We haven't found a way to reliably tests permissions on Windows", SystemUtils.IS_OS_WINDOWS);
Path archive = testDirectory.file("the-archive.dump").toPath();
Path destination = testDirectory.directory("subdir/the-destination").toPath();
Files.createDirectories(destination.getParent());
try (Closeable ignored = withPermissions(destination.getParent(), emptySet())) {
new Loader().load(archive, destination);
fail("Expected an exception");
} catch (AccessDeniedException e) {
assertEquals(destination.getParent().toString(), e.getMessage());
}
}
use of java.nio.file.AccessDeniedException in project beam by apache.
the class GcsUtil method createBucket.
@VisibleForTesting
void createBucket(String projectId, Bucket bucket, BackOff backoff, Sleeper sleeper) throws IOException {
Storage.Buckets.Insert insertBucket = storageClient.buckets().insert(projectId, bucket);
insertBucket.setPredefinedAcl("projectPrivate");
insertBucket.setPredefinedDefaultObjectAcl("projectPrivate");
try {
ResilientOperation.retry(ResilientOperation.getGoogleRequestCallable(insertBucket), backoff, new RetryDeterminer<IOException>() {
@Override
public boolean shouldRetry(IOException e) {
if (errorExtractor.itemAlreadyExists(e) || errorExtractor.accessDenied(e)) {
return false;
}
return RetryDeterminer.SOCKET_ERRORS.shouldRetry(e);
}
}, IOException.class, sleeper);
return;
} catch (GoogleJsonResponseException e) {
if (errorExtractor.accessDenied(e)) {
throw new AccessDeniedException(bucket.getName(), null, e.getMessage());
}
if (errorExtractor.itemAlreadyExists(e)) {
throw new FileAlreadyExistsException(bucket.getName(), null, e.getMessage());
}
throw e;
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new IOException(String.format("Error while attempting to create bucket gs://%s for rproject %s", bucket.getName(), projectId), e);
}
}
Aggregations