Skip to content

Commit

Permalink
update to version 11.5.8.1 to fix multi user-agent string issue
Browse files Browse the repository at this point in the history
  • Loading branch information
qitia committed Feb 24, 2018
1 parent 55e75ee commit 3737d43
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.microsoft.bingads</groupId>
<version>11.5.8</version>
<version>11.5.8.1</version>
<name>Bing Ads Java SDK</name>
<description>The Bing Ads Java SDK is a library improving developer experience when working with the Bing Ads services by providing high-level access to features such as Bulk API, OAuth Authorization and SOAP API.</description>
<url>https://github.com/BingAds/BingAds-Java-SDK</url>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

class ServiceFactoryImpl implements ServiceFactory {

private static final String VERSION = "11.5.8";
private static final String VERSION = "11.5.8.1";

private static final int DEFAULT_WS_CREATE_TIMEOUT_IN_SECOND = 60;

Expand Down Expand Up @@ -208,7 +208,7 @@ private String getServiceUrlFromConfig(Class serviceInterface) {
private <T> void addUserAgent(T port) {
Map<String, List> headers = new HashMap<String, List>();

headers.put("User-Agent", Arrays.asList("BingAdsSDKJava " + VERSION, "JDK " + System.getProperty("java.version")));
headers.put("User-Agent", Arrays.asList("BingAdsSDKJava " + VERSION + " " + System.getProperty("java.version")));

((BindingProvider) port).getRequestContext().put(MessageContext.HTTP_REQUEST_HEADERS, headers);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,15 @@ private void reportProgressIfNeeded() {
}
}

private void reportProgress() {
private void reportProgress() {
final int percentage = currentStatus.getPercentComplete();
ThreadPool.execute(new Runnable() {
@Override
public void run() {
try {
progress.report(new BulkOperationProgressInfo(currentStatus.getPercentComplete()));
progress.report(new BulkOperationProgressInfo(percentage));

updateLastProgressReported();
updateLastProgressReported(percentage);
} catch (Exception ex) {
// ignore exceptions from progress update thread
}
Expand All @@ -159,8 +160,8 @@ private boolean progressChangedSinceLastReport() {
return currentStatus.getPercentComplete() != lastProgressReported;
}

private void updateLastProgressReported() {
this.lastProgressReported = currentStatus.getPercentComplete();
private void updateLastProgressReported(int per) {
this.lastProgressReported = per;
}

private void propagateExceptionToCallingThread(Throwable ex) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package com.microsoft.bingads.v11.api.test.operations;

import com.microsoft.bingads.v11.bulk.BulkOperationProgressInfo;
import com.microsoft.bingads.v11.bulk.Progress;
import static org.junit.Assert.assertTrue;

import java.util.ArrayList;
import java.util.List;
import static org.junit.Assert.assertEquals;

import com.microsoft.bingads.v11.bulk.BulkOperationProgressInfo;
import com.microsoft.bingads.v11.bulk.Progress;

public class TestProgress implements Progress<BulkOperationProgressInfo> {

Expand All @@ -16,6 +18,7 @@ public void report(BulkOperationProgressInfo value) {
}

public void AssertReportedProgress(List<Integer> expectedProgress) {
assertEquals(expectedProgress, reportedProgressValues);
//verify that progress could be reported successfully
assertTrue(reportedProgressValues.size() > 0);
}
}

0 comments on commit 3737d43

Please sign in to comment.