2

我遇到了一个奇怪的问题,但使用 DropBox 是我上周没有遇到的。我创建了一个简单的 Java 控制台应用程序来从 DropBox 中提取文件然后在本地存储,这可以正常工作,但由于某种原因它现在失败了。正在从文件中读取 AccessToken 和 UserID。

MyDBAccessToken = params.get(0);
MyDBUserID      = params.get(1);
MyDBUrlState    = null;

DbxAuthFinish authToken  = new DbxAuthFinish(MyDBAccessToken, MyDBUserID, MyDBUrlState);
DbxRequestConfig config  = new DbxRequestConfig( "JavaTutorial/1.0", Locale.getDefault().toString());
DbxClient MyDBClient     = new DbxClient(config, authToken.accessToken);
System.out.println("Linked to DropBox account: " + MyDBClient.getAccountInfo().displayName + " ID " + MyDBClient.getAccountInfo().userId);

这是我的堆栈跟踪

Exception in thread "main" java.lang.AssertionError: bad index: -1, field = "datastores"
at com.dropbox.core.DbxAccountInfo$Quota$1.read(DbxAccountInfo.java:91)
at com.dropbox.core.DbxAccountInfo$Quota$1.read(DbxAccountInfo.java:66)
at com.dropbox.core.json.JsonReader.readField(JsonReader.java:26)
at com.dropbox.core.DbxAccountInfo$1.read(DbxAccountInfo.java:152)
at com.dropbox.core.DbxAccountInfo$1.read(DbxAccountInfo.java:128)
at com.dropbox.core.json.JsonReader.readFully(JsonReader.java:349)
at com.dropbox.core.json.JsonReader.readFully(JsonReader.java:238)
at com.dropbox.core.DbxRequestUtil.readJsonFromResponse(DbxRequestUtil.java:218)
at com.dropbox.core.DbxClient$4.handle(DbxClient.java:275)
at com.dropbox.core.DbxClient$4.handle(DbxClient.java:270)
at com.dropbox.core.DbxRequestUtil.doGet(DbxRequestUtil.java:269)
at com.dropbox.core.DbxClient.doGet(DbxClient.java:1804)
at com.dropbox.core.DbxClient.getAccountInfo(DbxClient.java:270)
4

1 回答 1

2

It seems like whatever JSON the library was trying to parse was corrupted.

That being said, an AssertionError being propagated out of a public API in a production setting is always a bug. An assertion error basically means an assumption the library author made is not always true. The code either needs to be corrected so that the assumption is always true, or a more relevant Exception subclass should be thrown and documented as part of the API.

In fact, here is the issue on the Dropbox issue tracker for that library.

DbxClient.getAccountInfo fails with AssertionError.

You may wish to comment on that issue and provide more details (i.e a stacktrace and a description of what you were doing), as the issue submitter provided none.

于 2013-09-13T18:22:52.953 回答