|
36 | 36 | import software.amazon.awssdk.core.async.AsyncRequestBodySplitConfiguration; |
37 | 37 | import software.amazon.awssdk.core.async.CloseableAsyncRequestBody; |
38 | 38 | import software.amazon.awssdk.core.async.SdkPublisher; |
| 39 | +import software.amazon.awssdk.core.exception.SdkClientException; |
39 | 40 | import software.amazon.awssdk.core.internal.util.Mimetype; |
40 | 41 | import software.amazon.awssdk.core.internal.util.NoopSubscription; |
41 | 42 | import software.amazon.awssdk.utils.Logger; |
@@ -469,31 +470,30 @@ private boolean validateFileUnchanged() { |
469 | 470 | try { |
470 | 471 | long sizeAtEnd = Files.size(path); |
471 | 472 | if (sizeAtStart != sizeAtEnd) { |
472 | | - signalOnError(new RuntimeException("File size changed after reading started. Initial size: " |
473 | | - + sizeAtStart + ". Current size: " + sizeAtEnd)); |
| 473 | + signalOnError(SdkClientException.create("File size changed after reading started. Initial size: " |
| 474 | + + sizeAtStart + ". Current size: " + sizeAtEnd)); |
474 | 475 | return false; |
475 | 476 | } |
476 | 477 |
|
477 | 478 | if (remainingBytes.get() > 0) { |
478 | | - signalOnError(new RuntimeException("Fewer bytes were read than were expected, was the file modified after " |
479 | | - + "reading started?")); |
| 479 | + signalOnError(SdkClientException.create("Fewer bytes were read than were expected, was the file modified " |
| 480 | + + "after reading started?")); |
480 | 481 | return false; |
481 | 482 | } |
482 | 483 |
|
483 | 484 | FileTime modifiedTimeAtEnd = Files.getLastModifiedTime(path); |
484 | 485 | if (modifiedTimeAtStart.compareTo(modifiedTimeAtEnd) != 0) { |
485 | | - signalOnError( |
486 | | - new RuntimeException("File last-modified time changed after reading started. Initial modification " |
487 | | - + "time: " + modifiedTimeAtStart + ". Current modification time: " + |
488 | | - modifiedTimeAtEnd)); |
| 486 | + signalOnError(SdkClientException.create("File last-modified time changed after reading started. " |
| 487 | + + "Initial modification time: " + modifiedTimeAtStart |
| 488 | + + ". Current modification time: " + modifiedTimeAtEnd)); |
489 | 489 | return false; |
490 | 490 | } |
491 | 491 | } catch (NoSuchFileException e) { |
492 | | - signalOnError(new IOException("Unable to check file status after read. Was the file deleted or were its " |
493 | | - + "permissions changed?", e)); |
| 492 | + signalOnError(SdkClientException.create("Unable to check file status after read. Was the file deleted" |
| 493 | + + " or were its permissions changed?", e)); |
494 | 494 | return false; |
495 | 495 | } catch (IOException e) { |
496 | | - signalOnError(new IOException("Unable to check file status after read.", e)); |
| 496 | + signalOnError(SdkClientException.create("Unable to check file status after read.", e)); |
497 | 497 | return false; |
498 | 498 | } |
499 | 499 | return true; |
|
0 commit comments