@Test public void createCompositeException_withMultipleInnerExceptions() { IOException inner1 = new IOException("inner exception 1"); IOException inner2 = new IOException("inner exception 2"); IOException compositeException = createCompositeException(ImmutableList.of(inner1, inner2)); assertThat(inner1).isNotSameInstanceAs(compositeException); assertThat(inner2).isNotSameInstanceAs(compositeException); assertThat(compositeException).hasMessageThat().isEqualTo("Multiple IOExceptions."); assertThat(compositeException.getSuppressed()).isEqualTo(new Throwable[] {inner1, inner2}); assertThat(compositeException.getSuppressed()[0]).isSameInstanceAs(inner1); assertThat(compositeException.getSuppressed()[1]).isSameInstanceAs(inner2); }
public static IOException createCompositeException(Collection<IOException> innerExceptions) { checkArgument( innerExceptions != null && !innerExceptions.isEmpty(), "innerExceptions (%s) must be not null and contain at least one element", innerExceptions); Iterator<IOException> innerExceptionIterator = innerExceptions.iterator(); if (innerExceptions.size() == 1) { return innerExceptionIterator.next(); } IOException combined = new IOException("Multiple IOExceptions."); while (innerExceptionIterator.hasNext()) { combined.addSuppressed(innerExceptionIterator.next()); } return combined; }
GoogleCloudStorageExceptions { public static IOException createCompositeException(Collection<IOException> innerExceptions) { checkArgument( innerExceptions != null && !innerExceptions.isEmpty(), "innerExceptions (%s) must be not null and contain at least one element", innerExceptions); Iterator<IOException> innerExceptionIterator = innerExceptions.iterator(); if (innerExceptions.size() == 1) { return innerExceptionIterator.next(); } IOException combined = new IOException("Multiple IOExceptions."); while (innerExceptionIterator.hasNext()) { combined.addSuppressed(innerExceptionIterator.next()); } return combined; } }
GoogleCloudStorageExceptions { public static IOException createCompositeException(Collection<IOException> innerExceptions) { checkArgument( innerExceptions != null && !innerExceptions.isEmpty(), "innerExceptions (%s) must be not null and contain at least one element", innerExceptions); Iterator<IOException> innerExceptionIterator = innerExceptions.iterator(); if (innerExceptions.size() == 1) { return innerExceptionIterator.next(); } IOException combined = new IOException("Multiple IOExceptions."); while (innerExceptionIterator.hasNext()) { combined.addSuppressed(innerExceptionIterator.next()); } return combined; } private  GoogleCloudStorageExceptions(); }
GoogleCloudStorageExceptions { public static IOException createCompositeException(Collection<IOException> innerExceptions) { checkArgument( innerExceptions != null && !innerExceptions.isEmpty(), "innerExceptions (%s) must be not null and contain at least one element", innerExceptions); Iterator<IOException> innerExceptionIterator = innerExceptions.iterator(); if (innerExceptions.size() == 1) { return innerExceptionIterator.next(); } IOException combined = new IOException("Multiple IOExceptions."); while (innerExceptionIterator.hasNext()) { combined.addSuppressed(innerExceptionIterator.next()); } return combined; } private  GoogleCloudStorageExceptions(); static FileNotFoundException createFileNotFoundException(
      String bucketName, String objectName, @Nullable IOException cause); static FileNotFoundException createFileNotFoundException(
      StorageResourceId resourceId, @Nullable IOException cause); static IOException createCompositeException(Collection<IOException> innerExceptions); static GoogleJsonResponseException createJsonResponseException(
      GoogleJsonError e, HttpHeaders responseHeaders); }
GoogleCloudStorageExceptions { public static IOException createCompositeException(Collection<IOException> innerExceptions) { checkArgument( innerExceptions != null && !innerExceptions.isEmpty(), "innerExceptions (%s) must be not null and contain at least one element", innerExceptions); Iterator<IOException> innerExceptionIterator = innerExceptions.iterator(); if (innerExceptions.size() == 1) { return innerExceptionIterator.next(); } IOException combined = new IOException("Multiple IOExceptions."); while (innerExceptionIterator.hasNext()) { combined.addSuppressed(innerExceptionIterator.next()); } return combined; } private  GoogleCloudStorageExceptions(); static FileNotFoundException createFileNotFoundException(
      String bucketName, String objectName, @Nullable IOException cause); static FileNotFoundException createFileNotFoundException(
      StorageResourceId resourceId, @Nullable IOException cause); static IOException createCompositeException(Collection<IOException> innerExceptions); static GoogleJsonResponseException createJsonResponseException(
      GoogleJsonError e, HttpHeaders responseHeaders);  }