You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2021/12/01 07:34:32 UTC

[Bug 65715] New: An inexplicable ‘break’ statement in XSSFSheet

https://bz.apache.org/bugzilla/show_bug.cgi?id=65715

            Bug ID: 65715
           Summary: An inexplicable ‘break’ statement in XSSFSheet
           Product: POI
           Version: unspecified
          Hardware: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: XSSF
          Assignee: dev@poi.apache.org
          Reporter: 1215170944@qq.com
  Target Milestone: ---

public XSSFDrawing getDrawingPatriarch() {
        CTDrawing ctDrawing = getCTDrawing();
        if (ctDrawing != null) {
            // Search the referenced drawing in the list of the sheet's
relations
            for (RelationPart rp : getRelationParts()){
                POIXMLDocumentPart p = rp.getDocumentPart();
                if (p instanceof XSSFDrawing) {
                    XSSFDrawing dr = (XSSFDrawing)p;
                    String drId = rp.getRelationship().getId();
                    if (drId.equals(ctDrawing.getId())){
                        return dr;
                    }
                    break;
                }
            }
            LOG.atError().log("Can't find drawing with id={} in the list of the
sheet's relationships", ctDrawing.getId());
        }
        return null;
    }

I don‘t know why there is a ’break‘ statement.It makes the loop
meaningless.Actually,the 'if' in front means there may be multiple drawing in
one sheet.So i think this maybe a bug.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 65715] An inexplicable ‘break’ statement in XSSFSheet

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=65715

PJ Fanning <fa...@yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 OS|                            |All

--- Comment #1 from PJ Fanning <fa...@yahoo.com> ---
Thanks - does look strange. I've modified it with r1895446

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 65715] An inexplicable ‘break’ statement in XSSFSheet

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=65715

PJ Fanning <fa...@yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 65715] An inexplicable ‘break’ statement in XSSFSheet

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=65715

--- Comment #2 from PJ Fanning <fa...@yahoo.com> ---
should be r1895447

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 65715] An inexplicable ‘break’ statement in XSSFSheet

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=65715

--- Comment #3 from PJ Fanning <fa...@yahoo.com> ---
I ran a test in jdoodle and break does leave the for loop early.

```
import java.util.*;

public class MyClass {
    public static void main(String args[]) {
        ArrayList<String> strs = new ArrayList<>();
        strs.add("aon");
        strs.add("dó");
        strs.add("trí");
        for(String str : strs) {
            System.out.println(str);
            break;
        }
    }
}
```

In this case, only `aon` gets printed.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org