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

[Android] make volley socket timeout configurable #3646

Merged
merged 2 commits into from
Aug 29, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
package {{invokerPackage}};

import com.android.volley.Cache;
import com.android.volley.DefaultRetryPolicy;
import com.android.volley.Network;
import com.android.volley.Request;
import com.android.volley.RequestQueue;
Expand Down Expand Up @@ -486,7 +487,12 @@ public class ApiInvoker {
} else {
request = new PatchRequest(url, headers, null, null, stringRequest, errorListener);
}
}
}

if (request != null) {
request.setRetryPolicy(new DefaultRetryPolicy((int)TimeUnit.SECONDS.toMillis(this.connectionTimeout), DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
}

return request;
}

Expand Down
12 changes: 6 additions & 6 deletions samples/client/petstore/android/volley/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,6 @@ Class | Method | HTTP request | Description
## Documentation for Authorization

Authentication schemes defined for the API:
### api_key

- **Type**: API key
- **API key parameter name**: api_key
- **Location**: HTTP header

### petstore_auth

- **Type**: OAuth
Expand All @@ -131,6 +125,12 @@ Authentication schemes defined for the API:
- write:pets: modify pets in your account
- read:pets: read your pets

### api_key

- **Type**: API key
- **API key parameter name**: api_key
- **Location**: HTTP header


## Recommendation

Expand Down
4 changes: 2 additions & 2 deletions samples/client/petstore/android/volley/docs/PetApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ try {

Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**status** | [**List<String>**](String.md)| Status values that need to be considered for filter | [optional] [default to available]
**status** | [**List<String>**](String.md)| Status values that need to be considered for filter | [optional] [default to available] [enum: available, pending, sold]

### Return type

Expand Down Expand Up @@ -222,7 +222,7 @@ Name | Type | Description | Notes

### Authorization

[api_key](../README.md#api_key), [petstore_auth](../README.md#petstore_auth)
[petstore_auth](../README.md#petstore_auth), [api_key](../README.md#api_key)

### HTTP request headers

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
package io.swagger.client;

import com.android.volley.Cache;
import com.android.volley.DefaultRetryPolicy;
import com.android.volley.Network;
import com.android.volley.Request;
import com.android.volley.RequestQueue;
Expand Down Expand Up @@ -213,9 +214,9 @@ public static void initializeInstance(Cache cache, Network network, int threadPo

// Setup authentications (key: authentication name, value: authentication).
INSTANCE.authentications = new HashMap<String, Authentication>();
INSTANCE.authentications.put("api_key", new ApiKeyAuth("header", "api_key"));
// TODO: comment out below as OAuth does not exist
//INSTANCE.authentications.put("petstore_auth", new OAuth());
INSTANCE.authentications.put("api_key", new ApiKeyAuth("header", "api_key"));
// Prevent the authentications from being modified.
INSTANCE.authentications = Collections.unmodifiableMap(INSTANCE.authentications);
}
Expand Down Expand Up @@ -500,7 +501,12 @@ else if ("PATCH".equals(method)) {
} else {
request = new PatchRequest(url, headers, null, null, stringRequest, errorListener);
}
}
}

if (request != null) {
request.setRetryPolicy(new DefaultRetryPolicy((int)TimeUnit.SECONDS.toMillis(this.connectionTimeout), DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
}

return request;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ public Pet getPetById (Long petId) throws TimeoutException, ExecutionException,
// normal form params
}

String[] authNames = new String[] { "api_key", "petstore_auth" };
String[] authNames = new String[] { "petstore_auth", "api_key" };

try {
String localVarResponse = apiInvoker.invokeAPI (basePath, path, "GET", queryParams, postBody, headerParams, formParams, contentType, authNames);
Expand Down Expand Up @@ -693,7 +693,7 @@ public void getPetById (Long petId, final Response.Listener<Pet> responseListene
// normal form params
}

String[] authNames = new String[] { "api_key", "petstore_auth" };
String[] authNames = new String[] { "petstore_auth", "api_key" };

try {
apiInvoker.invokeAPI(basePath, path, "GET", queryParams, postBody, headerParams, formParams, contentType, authNames,
Expand Down