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

rename folder causes BoxAPIException #126

Closed
joh-mue opened this issue May 27, 2015 · 4 comments
Closed

rename folder causes BoxAPIException #126

joh-mue opened this issue May 27, 2015 · 4 comments
Labels
bug Added to issues that describes SDK bug

Comments

@joh-mue
Copy link

joh-mue commented May 27, 2015

The following code will raise a BoxAPIException everytime it is executed. The renaming goes through but the Exception is thrown.

[BoxAPIException: Couldn't finish closing the connection to the Box API due to a network error or because the stream was already closed.]

This is my code

public static void renameFolder(String developerToken, String folderID, String name) {
    BoxAPIConnection connection = new BoxAPIConnection(developerToken);
    BoxFolder folder = new BoxFolder(connection, folderID);
    folder.rename(name);
}    

Am I stupid or is there maybe something wrong here?

@gcurtis
Copy link
Contributor

gcurtis commented Jun 2, 2015

Hi @joh-mue, sorry for the delayed response. What you're doing looks correct.

Can you paste the full stack trace including the inner exception? Which version of the SDK are you using?

@joh-mue
Copy link
Author

joh-mue commented Jun 17, 2015

Well, now it took me a very long time. Here's what I get:

[info] play - database [default] connected at jdbc:h2:mem:play
[info] play - Application started (Dev)
[error] play - Cannot invoke the action, eventually got an error: com.box.sdk.BoxAPIException: Couldn't finish closing the connection to the Box API due to a network error or because the stream was already closed.
[error] application - 

! @6mfmm8iaj - Internal server error, for (POST) [/folders/3789310186/rename] ->

play.api.Application$$anon$1: Execution exception[[BoxAPIException: Couldn't finish closing the connection to the Box API due to a network error or because the stream was already closed.]]
    at play.api.Application$class.handleError(Application.scala:296) ~[play_2.11-2.3.9.jar:2.3.9]
    at play.api.DefaultApplication.handleError(Application.scala:402) [play_2.11-2.3.9.jar:2.3.9]
    at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$3$$anonfun$applyOrElse$4.apply(PlayDefaultUpstreamHandler.scala:320) [play_2.11-2.3.9.jar:2.3.9]
    at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$3$$anonfun$applyOrElse$4.apply(PlayDefaultUpstreamHandler.scala:320) [play_2.11-2.3.9.jar:2.3.9]
    at scala.Option.map(Option.scala:146) [scala-library-2.11.6.jar:na]
Caused by: com.box.sdk.BoxAPIException: Couldn't finish closing the connection to the Box API due to a network error or because the stream was already closed.
    at com.box.sdk.BoxAPIResponse.disconnect(BoxAPIResponse.java:159) ~[box-java-sdk-1.0.0.jar:na]
    at com.box.sdk.BoxFolder.rename(BoxFolder.java:285) ~[box-java-sdk-1.0.0.jar:na]
    at box.com.ApiJava.renameFolder(ApiJava.java:89) ~[classes/:na]
    at controllers.Application$$anonfun$renameFolder$1$$anonfun$apply$4.apply(Application.scala:49) ~[classes/:na]
    at controllers.Application$$anonfun$renameFolder$1$$anonfun$apply$4.apply(Application.scala:42) ~[classes/:na]
Caused by: java.io.IOException: stream is closed
    at sun.net.www.protocol.http.HttpURLConnection$HttpInputStream.ensureOpen(HttpURLConnection.java:3295) ~[na:1.8.0_25]
    at sun.net.www.protocol.http.HttpURLConnection$HttpInputStream.read(HttpURLConnection.java:3320) ~[na:1.8.0_25]
    at sun.net.www.protocol.http.HttpURLConnection$HttpInputStream.read(HttpURLConnection.java:3315) ~[na:1.8.0_25]
    at com.box.sdk.BoxAPIResponse.disconnect(BoxAPIResponse.java:149) ~[box-java-sdk-1.0.0.jar:na]
    at com.box.sdk.BoxFolder.rename(BoxFolder.java:285) ~[box-java-sdk-1.0.0.jar:na]

the box-java-sdk version is 1.0.0

Thank you for your help!

@tarrencev tarrencev added the bug Added to issues that describes SDK bug label Jun 8, 2016
@gcurtis
Copy link
Contributor

gcurtis commented Nov 8, 2016

Hi @joh-mue, are you still running into this issue? If so, please reopen this ticket.

So far I've been unable to reproduce it, but it definitely looks like some other code is closing the HttpUrlConnection before BoxAPIResponse.disconnect() is called. Is it possible that there's any other code in your program that could be doing this? It may also just be happening if the network connection is interrupted.

@gcurtis gcurtis closed this as completed Nov 8, 2016
@abhijry
Copy link

abhijry commented Nov 13, 2017

I am using the box java sdk 2.8.2 to move some folders around as a part of automation.

A call to public BoxFolder.Info moveFolderToUser​(String sourceUserID) throws the following exception . The move happens succesfully but the BoxFolder.Info object returned is null. Looks like a similar issue

com.box.sdk.BoxAPIException: Couldn't finish closing the connection to the Box API due to a network error or because the stream was already closed.
at com.box.sdk.BoxAPIResponse.disconnect(BoxAPIResponse.java:192)
at com.box.sdk.BoxUser.moveFolderToUser(BoxUser.java:445)
at com..box.BoxTermProcessAutomation.moveTerminatedUserFolders(BoxTermProcessAutomation.java:430)
at com..box.BoxTermProcessAutomation.main(BoxTermProcessAutomation.java:59)
Caused by: java.io.IOException: stream is closed
at sun.net.www.protocol.http.HttpURLConnection$HttpInputStream.ensureOpen(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection$HttpInputStream.read(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection$HttpInputStream.read(Unknown Source)
at com.box.sdk.BoxAPIResponse.disconnect(BoxAPIResponse.java:182)
... 3 more

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Added to issues that describes SDK bug
Projects
None yet
Development

No branches or pull requests

4 participants