Removing all leaks on Android

This commit is contained in:
Francesco Chicchiriccò 2014-07-13 07:56:24 +02:00
parent c3a709309e
commit f1f6491a56
4 changed files with 32 additions and 6 deletions

View File

@ -49,10 +49,6 @@ public abstract class AbstractODataBatchRequest<V extends ODataResponse, T exten
*/
protected final List<ODataBatchResponseItem> expectedResItems = new ArrayList<ODataBatchResponseItem>();
protected void addExpectedResItem(ODataBatchResponseItem item) {
expectedResItems.add(item);
}
/**
* Constructor.
*
@ -69,6 +65,10 @@ public abstract class AbstractODataBatchRequest<V extends ODataResponse, T exten
setContentType(ContentType.MULTIPART_MIXED + ";" + ODataBatchConstants.BOUNDARY + "=" + boundary);
}
protected void addExpectedResItem(final ODataBatchResponseItem item) {
expectedResItems.add(item);
}
/**
* {@inheritDoc }
*/
@ -78,11 +78,11 @@ public abstract class AbstractODataBatchRequest<V extends ODataResponse, T exten
/**
* {@inheritDoc}
* <p>
* <br/>
* This operation is unsupported by a batch request.
*/
@Override
public void batch(CommonODataBatchRequest req) {
public void batch(final CommonODataBatchRequest req) {
throw new UnsupportedOperationException("A batch request is not batchable");
}
}

View File

@ -83,4 +83,13 @@ public class ODataSingleResponseItem extends AbstractODataBatchResponseItem {
public void remove() {
throw new UnsupportedOperationException("Operation not supported.");
}
@Override
public void close() {
super.close();
if (current != null && !(current instanceof AsyncResponseImpl) && !(current instanceof ODataBatchErrorResponse)) {
current.close();
}
}
}

View File

@ -121,5 +121,13 @@ public class ODataBatchRequestImpl
public Iterator<ODataBatchResponseItem> getBody() {
return new ODataBatchResponseManager(this, expectedResItems);
}
@Override
public void close() {
for (ODataBatchResponseItem resItem : expectedResItems) {
resItem.close();
}
super.close();
}
}
}

View File

@ -124,5 +124,14 @@ public class ODataBatchRequestImpl
public Iterator<ODataBatchResponseItem> getBody() {
return new ODataBatchResponseManager(this, expectedResItems, continueOnError);
}
@Override
public void close() {
for (ODataBatchResponseItem resItem : expectedResItems) {
resItem.close();
}
super.close();
}
}
}