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

service load only once #158

Merged
merged 2 commits into from
Jan 28, 2020
Merged

service load only once #158

merged 2 commits into from
Jan 28, 2020

Conversation

dansanduleac
Copy link
Contributor

Before this PR

spotless is service loading the implementation once per gradle project, even though it's guaranteed to be the same for the entire gradle build.

This leads to some people's gradles dying by exceeding MaxMetaspaceSize.

After this PR

==COMMIT_MSG==
Only service load the formatter implementation once.
==COMMIT_MSG==

Possible downsides?

@changelog-app
Copy link

changelog-app bot commented Jan 28, 2020

Generate changelog in changelog/@unreleased

Type

  • Feature
  • Improvement
  • Fix
  • Break
  • Deprecation
  • Manual task
  • Migration

Description

Only service load the formatter implementation once, rather than once per gradle project. This avoids gradle potentially exceedding the MaxMetaspaceSize and throwing java.lang.OutOfMemoryError: Metaspace.

Check the box to generate changelog(s)

  • Generate changelog entry

import com.google.common.collect.Iterables;
import com.palantir.javaformat.java.FormatterService;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ServiceLoader;
import java.util.function.Supplier;
import org.gradle.api.artifacts.Configuration;

public class JavaFormatExtension {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 confirmed this is only registered by the PalantirJavaFormatProvider plugin, which only works on the root project:

        Preconditions.checkState(
                rootProject == rootProject.getRootProject(),
                "May only apply com.palantir.java-format-provider to the root project");

@bulldozer-bot bulldozer-bot bot merged commit b93f4f3 into develop Jan 28, 2020
@bulldozer-bot bulldozer-bot bot deleted the ds/load-once branch January 28, 2020 18:38
@svc-autorelease
Copy link
Collaborator

Released 0.3.18

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants