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

Tappx changes - Backward compatible change of version #1222

Merged
merged 2 commits into from
Apr 21, 2021

Conversation

RodionOrets
Copy link
Contributor

@RodionOrets RodionOrets commented Apr 12, 2021

@RodionOrets RodionOrets force-pushed the bump-tappx-version-to-1.2 branch 2 times, most recently from 0d30cb3 to a691967 Compare April 14, 2021 01:32
Comment on lines 110 to 122
String url = endpointUrl + host;
if (!host.contains(endpoint)) {
url += "/" + endpoint;
}
url += "?tappxkey=" + tappxkey;

Copy link
Collaborator

Choose a reason for hiding this comment

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

We have many concatenations in this method, can we use StringBuilder?

Copy link
Contributor Author

@RodionOrets RodionOrets Apr 14, 2021

Choose a reason for hiding this comment

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

@snahornyi Sure, but that would look somewhere like this:

...
StringBuilder urlBuilder = new StringBuilder()
                .append(endpointUrl)
                .append(host);

        if (!host.contains(endpoint)) {
            urlBuilder.append("/").append(endpoint);
        }

        urlBuilder.append("?tappxkey=").append(tappxkey);

        if (test != null && test == 0) {
            int t = (int) System.nanoTime();
            urlBuilder.append("&ts").append(t);
        }

        urlBuilder
                .append("&v=").append(VERSION)
                .append("&type_cnn=").append(TYPE_CNN);

        String url = urlBuilder.toString();
        try {
            HttpUtil.validateUrl(url);
        } catch (IllegalArgumentException e) {
            throw new PreBidException("Not valid url: " + url, e);
        }

        return url;
...

Which I think is less cleaner than "old" approach with url += ...
I'm trying to say it is not required here - we're not concatenating strings in a loop or something.
Since it's a simple concatenation, Java compiler will do the trick for us. At least for now I don't see any problem with += approach.
If not - let me know :)

@RodionOrets RodionOrets force-pushed the bump-tappx-version-to-1.2 branch 2 times, most recently from db94d78 to e7da501 Compare April 16, 2021 08:47
@RodionOrets RodionOrets force-pushed the bump-tappx-version-to-1.2 branch from e7da501 to 545c3c0 Compare April 19, 2021 11:16
uriBuilder.addParameter("type_cnn", TYPE_CNN);
return uriBuilder.build().toString();
} catch (URISyntaxException e) {
throw new PreBidException("Built invalid URL: ", e);
Copy link
Collaborator

Choose a reason for hiding this comment

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

throw new PreBidException(String.format("Failed to build endpoint URL: %s", e.getMessage()));

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done


private String buildUrl(String endpointUrl, String host, String endpoint, String tappxkey, Integer test) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

can be static

Copy link
Contributor Author

Choose a reason for hiding this comment

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

And will be

Comment on lines 130 to 131
uriBuilder.addParameter("v", VERSION);
uriBuilder.addParameter("type_cnn", TYPE_CNN);
Copy link
Collaborator

Choose a reason for hiding this comment

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

lets put all parameters creating together

uriBuilder.addParameter("tappxkey", tappxkey);
uriBuilder.addParameter("v", VERSION);
uriBuilder.addParameter("type_cnn", TYPE_CNN);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@RodionOrets RodionOrets force-pushed the bump-tappx-version-to-1.2 branch from 545c3c0 to c6584fa Compare April 19, 2021 11:37
uriBuilder.addParameter("type_cnn", TYPE_CNN);

if (test != null && test == 0) {
int t = (int) System.nanoTime();
Copy link
Contributor

Choose a reason for hiding this comment

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

Pls give reasonable names to variables.

@rpanchyk rpanchyk merged commit 909af56 into master Apr 21, 2021
@rpanchyk rpanchyk deleted the bump-tappx-version-to-1.2 branch April 21, 2021 07:03
@bretg bretg mentioned this pull request May 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants