jaxrs: add workaround for
When bulk-creating very large number of subscriptions, redirect the client
to the account bundles endpoint, without an arbitrarily long list of bundleIds
in the bundlesFilter.
@@ -400,7 +400,7 @@ public class SubscriptionResource extends JaxRsResourceBase {
}
if (responseObject == ObjectType.ACCOUNT) {
- return uriBuilder.buildResponse(uriInfo, AccountResource.class, "getAccountBundles", account.getId(), buildQueryParams(bundleIds), request);
+ return uriBuilder.buildResponse(uriInfo, AccountResource.class, "getAccountBundles", account.getId(), buildBundlesFilterQueryParam(bundleIds), request);
} else if (responseObject == ObjectType.BUNDLE) {
return uriBuilder.buildResponse(uriInfo, BundleResource.class, "getBundle", Iterables.getFirst(bundleIds, null), request);
} else {
@@ -412,11 +412,19 @@ public class SubscriptionResource extends JaxRsResourceBase {
return callCompletionCreation.withSynchronization(callback, timeoutSec, callCompletion, callContext);
}
- private Map<String, String> buildQueryParams(final Iterable<String> bundleIdList) {
- Map<String, String> queryParams = new HashMap<String, String>();
+ private Map<String, String> buildBundlesFilterQueryParam(final Collection<String> bundleIdList) {
+ final Map<String, String> queryParams = new HashMap<String, String>();
+
+ // Workaround for https://github.com/killbill/killbill/issues/1336
+ // While we could tweak the container to support large number of bundles in the filter (e.g. Jetty's RequestBufferSize),
+ // the full list is probably not that useful for the client in practice.
+ if (bundleIdList.size() > 50) {
+ return queryParams;
+ }
+
String value = "";
- for (String bundleId : bundleIdList) {
- if (value.equals("")) {
+ for (final String bundleId : bundleIdList) {
+ if ("".equals(value)) {
value += bundleId;
} else {
value += "," + bundleId;
