use of com.amazonaws.AbortedException in project aws-sdk-android by aws-amplify.
the class RetryUtilsTest method testIsInterruptedException.
@Test
public void testIsInterruptedException() {
assertTrue(RetryUtils.isInterrupted(new AbortedException()));
Exception interrupted = new Exception(new InterruptedException());
assertTrue(RetryUtils.isInterrupted(interrupted));
Exception interruptedio = new Exception(new InterruptedIOException());
assertTrue(RetryUtils.isInterrupted(interruptedio));
Exception socketTimeout = new Exception(new SocketTimeoutException());
assertFalse(RetryUtils.isInterrupted(socketTimeout));
}
use of com.amazonaws.AbortedException in project javabuilder by code-dot-org.
the class AWSContentManager method generateAssetUploadUrl.
@Override
public String generateAssetUploadUrl(String filename) throws JavabuilderException {
if (this.uploads >= UPLOADS_PER_SESSION) {
throw new UserInitiatedException(UserInitiatedExceptionKey.TOO_MANY_UPLOADS, String.format("Too many Prompter images. We currently support up to %s Prompter images per project.\n", UPLOADS_PER_SESSION));
}
final String key = this.generateKey(filename);
final long expirationTimeMs = System.currentTimeMillis() + context.getRemainingTimeInMillis();
try {
final URL presignedUrl = s3Client.generatePresignedUrl(this.bucketName, key, new Date(expirationTimeMs), HttpMethod.PUT);
this.uploads++;
// Add the GET url for this file to the asset map so it can be referenced later.
this.projectData.addNewAssetUrl(filename, this.contentBucketUrl + "/" + key);
return this.contentBucketUrl + presignedUrl.getFile();
} catch (AbortedException e) {
// this is most likely because the end user interrupted program execution. We can safely
// ignore this.
} catch (SdkClientException e) {
throw new InternalServerError(InternalErrorKey.INTERNAL_RUNTIME_EXCEPTION, e);
}
return null;
}
use of com.amazonaws.AbortedException in project javabuilder by code-dot-org.
the class AWSContentManager method writeToOutputFile.
@Override
public String writeToOutputFile(String filename, byte[] inputBytes, String contentType) throws JavabuilderException {
if (this.writes >= WRITES_PER_SESSION) {
throw new UserInitiatedException(UserInitiatedExceptionKey.TOO_MANY_WRITES);
}
String filePath = this.generateKey(filename);
ObjectMetadata metadata = new ObjectMetadata();
metadata.setContentType(contentType);
metadata.setContentLength(inputBytes.length);
ByteArrayInputStream inputStream = new ByteArrayInputStream(inputBytes);
try {
this.s3Client.putObject(this.bucketName, filePath, inputStream, metadata);
} catch (AbortedException e) {
// this is most likely because the end user interrupted program execution. We can safely
// ignore this.
} catch (SdkClientException e) {
// We couldn't write to S3, send a message to the user and fail. The S3 SDK includes retries.
throw new InternalServerError(InternalErrorKey.INTERNAL_RUNTIME_EXCEPTION, e);
}
this.writes++;
return this.contentBucketUrl + "/" + filePath;
}
use of com.amazonaws.AbortedException in project datarouter by hotpads.
the class BaseSqsPeekMultiOp method run.
@Override
protected final List<T> run() {
ReceiveMessageRequest request = makeRequest();
ReceiveMessageResult result;
try {
result = sqsClientManager.getAmazonSqs(clientId).receiveMessage(request);
} catch (AbortedException e) {
throw new UncheckedInterruptedException("", e);
}
List<Message> messages = result.getMessages();
return messages.isEmpty() ? List.of() : extractDatabeans(messages);
}
use of com.amazonaws.AbortedException in project datarouter by hotpads.
the class SqsAckOp method run.
@Override
protected Void run() {
String handle = StringCodec.UTF_8.decode(key.getHandle());
var deleteRequest = new DeleteMessageRequest(queueUrl, handle);
try {
sqsClientManager.getAmazonSqs(clientId).deleteMessage(deleteRequest);
} catch (AbortedException e) {
throw new UncheckedInterruptedException("", e);
}
return null;
}
Aggregations