ks8219 opened a new issue, #9422: URL: https://github.com/apache/netbeans/issues/9422
### Apache NetBeans version Apache NetBeans 30 ### What happened We're using the Netbeans/OpenIDE platform as the underlying framework for our application, STAR-CCM+. Some time ago, one of our testing engineers ran across an issue in which an embedded window is floated and docked several times. See attached screen recording. https://github.com/user-attachments/assets/7bc4538d-5448-4e57-8b8e-c0fa2017a124 From the stack trace (see attached), one can see that the problem originates in the `getModeTopComponentPreviousIndex()` method defined in the **DefaultModel** class (part of the _org.netbeans.core.windows.model_ package). [StackTrace.txt](https://github.com/user-attachments/files/28480474/StackTrace.txt) Looking at the source code... ``` /** Gets the tab index of the given top component before it was moved to sliding/separate mode */ @Override public int getModeTopComponentPreviousIndex(ModeImpl mode, String tcID) { ModeModel modeModel = getModelForMode(mode); return modeModel == null ? null : modeModel.getTopComponentPreviousIndex(tcID); } ``` ... it is possible that the `modeModel` variable can be `null`, and the `return` statement tries to accommodate for this possibility; however, in this case it tries to return a value `null` from the method. The compiler appears to allocate an `Integer` variable for this, then unboxes into an `int`. But the problem is that the value in the `Integer` is `null`, and the call to `Integer::intValue()` fails. ### Language / Project Type / NetBeans Component Netbeans/OpenIDE platform ### How to reproduce I can reproduce this in our application; however, I do not have a stand-alone example external of our application that I can provide. (And, quite honestly, I'm not sure how to create a small demonstrable platform-based application, let alone one that will reliably reproduce the problem.) I've tried reproducing in the Netbeans IDE, but as yet have not been able to do so. It is possible that our application exposes a situation that does not normally occur otherwise. Nevertheless, you can see the reproduction from the attached video, and you can see in the code for `DefaultModel` where and under condition it occurs. ### Did this work correctly in an earlier version? No / Don't know ### Operating System We've seen this in Windows 10 and Linux CentOS 7.9. Have not tried under later versions. ### JDK Originally observed using JDK 17 ### Apache NetBeans packaging Apache NetBeans platform ### Anything else I've been able to mitigate this for our application by adjusting our own copy of the platform code such that it returns a value -1 rather than `null`, so this does not seem to be an issue for us any longer. However, as far as I can tell in GitHub, the code in which the runtime could try to unbox a `null` `Integer` still exists, whether or not it will actually be exercised in a real application. I'm not sure off-hand what a 'correct' value should be returned from the method if the `modeModel` is `null`, or perhaps whether it might be more appropriate to adjust the return type on the method to `Integer`, thus avoiding the unboxing operation. In any event, I thought I should bring this to your attention. ### Are you willing to submit a pull request? No -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected] For further information about the NetBeans mailing lists, visit: https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
