Skip to content
This repository has been archived by the owner on Apr 1, 2019. It is now read-only.

Json Delete #24

Open
joskar opened this issue Feb 26, 2013 · 5 comments
Open

Json Delete #24

joskar opened this issue Feb 26, 2013 · 5 comments

Comments

@joskar
Copy link

joskar commented Feb 26, 2013

I am using Resty 0.3.2 on android
I am calling delete like this :
request.json("http://example.com:port/customer/4", delete());

here is the error , is my falut or Resty ?

02-26 00:10:56.736: W/System.err(1116): java.io.IOException: BufferedInputStream is closed
02-26 00:10:56.747: W/System.err(1116): at java.io.BufferedInputStream.streamClosed(BufferedInputStream.java:118)
02-26 00:10:56.747: W/System.err(1116): at java.io.BufferedInputStream.read(BufferedInputStream.java:279)
02-26 00:10:56.747: W/System.err(1116): at java.io.InputStream.read(InputStream.java:163)
02-26 00:10:56.747: W/System.err(1116): at us.monoid.web.AbstractResource.fill(AbstractResource.java:44)
02-26 00:10:56.757: W/System.err(1116): at us.monoid.web.Resty.fillResourceFromURL(Resty.java:432)
02-26 00:10:56.757: W/System.err(1116): at us.monoid.web.Resty.doPOSTOrPUT(Resty.java:394)
02-26 00:10:56.757: W/System.err(1116): at us.monoid.web.Resty.json(Resty.java:223)
02-26 00:10:56.757: W/System.err(1116): at us.monoid.web.Resty.json(Resty.java:228)
02-26 00:10:56.757: W/System.err(1116): at com.example.resttest.RestTasks.doRequest(RestTasks.java:57)
02-26 00:10:56.757: W/System.err(1116): at com.example.resttest.RestTasks.doInBackground(RestTasks.java:29)
02-26 00:10:56.757: W/System.err(1116): at com.example.resttest.RestTasks.doInBackground(RestTasks.java:1)
02-26 00:10:56.767: W/System.err(1116): at android.os.AsyncTask$2.call(AsyncTask.java:287)

02-26 00:10:56.767: W/System.err(1116): at java.util.concurrent.FutureTask.run(FutureTask.java:234)
02-26 00:10:56.767: W/System.err(1116): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
02-26 00:10:56.777: W/System.err(1116): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
02-26 00:10:56.777: W/System.err(1116): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
02-26 00:10:56.793: W/System.err(1116): at java.lang.Thread.run(Thread.java:856)

EDIT:
I am using all the others methods successful only the delete is creating this error

@jaredc
Copy link

jaredc commented Aug 2, 2013

I am getting the same error when I try to perform a DELETE via Resty. Following are the details of how I'm calling, in case they're helpful:

String requestUrl = "https://my.example.com/api/v1/timesheets?ids=135635398";
restyClient = new Resty();
JSONObject responseObj = restyClient.json(requestUrl, Resty.delete()).toObject();

An exception occured during request network execution :BufferedInputStream is closed
com.octo.android.robospice.persistence.exception.SpiceException: BufferedInputStream is closed
at com.example.android.robospice.exampleDebugSpiceRequest.loadDataFromNetwork(exampleDebugSpiceRequest.java:81)
at com.example.android.robospice.exampleDebugSpiceRequest.loadDataFromNetwork(exampleDebugSpiceRequest.java:18)
at com.octo.android.robospice.request.CachedSpiceRequest.loadDataFromNetwork(CachedSpiceRequest.java:27)
at com.octo.android.robospice.request.RequestProcessor.processRequest(RequestProcessor.java:247)
at com.octo.android.robospice.request.RequestProcessor$2.run(RequestProcessor.java:172)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:442)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
at java.util.concurrent.FutureTask.run(FutureTask.java:137)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
at java.lang.Thread.run(Thread.java:856)
Caused by: java.io.IOException: BufferedInputStream is closed
at com.example.android.api.exampleAPI.apiDelete(exampleAPI.java:255)
at com.example.android.robospice.exampleDebugSpiceRequest.loadDataFromNetwork(exampleDebugSpiceRequest.java:73)
... 10 more

@beders
Copy link
Owner

beders commented Aug 2, 2013

Hi Jared,
If there a stack trace that shows the Resty class/line number affected?
i.e. if toObject() would throw the exception I would expect to see that in the stack trace.

Thanks,
 Jochen


From: Jared Cheney [email protected]
To: beders/Resty [email protected]
Sent: Thursday, August 1, 2013 10:18 PM
Subject: Re: [Resty] Json Delete (#24)

I am getting the same error when I try to perform a DELETE via Resty. Following are the details of how I'm calling, in case they're helpful:
String requestUrl = "https://my.example.com/api/v1/timesheets?ids=135635398";
restyClient = new Resty();
JSONObject responseObj = restyClient.json(requestUrl, Resty.delete()).toObject();
An exception occured during request network execution :BufferedInputStream is closed
com.octo.android.robospice.persistence.exception.SpiceException: BufferedInputStream is closed
at com.example.android.robospice.exampleDebugSpiceRequest.loadDataFromNetwork(exampleDebugSpiceRequest.java:81)
at com.example.android.robospice.exampleDebugSpiceRequest.loadDataFromNetwork(exampleDebugSpiceRequest.java:18)
at com.octo.android.robospice.request.CachedSpiceRequest.loadDataFromNetwork(CachedSpiceRequest.java:27)
at com.octo.android.robospice.request.RequestProcessor.processRequest(RequestProcessor.java:247)
at com.octo.android.robospice.request.RequestProcessor$2.run(RequestProcessor.java:172)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:442)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
at java.util.concurrent.FutureTask.run(FutureTask.java:137)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
at java.lang.Thread.run(Thread.java:856)
Caused by: java.io.IOException: BufferedInputStream is closed
at com.example.android.api.exampleAPI.apiDelete(exampleAPI.java:255)
at com.example.android.robospice.exampleDebugSpiceRequest.loadDataFromNetwork(exampleDebugSpiceRequest.java:73)
... 10 more

Reply to this email directly or view it on GitHub.

@jaredc
Copy link

jaredc commented Aug 12, 2013

Hi Jochen,

I'm sorry for the slow response, we've been out of town. Here's the stack trace you requested.

08-12 07:17:56.975 17442-17814/com.myexample.android.hammerhead W/System.err: java.io.IOException: BufferedInputStream is closed
08-12 07:17:56.975 17442-17814/com.myexample.android.hammerhead W/System.err: at java.io.BufferedInputStream.streamClosed(BufferedInputStream.java:118)
08-12 07:17:56.975 17442-17814/com.myexample.android.hammerhead W/System.err: at java.io.BufferedInputStream.read(BufferedInputStream.java:279)
08-12 07:17:56.975 17442-17814/com.myexample.android.hammerhead W/System.err: at java.io.InputStream.read(InputStream.java:163)
08-12 07:17:56.975 17442-17814/com.myexample.android.hammerhead W/System.err: at us.monoid.web.AbstractResource.fill(AbstractResource.java:44)
08-12 07:17:56.975 17442-17814/com.myexample.android.hammerhead W/System.err: at us.monoid.web.Resty.fillResourceFromURL(Resty.java:432)
08-12 07:17:56.975 17442-17814/com.myexample.android.hammerhead W/System.err: at us.monoid.web.Resty.doPOSTOrPUT(Resty.java:394)
08-12 07:17:56.975 17442-17814/com.myexample.android.hammerhead W/System.err: at us.monoid.web.Resty.json(Resty.java:223)
08-12 07:17:56.975 17442-17814/com.myexample.android.hammerhead W/System.err: at us.monoid.web.Resty.json(Resty.java:228)
08-12 07:17:56.975 17442-17814/com.myexample.android.hammerhead W/System.err: at com.myexample.android.api.MyExampleAPI.apiDelete(MyExampleAPI.java:251)
08-12 07:17:56.975 17442-17814/com.myexample.android.hammerhead W/System.err: at com.myexample.android.api.MyExampleAPISyncEngine.syncUpEndPoint(MyExampleAPISyncEngine.java:228)
08-12 07:17:56.975 17442-17814/com.myexample.android.hammerhead W/System.err: at com.myexample.android.api.MyExampleAPISyncEngine.syncUp(MyExampleAPISyncEngine.java:910)
08-12 07:17:56.975 17442-17814/com.myexample.android.hammerhead W/System.err: at com.myexample.android.api.MyExampleSyncService$1.run(MyExampleSyncService.java:108)
08-12 07:17:56.975 17442-17814/com.myexample.android.hammerhead W/System.err: at java.lang.Thread.run(Thread.java:856)

I'm calling it like this in our API class:

JSONObject responseObj = restyClient.json(requestUrl, Resty.delete()).toObject();

Let me know if it would be helpful to have an actual url to test against, and I can send you the info needed to do that.

Thank you,
Jared

@zepernick
Copy link

I encountered this same error on a put. Here is the code that is causing the error

new Resty() .text(url + "/ViewingSession/" + getViewSessionId() + "/SourceFile?FileExtension=" + extension, Resty.put( Resty.content( IOUtils.toByteArray(new FileInputStream(documentFile)) ) ) );

The same error happens whether it is using json, text, or bytes. The relevant piece of the stack trace is below.

java.io.IOException: Stream closed at java.io.BufferedInputStream.getInIfOpen(BufferedInputStream.java:151) at java.io.BufferedInputStream.fill(BufferedInputStream.java:235) at java.io.BufferedInputStream.read1(BufferedInputStream.java:275) at java.io.BufferedInputStream.read(BufferedInputStream.java:334) at java.io.FilterInputStream.read(FilterInputStream.java:107) at us.monoid.web.AbstractResource.fill(AbstractResource.java:44) at us.monoid.web.Resty.fillResourceFromURL(Resty.java:432) at us.monoid.web.Resty.doPOSTOrPUT(Resty.java:394) at us.monoid.web.Resty.bytes(Resty.java:383) at us.monoid.web.Resty.bytes(Resty.java:371) at com.iws.actions.document.master.MasterDocumentPopulateAction.doPopulate(MasterDocumentPopulateAction.java:87)

The response being sent back from the service is empty per the documentation for the service. I am guessing that may have something to do with it.

@zepernick
Copy link

This looks like it has been corrected in the current master branch. There was a error happening when reading the error stream in. There is a try / catch there now that ignores the error and writes a warn to the log.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants