Skip to content

ReplaceStackWithDeque sometimes fails with an exception #87

Description

@koppor

org.openrewrite.internal.RecipeRunException: Exception while visiting project file 'src\main\java\org\jabref\model\openoffice\ootext\OOTextI
ntoOO.java (in OOTextIntoOO.write)', caused by: org.openrewrite.java.controlflow.ControlFlowIllegalStateException: Unable to create new J.VariableDeclarations with name pairIterator

File: https://github.com/JabRef/jabref/blob/main/src/main/java/org/jabref/model/openoffice/ootext/OOTextIntoOO.java

Details
```
org.openrewrite.internal.RecipeRunException: Exception while visiting project file 'src\main\java\org\jabref\model\openoffice\ootext\OOTextI
ntoOO.java (in OOTextIntoOO.write)', caused by: org.openrewrite.java.controlflow.ControlFlowIllegalStateException: Unable to create new J.Vari
ableDeclarations with name `pairIterator`
        AST: J.ForEachLoop(padding=org.openrewrite.java.tree.J$ForEachLoop$Padding@1cdd3384, id=300fe438-9af5-44c7-b3e5-f2efec566c14, prefix=S
pace(comments=<0 comments>, whitespace='\n┬ÀÔéü┬ÀÔéé┬ÀÔéâ┬ÀÔéä┬ÀÔéà┬ÀÔéå┬ÀÔéç┬ÀÔéê┬ÀÔéë┬ÀÔéè┬ÀÔéü┬ÀÔéé┬ÀÔéâ┬ÀÔéä┬ÀÔéà┬ÀÔéå┬ÀÔéç┬ÀÔéê┬ÀÔéë┬ÀÔéè
'), markers=Markers(id=7f8ffa86-0646-4c43-b758-2f899d90e725, markers=[]), control=OOPair pair  attributes, body=J.Block(paddin
g=org.openrewrite.java.tree.J$Block$Padding@2034cf68, id=aba06d4c-25e9-45df-884f-f0ed5bb8ca89, prefix=Space(comments=<0 comments>, whitespace=
'┬ÀÔéü'), markers=Markers(id=7f8ffa86-0646-4c43-b758-2f899d90e725, markers=[]), statik=JRightPadded(element=false, after=Space(comments=<0 com
ments>, whitespace='')), statements=[String key = pair.a, String value = pair.b, J.Switch(id=2e9e8660-65f7-4cbc-aac9-62e89b2a35cf, prefix=Spac
e(comments=<0 comments>, whitespace='\n┬ÀÔéü┬ÀÔéé┬ÀÔéâ┬ÀÔéä┬ÀÔéà┬ÀÔéå┬ÀÔéç┬ÀÔéê┬ÀÔéë┬ÀÔéè┬ÀÔéü┬ÀÔéé┬ÀÔéâ┬ÀÔéä┬ÀÔéà┬ÀÔéå┬ÀÔéç┬ÀÔéê┬ÀÔéë┬ÀÔéè┬ÀÔ
éü┬ÀÔéé┬ÀÔéâ┬ÀÔéä'), markers=Markers(id=7f8ffa86-0646-4c43-b758-2f899d90e725, markers=[]), selector=(key), cases=J.Block(padding=org.openrewri
te.java.tree.J$Block$Padding@42f68ad0, id=1fbbba97-fd9d-4923-86b0-880f7064e83a, prefix=Space(comments=<0 comments>, whitespace='┬ÀÔéü'), marke
rs=Markers(id=7f8ffa86-0646-4c43-b758-2f899d90e725, markers=[]), statik=JRightPadded(element=false, after=Space(comments=<0 comments>, whitesp
ace='')), statements=[case "oo:ParaStyleName":
                                  // 

if (StringUtil.isNullOrEmpty(value)) { LOGGER.debug("oo:ParaStyleName inherited"); } else { if (setParagraphStyle(cursor, value)) { // Presumably tested already: LOGGER.debug(String.format("oo:ParaStyleName=\"%s\" failed", value)); } } break;, default: LOGGER.warn(String.format("Unexpected attribute '%s' for <%s>", key, tagName)); break;], end=Space(comments=<0 comments>, whitespace='\n┬ÀÔéü┬ÀÔéé┬ÀÔéâ┬ÀÔéä┬ÀÔéà┬ÀÔéå┬ÀÔéç┬ÀÔéê┬ÀÔéë┬ÀÔéè┬À Ôéü┬ÀÔéé┬ÀÔéâ┬ÀÔéä┬ÀÔéà┬ÀÔéå┬ÀÔéç┬ÀÔéê┬ÀÔéë┬ÀÔéè┬ÀÔéü┬ÀÔéé┬ÀÔéâ┬ÀÔéä')))], end=Space(comments=<0 comments>, whitespace='\n┬ÀÔéü┬ÀÔéé┬ÀÔéâ┬ÀÔéä ┬ÀÔéà┬ÀÔéå┬ÀÔéç┬ÀÔéê┬ÀÔéë┬ÀÔéè┬ÀÔéü┬ÀÔéé┬ÀÔéâ┬ÀÔéä┬ÀÔéà┬ÀÔéå┬ÀÔéç┬ÀÔéê┬ÀÔéë┬ÀÔéè'))) Cursor: Cursor{ForEachLoop->Case->Block->Switch->Block->WhileLoop->Block->MethodDeclaration->JRightPadded(element=MethodDeclaration{or g.jabref.model.openoffice.ootext.OOTextIntoOO{name=write,return=void,parameters=[{undefined},{undefined},org.jabref.model.openoffice.ootext.OO Text]}}, after=Space(comments=<0 comments>, whitespace=''))->Block->ClassDeclaration->CompilationUnit->root}, at org.openrewrite.java.controlf low.ControlFlow$ControlFlowAnalysis.createFakeIteratorVariableDeclarations(ControlFlow.java:812) ```

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status
    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions