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

java.lang.IndexOutOfBoundsException: Index: 1, Size: 1 #89

Closed
wuseal opened this issue Dec 9, 2018 · 3 comments
Closed

java.lang.IndexOutOfBoundsException: Index: 1, Size: 1 #89

wuseal opened this issue Dec 9, 2018 · 3 comments
Assignees
Labels
Milestone

Comments

@wuseal
Copy link
Owner

wuseal commented Dec 9, 2018

Plugin version: 2.3.0
Error Json String:

{
  "mime_type": "image/jpeg",
  "file_name": "136149.jpg",
  "source_type": "chk",
  "source_id": 3000193,
  "year_month": "201810",
  "day": "31",
  "type_document_id": 11,
  "usr_id": 55572,
  "file_desc": "текст примечания",
  "bytes": "/9j/4AAQSkZ...Nd/VJ/Ef",
  "description": {
    "cmis:objectTypeId": "D:esp:act",
    "esp:doc_name": "текст примечания",
    "esp:iin_bin": "101040011256",
    "esp:create_date": "2018.09.31",
    "esp:reg_num": "181000000103012/00022",
    "esp:reg_date": "2018.10.01",
    "esp:author": "Уалиева Асель Мухаметбековна"
  }
}

Exception log:

java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
	at java.util.Collections$SingletonList.get(Collections.java:4815)
	at wu.seal.jsontokotlin.utils.classblockparse.ClassCodeParser.getPropertyKeyword(ClassCodeParser.kt:104)
	at wu.seal.jsontokotlin.utils.classblockparse.ClassCodeParser.getProperties(ClassCodeParser.kt:34)
	at wu.seal.jsontokotlin.utils.classblockparse.ClassCodeParser.getKotlinDataClass(ClassCodeParser.kt:11)
	at wu.seal.jsontokotlin.utils.KotlinDataClassFileGenerator.generateMultipleDataClassFiles(KotlinDataClassFileGenerator.kt:61)
	at wu.seal.jsontokotlin.GenerateKotlinFileAction.doGenerateKotlinDataClassFileAction(GenerateKotlinFileAction.kt:108)
	at wu.seal.jsontokotlin.GenerateKotlinFileAction.actionPerformed(GenerateKotlinFileAction.kt:67)
	at com.intellij.openapi.actionSystem.ex.ActionUtil$1.run(ActionUtil.java:220)
	at com.intellij.openapi.actionSystem.ex.ActionUtil.performActionDumbAware(ActionUtil.java:237)
	at com.intellij.openapi.actionSystem.impl.ActionMenuItem$ActionTransmitter.lambda$actionPerformed$0(ActionMenuItem.java:301)
	at com.intellij.openapi.wm.impl.FocusManagerImpl.runOnOwnContext(FocusManagerImpl.java:307)
	at com.intellij.openapi.wm.impl.IdeFocusManagerImpl.runOnOwnContext(IdeFocusManagerImpl.java:104)
	at com.intellij.openapi.actionSystem.impl.ActionMenuItem$ActionTransmitter.actionPerformed(ActionMenuItem.java:291)
	at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
	at com.intellij.openapi.actionSystem.impl.ActionMenuItem.lambda$fireActionPerformed$0(ActionMenuItem.java:111)
	at com.intellij.openapi.application.TransactionGuardImpl.runSyncTransaction(TransactionGuardImpl.java:88)
	at com.intellij.openapi.application.TransactionGuardImpl.lambda$submitTransaction$1(TransactionGuardImpl.java:111)
	at com.intellij.openapi.application.TransactionGuardImpl.submitTransaction(TransactionGuardImpl.java:120)
	at com.intellij.openapi.application.TransactionGuard.submitTransaction(TransactionGuard.java:122)
	at com.intellij.openapi.actionSystem.impl.ActionMenuItem.fireActionPerformed(ActionMenuItem.java:111)
	at com.intellij.ui.plaf.beg.BegMenuItemUI.doClick(BegMenuItemUI.java:528)
	at com.intellij.ui.plaf.beg.BegMenuItemUI.access$300(BegMenuItemUI.java:48)
	at com.intellij.ui.plaf.beg.BegMenuItemUI$MyMouseInputHandler.mouseReleased(BegMenuItemUI.java:548)
	at java.awt.Component.processMouseEvent(Component.java:6548)
@kezhenxu94
Copy link
Collaborator

{
  "mime_type": "image/jpeg",
  "file_name": "136149.jpg",
  "source_type": "chk",
  "source_id": 3000193,
  "year_month": "201810",
  "day": "31",
  "type_document_id": 11,
  "usr_id": 55572,
  "file_desc": "текст примечания",
  "bytes": "/9j/4AAQSkZ...Nd/VJ/Ef",
  "description": {
    "cmis:objectTypeId": "D:esp:act",
    "esp:doc_name": "текст примечания",
    "esp:iin_bin": "101040011256",
    "esp:create_date": "2018.09.31",
    "esp:reg_num": "181000000103012/00022",
    "esp:reg_date": "2018.10.01",
    "esp:author": "Уалиева Асель Мухаметбековна"
  }
}

How do we deal with the key like esp:doc_name?

@kezhenxu94
Copy link
Collaborator

This exception did not reproduce in the master branch and the generated code is:

data class Test(
    @SerializedName("bytes") val bytes: String = "", // /9j/4AAQSkZ...Nd/VJ/Ef
    @SerializedName("day") val day: String = "", // 31
    @SerializedName("description") val description: Description = Description(),
    @SerializedName("file_desc") val fileDesc: String = "", // текст примечания
    @SerializedName("file_name") val fileName: String = "", // 136149.jpg
    @SerializedName("mime_type") val mimeType: String = "", // image/jpeg
    @SerializedName("source_id") val sourceId: Int = 0, // 3000193
    @SerializedName("source_type") val sourceType: String = "", // chk
    @SerializedName("type_document_id") val typeDocumentId: Int = 0, // 11
    @SerializedName("usr_id") val usrId: Int = 0, // 55572
    @SerializedName("year_month") val yearMonth: String = "" // 201810
) {
    
    data class Description(
        @SerializedName("cmis:objectTypeId") val cmisobjectTypeId: String = "", // D:esp:act
        @SerializedName("esp:author") val espauthor: String = "", // Уалиева Асель Мухаметбековна
        @SerializedName("esp:create_date") val espcreateDate: String = "", // 2018.09.31
        @SerializedName("esp:doc_name") val espdocName: String = "", // текст примечания
        @SerializedName("esp:iin_bin") val espiinBin: String = "", // 101040011256
        @SerializedName("esp:reg_date") val espregDate: String = "", // 2018.10.01
        @SerializedName("esp:reg_num") val espregNum: String = "" // 181000000103012/00022
    )
}

@wuseal
Copy link
Owner Author

wuseal commented Dec 30, 2018

@kezhenxu94 This exception happened every time when I do generate action.
Using Idea version: Community 2017.1 or Community 2018.3.1

wuseal pushed a commit that referenced this issue Jan 6, 2019
@wuseal wuseal self-assigned this Jan 6, 2019
kezhenxu94 added a commit that referenced this issue Jan 12, 2019
@kezhenxu94 kezhenxu94 added this to the 3.0 milestone Jan 12, 2019
@kezhenxu94 kezhenxu94 added the fixed but not released this issue has been solved but is not released yet label Jan 12, 2019
@wuseal wuseal removed the fixed but not released this issue has been solved but is not released yet label Jan 18, 2019
@wuseal wuseal closed this as completed Jan 18, 2019
wuseal pushed a commit that referenced this issue Sep 20, 2021
wuseal pushed a commit that referenced this issue Sep 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants