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

Utility to safely build URLs #346

Merged
merged 4 commits into from
Feb 24, 2020
Merged

Utility to safely build URLs #346

merged 4 commits into from
Feb 24, 2020

Conversation

carterkozak
Copy link
Contributor

Deduplicate client code, and isolate unsafety around UrlBuilder
mutability.

After this PR

==COMMIT_MSG==
Utility to safely build URLs
==COMMIT_MSG==

@changelog-app
Copy link

changelog-app bot commented Feb 17, 2020

Generate changelog in changelog/@unreleased

Type

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

Description

Utility to safely build URLs

Check the box to generate changelog(s)

  • Generate changelog entry

import com.palantir.dialogue.UrlBuilder;
import java.net.URL;

/** Convenience utility around {@link UrlBuilder}. */
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not add the render method to UrlBuilder?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I’m worried about introducing bugs that mutate the urlBuilder state

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Method on the builder is probably fine but it adds logic to the generator target rather than the runtime, and we still risk mutation

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure...it just seems strange to fully encapsulate one utility class inside another. After this change UrlBuilder wouldn't need to be public, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The generated Endpoint objects have a method that consumes a UrlBuilder. I think that object should become an interface to further reduce logic in the generator target API, but that can occur separately.

Deduplicate client code, and isolate unsafety around UrlBuilder
mutability.
Copy link
Contributor

@ferozco ferozco left a comment

Choose a reason for hiding this comment

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

👍 Changing UrlBuilder from a class to interface is an ABI break but it shouldn't be an issue. Now might be the right time to make any breaks that require changes to the codegen

@carterkozak
Copy link
Contributor Author

👍 policy bot?

@carterkozak
Copy link
Contributor Author

🤖

@ferozco
Copy link
Contributor

ferozco commented Feb 24, 2020

👍

@bulldozer-bot bulldozer-bot bot merged commit 615a49e into develop Feb 24, 2020
@bulldozer-bot bulldozer-bot bot deleted the ckozak/base_url branch February 24, 2020 21:15
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