|
40 | 40 | import com.google.common.collect.ImmutableMap;
|
41 | 41 | import com.google.common.collect.ImmutableSet;
|
42 | 42 | import java.io.ByteArrayInputStream;
|
| 43 | +import java.io.ByteArrayOutputStream; |
43 | 44 | import java.io.IOException;
|
44 | 45 | import java.io.InputStream;
|
45 | 46 | import java.io.ObjectInputStream;
|
| 47 | +import java.io.ObjectOutputStream; |
46 | 48 | import java.io.Serializable;
|
47 | 49 | import java.util.Base64;
|
48 | 50 | import java.util.Collections;
|
@@ -213,6 +215,29 @@ protected Serializable[] serializableObjects() {
|
213 | 215 | }
|
214 | 216 | }
|
215 | 217 |
|
| 218 | + @Test |
| 219 | + public void avoidNpeHttpStorageOptions_retryDeps() throws IOException, ClassNotFoundException { |
| 220 | + HttpStorageOptions optionsHttp1 = |
| 221 | + StorageOptions.http() |
| 222 | + .setProjectId("http1") |
| 223 | + .setCredentials(NoCredentials.getInstance()) |
| 224 | + .build(); |
| 225 | + |
| 226 | + assertThat(optionsHttp1.asRetryDependencies()).isNotNull(); |
| 227 | + |
| 228 | + ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
| 229 | + try (ObjectOutputStream oos = new ObjectOutputStream(baos)) { |
| 230 | + oos.writeObject(optionsHttp1); |
| 231 | + } |
| 232 | + |
| 233 | + byte[] byteArray = baos.toByteArray(); |
| 234 | + try (ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(byteArray))) { |
| 235 | + Object o = ois.readObject(); |
| 236 | + HttpStorageOptions hso = (HttpStorageOptions) o; |
| 237 | + assertThat(hso.asRetryDependencies()).isNotNull(); |
| 238 | + } |
| 239 | + } |
| 240 | + |
216 | 241 | @Override
|
217 | 242 | @SuppressWarnings("resource")
|
218 | 243 | protected Restorable<?>[] restorableObjects() {
|
|
0 commit comments