Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: make ParallelCompositeUploadBlobWriteSessionConfig.ExecutorSupplier#cachedPool a singleton #2691

Merged
merged 1 commit into from
Aug 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading