question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

try with resources formatting adding extra space

See original GitHub issue

Apache NetBeans version

Apache NetBeans 13

What happened

try with resources formatting adds an extra space after the opening parens.

 try ( InputStream is = new FileInputStream("foo")) {
      ^   

Unfortunately, we use checkstyle and this causes a rule violation and we use format on save.

How to reproduce

Type the following and format try (InputStream is = new FileInputStream("foo")) { }

Did this work correctly in an earlier version?

Apache NetBeans 12.6

Operating System

Windows 10

JDK

Eclipse temurin jdk-17.0.0.35-hotspot

Apache NetBeans packaging

Apache NetBeans binary zip

Anything else

This has been plaguing people on and off for several old versions. It used to be related to the nb-javac plugin but I have tried with/without/activated/deactivated and it doesn’t seem to make a difference, it keeps adding the extra space.

Some previous issues: https://issues.apache.org/jira/browse/NETBEANS-236 https://issues.apache.org/jira/browse/NETBEANS-4641 https://issues.apache.org/jira/browse/NETBEANS-4676 https://issues.apache.org/jira/browse/NETBEANS-6129 https://issues.apache.org/jira/browse/NETBEANS-6400

Are you willing to submit a pull request?

No

Code of Conduct

Yes

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:7
  • Comments:14 (5 by maintainers)

github_iconTop GitHub Comments

7reactions
neilcsmith-netcommented, Sep 15, 2022

Putting a milestone on this, and will take a look ASAP. Be good to get this fixed in NB16 - annoying a lot of people, myself included.

3reactions
PavelCibulkacommented, Jun 13, 2022

I’ve installed Netbeans 14 (without importing settings from previous versions). This problem is still in.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Extra space in try with resources without nb-javac - Apache
Automatic formatting adds a space for try with resources if nb-javac is not installed: try ( MyType myObject = new MyType()) { }...
Read more >
What is the code convention for formatting try-with-resources?
I'd like to know what the code convention is for formatting try blocks with resources, in particular with more than one resource.
Read more >
[jira] [Created] (NETBEANS-6129) Extra space in try with ...
Summary: Extra space in try with resources without nb-javac Key: ... formatting adds a space for try with resources if nb-javac is not ......
Read more >
Additonal try-with-resources formatting options : IDEA-99550
For the "Align when multiline" setting, it would be useful to have a "when more than one" option. That way single resource can...
Read more >
Indentation: multiple try with resource not checked · Issue #3131
Please try formatting the example in the 3 major IDEs (Eclipse, ... Update: Indentation remains same even if a new resource is added...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found