This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 88021 - NPE in gdb.GdbProxyVL.logMessage(GdbProxyVL.java:94)
Summary: NPE in gdb.GdbProxyVL.logMessage(GdbProxyVL.java:94)
Status: RESOLVED FIXED
Alias: None
Product: cnd
Classification: Unclassified
Component: Debugger (show other bugs)
Version: 5.x
Hardware: All All
: P1 blocker (vote)
Assignee: Nikolay Molchanov
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-10-26 05:41 UTC by Nikolay Molchanov
Modified: 2009-06-25 10:59 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nikolay Molchanov 2006-10-26 05:41:14 UTC
I updated sources, rebuilt everything, started debugging a sample project 
MP, and got a NPE inthe middle of debugging. Looks like there is  a 
regression caused by fixed for IZ 87589 (commit was done 10/25 at 6:30 PM 
by gordonp@netbeans.org). Here is a stack trace:

java.lang.NullPointerException
	at java.io.Writer.write(Writer.java:126)
	at org.netbeans.modules.cnd.debugger.gdb.GdbProxyVL.logMessage(GdbProxyVL.java:94)
	at
org.netbeans.modules.cnd.debugger.gdb.GdbProxyCL.exec_interrupt(GdbProxyCL.java:597)
	at org.netbeans.modules.cnd.debugger.gdb.GdbProxy.exec_interrupt(GdbProxy.java:144)
	at
org.netbeans.modules.cnd.debugger.gdb.GdbDebuggerImpl.interrupt(GdbDebuggerImpl.java:185)
	at
org.netbeans.modules.cnd.debugger.gdb.actions.StepActionProvider.runAction(StepActionProvider.java:121)
	at
org.netbeans.modules.cnd.debugger.gdb.actions.StepActionProvider.doAction(StepActionProvider.java:93)
	at
org.netbeans.modules.cnd.debugger.gdb.actions.StepActionProvider$1.run(StepActionProvider.java:143)
	at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:499)
[catch] at
org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:932)


Here is a part of code, where the exception happened (GdbProxyVL.java:94):

    public void logMessage(String message) {
        if (logFile != null) {
            try {
94:             logFile.write(message);
                logFile.flush();
            } catch (IOException ioex) {
            }
        }
        if (gdbConsoleWindow != null) {
            gdbConsoleWindow.add(message);
        }
    }
Comment 1 Nikolay Molchanov 2006-10-26 06:33:35 UTC
The root of the problem is in new method logMessage(String message), which
does not check if the message is null, and passes it to logFile.write(message),
which tries to get message.length() and gets the NPE. I fixed this bug.

Tag: release55
User: NikMolchanov
Date: 2006/10/25 22:16:08

Modified:
   cnd/gdb/src/org/netbeans/modules/cnd/debugger/gdb/GdbProxyVL.java

Log:
 IZ 88021 NPE in gdb.GdbProxyVL.logMessage(GdbProxyVL.java:94)
 - Don't log null messages.

File Changes:

Directory: /cnd/gdb/src/org/netbeans/modules/cnd/debugger/gdb/
==============================================================

File [changed]: GdbProxyVL.java
Url:
http://cnd.netbeans.org/source/browse/cnd/gdb/src/org/netbeans/modules/cnd/debugger/gdb/GdbProxyVL.java?r1=1.2.2.18&r2=1.2.2.19
Delta lines:  +1 -0
-------------------
--- GdbProxyVL.java	26 Oct 2006 01:30:42 -0000	1.2.2.18
+++ GdbProxyVL.java	26 Oct 2006 05:16:03 -0000	1.2.2.19
@@ -89,6 +89,7 @@
      * @param message - a message from the debugger
      */
     public void logMessage(String message) {
+        if (message == null) return;
         if (logFile != null) {
             try {
                 logFile.write(message);

---------------------------------------------------------------------
Comment 2 Nikolay Molchanov 2006-10-26 06:35:23 UTC
The fix is integrated in "release55" branch.