Skip to content

Commit

Permalink
fix: make ParallelCompositeUploadBlobWriteSessionConfig.ExecutorSuppl…
Browse files Browse the repository at this point in the history
…ier#cachedPool a singleton (#2691)
  • Loading branch information
BenWhitehead authored Aug 29, 2024
1 parent 3358f17 commit 1494809
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ private ExecutorSupplier() {}
*/
@BetaApi
public static ExecutorSupplier cachedPool() {
return new CachedSupplier();
return CachedSupplier.INSTANCE;
}

/**
Expand Down Expand Up @@ -529,12 +529,18 @@ private void writeObject(ObjectOutputStream out) throws IOException {

private static class CachedSupplier extends ExecutorSupplier implements Serializable {
private static final long serialVersionUID = 7768210719775319260L;
private static final CachedSupplier INSTANCE = new CachedSupplier();

@Override
Executor get() {
ThreadFactory threadFactory = newThreadFactory();
return Executors.newCachedThreadPool(threadFactory);
}

/** prevent java serialization from using a new instance */
private Object readResolve() {
return INSTANCE;
}
}

private static class FixedSupplier extends ExecutorSupplier implements Serializable {
Expand Down

0 comments on commit 1494809

Please sign in to comment.