Skip to content

Code conversion error #9046

@edrobal

Description

@edrobal

Apache NetBeans version

Apache NetBeans 28

What happened

Code conversion truncate code

Language / Project Type / NetBeans Component

java class library

How to reproduce

Initial code is

        ByteArrayOutputStream outStream = new ByteArrayOutputStream();
        int len;

        byte[] buffer = new byte[1024];

        while ((len = input.read(buffer)) != -1) {
            outStream.write(buffer, 0, len);
        }
        input.close();

        return outStream.toByteArray();

Netbeans show convert to try-with-ressources and after code is

        try (input) {
            outStream = new ByteArrayOutputStream();
            int len;
            byte[] buffer = new byte[1024];
            while ((len = input.read(buffer)) != -1) {
                outStream.write(buffer, 0, len);
            }
        }

Did this work correctly in an earlier version?

No / Don't know

Operating System

Linux 6.4.0-150600.23.65-default

JDK

Java: 24.0.2; OpenJDK 64-Bit Server VM 24.0.2+12

Apache NetBeans packaging

Apache NetBeans binary zip

Anything else

No response

Are you willing to submit a pull request?

No

Metadata

Metadata

Labels

Java[ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form)hintskind:bugBug report or fix

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions