From 56ed305df446f9546a9db267a773d65d7c040d8e Mon Sep 17 00:00:00 2001 From: Jon Bratseth Date: Tue, 1 Sep 2020 11:22:19 +0200 Subject: Generate a Vtag class in vespa-http-client --- vespa-http-client/src/main/bin/versiontagger.sh | 24 ++++++++++++++++++++++ .../communication/ApacheGatewayConnection.java | 6 +++--- .../vespa/http/client/core/communication/Vtag.java | 7 ------- 3 files changed, 27 insertions(+), 10 deletions(-) create mode 100755 vespa-http-client/src/main/bin/versiontagger.sh delete mode 100644 vespa-http-client/src/main/java/com/yahoo/vespa/http/client/core/communication/Vtag.java (limited to 'vespa-http-client/src') diff --git a/vespa-http-client/src/main/bin/versiontagger.sh b/vespa-http-client/src/main/bin/versiontagger.sh new file mode 100755 index 00000000000..05682c3f940 --- /dev/null +++ b/vespa-http-client/src/main/bin/versiontagger.sh @@ -0,0 +1,24 @@ +#!/bin/bash +# Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +# Extracts the current version number (V_TAG_COMPONENT) from vtag.map and outputs this into a Java class. +# This replaces vespajlib/../VersionTagger.java as this module cannot depend on that, nor the dependencies +# of the resulting class. +# +# Author: bratseth + +source=$1 +destination=$2 +destinationDir=$(dirname $destination) + +mkdir -p $destinationDir + +versionNumber=$(cat $source | grep V_TAG_COMPONENT | awk '{print $2}' ) + +cat > $destination <<- END +package com.yahoo.vespa.http.client.core; + +public class Vtag { + public static final String V_TAG_COMPONENT = "$versionNumber"; +} +END diff --git a/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/core/communication/ApacheGatewayConnection.java b/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/core/communication/ApacheGatewayConnection.java index a46b2e67fe1..bd5cf761024 100644 --- a/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/core/communication/ApacheGatewayConnection.java +++ b/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/core/communication/ApacheGatewayConnection.java @@ -8,6 +8,7 @@ import com.yahoo.security.SslContextBuilder; import com.yahoo.vespa.http.client.config.ConnectionParams; import com.yahoo.vespa.http.client.config.Endpoint; import com.yahoo.vespa.http.client.config.FeedParams; +import com.yahoo.vespa.http.client.core.Vtag; import com.yahoo.vespa.http.client.core.Document; import com.yahoo.vespa.http.client.core.Encoder; import com.yahoo.vespa.http.client.core.Headers; @@ -16,7 +17,6 @@ import org.apache.http.Header; import org.apache.http.HttpHost; import org.apache.http.HttpResponse; import org.apache.http.StatusLine; -import org.apache.http.client.HttpClient; import org.apache.http.client.config.RequestConfig; import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.InputStreamEntity; @@ -427,8 +427,8 @@ class ApacheGatewayConnection implements GatewayConnection { } clientBuilder.setMaxConnPerRoute(1); clientBuilder.setMaxConnTotal(1); - clientBuilder.setUserAgent(String.format("vespa-http-client (%s)", Vtag.currentVersion)); - clientBuilder.setDefaultHeaders(Collections.singletonList(new BasicHeader(Headers.CLIENT_VERSION, Vtag.currentVersion))); + clientBuilder.setUserAgent(String.format("vespa-http-client (%s)", Vtag.V_TAG_COMPONENT)); + clientBuilder.setDefaultHeaders(Collections.singletonList(new BasicHeader(Headers.CLIENT_VERSION, Vtag.V_TAG_COMPONENT))); clientBuilder.disableContentCompression(); RequestConfig.Builder requestConfigBuilder = RequestConfig.custom(); requestConfigBuilder.setSocketTimeout(0); diff --git a/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/core/communication/Vtag.java b/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/core/communication/Vtag.java deleted file mode 100644 index f44a30208e7..00000000000 --- a/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/core/communication/Vtag.java +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - -package com.yahoo.vespa.http.client.core.communication; - -class Vtag { - static final String currentVersion = "7.1.0"; -} -- cgit v1.2.3