You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by "Jason Valentine (JIRA)" <ji...@apache.org> on 2007/11/19 15:45:43 UTC

[jira] Created: (DERBY-3215) Potential NullPointerException in CachedPage class

Potential NullPointerException in CachedPage class
--------------------------------------------------

                 Key: DERBY-3215
                 URL: https://issues.apache.org/jira/browse/DERBY-3215
             Project: Derby
          Issue Type: Bug
          Components: Store
    Affects Versions: 10.3.1.4
         Environment: Windows XP
            Reporter: Jason Valentine


There's a potential for a NullPointerException to be thrown in the in the org.apache.derby.impl.store.raw.data.CachedPage class.  In the writePage() method, there's a test of the myContainer reference to ensure it's not null (line 771), however in the else block, myContainer is dereferenced (line 836), where a NullPointerException is guaranteed to be thrown.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (DERBY-3215) Potential NullPointerException in CachedPage class

Posted by "Dag H. Wanvik (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-3215?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Dag H. Wanvik updated DERBY-3215:
---------------------------------

         Priority: Minor  (was: Major)
    Fix Version/s: 10.4.0.0

> Potential NullPointerException in CachedPage class
> --------------------------------------------------
>
>                 Key: DERBY-3215
>                 URL: https://issues.apache.org/jira/browse/DERBY-3215
>             Project: Derby
>          Issue Type: Bug
>          Components: Store
>    Affects Versions: 10.3.1.4
>         Environment: Windows XP
>            Reporter: Jason Valentine
>            Assignee: Dag H. Wanvik
>            Priority: Minor
>             Fix For: 10.4.0.0
>
>         Attachments: DERBY-3215.diff
>
>
> There's a potential for a NullPointerException to be thrown in the in the org.apache.derby.impl.store.raw.data.CachedPage class.  In the writePage() method, there's a test of the myContainer reference to ensure it's not null (line 771), however in the else block, myContainer is dereferenced (line 836), where a NullPointerException is guaranteed to be thrown.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (DERBY-3215) Potential NullPointerException in CachedPage class

Posted by "Dag H. Wanvik (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-3215?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Dag H. Wanvik updated DERBY-3215:
---------------------------------

    Derby Info: [Patch Available]

> Potential NullPointerException in CachedPage class
> --------------------------------------------------
>
>                 Key: DERBY-3215
>                 URL: https://issues.apache.org/jira/browse/DERBY-3215
>             Project: Derby
>          Issue Type: Bug
>          Components: Store
>    Affects Versions: 10.3.1.4
>         Environment: Windows XP
>            Reporter: Jason Valentine
>            Assignee: Dag H. Wanvik
>         Attachments: DERBY-3215.diff
>
>
> There's a potential for a NullPointerException to be thrown in the in the org.apache.derby.impl.store.raw.data.CachedPage class.  In the writePage() method, there's a test of the myContainer reference to ensure it's not null (line 771), however in the else block, myContainer is dereferenced (line 836), where a NullPointerException is guaranteed to be thrown.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (DERBY-3215) Potential NullPointerException in CachedPage class

Posted by "Dag H. Wanvik (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-3215?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12544099 ] 

Dag H. Wanvik commented on DERBY-3215:
--------------------------------------

Patch DERBY-3215.diff committed as svn 596853. I will make a follow-up patch
to address Knut's suggestion; I think it is a good idea, but I prefer to commit just this
minimal error patch first.


> Potential NullPointerException in CachedPage class
> --------------------------------------------------
>
>                 Key: DERBY-3215
>                 URL: https://issues.apache.org/jira/browse/DERBY-3215
>             Project: Derby
>          Issue Type: Bug
>          Components: Store
>    Affects Versions: 10.3.1.4
>         Environment: Windows XP
>            Reporter: Jason Valentine
>            Assignee: Dag H. Wanvik
>            Priority: Minor
>             Fix For: 10.4.0.0
>
>         Attachments: DERBY-3215.diff
>
>
> There's a potential for a NullPointerException to be thrown in the in the org.apache.derby.impl.store.raw.data.CachedPage class.  In the writePage() method, there's a test of the myContainer reference to ensure it's not null (line 771), however in the else block, myContainer is dereferenced (line 836), where a NullPointerException is guaranteed to be thrown.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Closed: (DERBY-3215) Potential NullPointerException in CachedPage class

Posted by "Dag H. Wanvik (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-3215?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Dag H. Wanvik closed DERBY-3215.
--------------------------------


Issue fixed on both trunk and 10.3 branch, so closing. Jason, please feel free to reopen
if you don't agree the issue should be closed.

> Potential NullPointerException in CachedPage class
> --------------------------------------------------
>
>                 Key: DERBY-3215
>                 URL: https://issues.apache.org/jira/browse/DERBY-3215
>             Project: Derby
>          Issue Type: Bug
>          Components: Store
>    Affects Versions: 10.3.1.4
>         Environment: Windows XP
>            Reporter: Jason Valentine
>            Assignee: Dag H. Wanvik
>            Priority: Minor
>             Fix For: 10.4.0.0
>
>         Attachments: DERBY-3215.diff, DERBY-3215b.diff
>
>
> There's a potential for a NullPointerException to be thrown in the in the org.apache.derby.impl.store.raw.data.CachedPage class.  In the writePage() method, there's a test of the myContainer reference to ensure it's not null (line 771), however in the else block, myContainer is dereferenced (line 836), where a NullPointerException is guaranteed to be thrown.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (DERBY-3215) Potential NullPointerException in CachedPage class

Posted by "Dag H. Wanvik (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-3215?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12561177#action_12561177 ] 

Dag H. Wanvik commented on DERBY-3215:
--------------------------------------

Merged both patches to 10.3 branch as svn 614068 after running 
regression tests without errors.

> Potential NullPointerException in CachedPage class
> --------------------------------------------------
>
>                 Key: DERBY-3215
>                 URL: https://issues.apache.org/jira/browse/DERBY-3215
>             Project: Derby
>          Issue Type: Bug
>          Components: Store
>    Affects Versions: 10.3.1.4
>         Environment: Windows XP
>            Reporter: Jason Valentine
>            Assignee: Dag H. Wanvik
>            Priority: Minor
>             Fix For: 10.4.0.0
>
>         Attachments: DERBY-3215.diff, DERBY-3215b.diff
>
>
> There's a potential for a NullPointerException to be thrown in the in the org.apache.derby.impl.store.raw.data.CachedPage class.  In the writePage() method, there's a test of the myContainer reference to ensure it's not null (line 771), however in the else block, myContainer is dereferenced (line 836), where a NullPointerException is guaranteed to be thrown.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (DERBY-3215) Potential NullPointerException in CachedPage class

Posted by "Dag H. Wanvik (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-3215?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Dag H. Wanvik updated DERBY-3215:
---------------------------------

    Attachment: DERBY-3215.diff

Enclosing a patch which removes the unused second argument.
Running regression tests.

> Potential NullPointerException in CachedPage class
> --------------------------------------------------
>
>                 Key: DERBY-3215
>                 URL: https://issues.apache.org/jira/browse/DERBY-3215
>             Project: Derby
>          Issue Type: Bug
>          Components: Store
>    Affects Versions: 10.3.1.4
>         Environment: Windows XP
>            Reporter: Jason Valentine
>         Attachments: DERBY-3215.diff
>
>
> There's a potential for a NullPointerException to be thrown in the in the org.apache.derby.impl.store.raw.data.CachedPage class.  In the writePage() method, there's a test of the myContainer reference to ensure it's not null (line 771), however in the else block, myContainer is dereferenced (line 836), where a NullPointerException is guaranteed to be thrown.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Assigned: (DERBY-3215) Potential NullPointerException in CachedPage class

Posted by "Dag H. Wanvik (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-3215?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Dag H. Wanvik reassigned DERBY-3215:
------------------------------------

    Assignee: Dag H. Wanvik

> Potential NullPointerException in CachedPage class
> --------------------------------------------------
>
>                 Key: DERBY-3215
>                 URL: https://issues.apache.org/jira/browse/DERBY-3215
>             Project: Derby
>          Issue Type: Bug
>          Components: Store
>    Affects Versions: 10.3.1.4
>         Environment: Windows XP
>            Reporter: Jason Valentine
>            Assignee: Dag H. Wanvik
>         Attachments: DERBY-3215.diff
>
>
> There's a potential for a NullPointerException to be thrown in the in the org.apache.derby.impl.store.raw.data.CachedPage class.  In the writePage() method, there's a test of the myContainer reference to ensure it's not null (line 771), however in the else block, myContainer is dereferenced (line 836), where a NullPointerException is guaranteed to be thrown.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (DERBY-3215) Potential NullPointerException in CachedPage class

Posted by "Knut Anders Hatlen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-3215?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12543725 ] 

Knut Anders Hatlen commented on DERBY-3215:
-------------------------------------------

Thanks Dag, the patch looks good to me. +1 to commit if the tests pass.

Perhaps out of the scope for this issue, but I think it would increase the readability of the method if we moved the contents of the "else" part nearer the beginning of the method and said

    FileContainer myContainer = ...;
    if (myContainer == null) {
        throw ...;
    }

As it is now, with more than 50 lines between "if" and "else", it is not so easy to see what "else" refers to.

> Potential NullPointerException in CachedPage class
> --------------------------------------------------
>
>                 Key: DERBY-3215
>                 URL: https://issues.apache.org/jira/browse/DERBY-3215
>             Project: Derby
>          Issue Type: Bug
>          Components: Store
>    Affects Versions: 10.3.1.4
>         Environment: Windows XP
>            Reporter: Jason Valentine
>            Assignee: Dag H. Wanvik
>            Priority: Minor
>             Fix For: 10.4.0.0
>
>         Attachments: DERBY-3215.diff
>
>
> There's a potential for a NullPointerException to be thrown in the in the org.apache.derby.impl.store.raw.data.CachedPage class.  In the writePage() method, there's a test of the myContainer reference to ensure it's not null (line 771), however in the else block, myContainer is dereferenced (line 836), where a NullPointerException is guaranteed to be thrown.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (DERBY-3215) Potential NullPointerException in CachedPage class

Posted by "Knut Anders Hatlen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-3215?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12543598 ] 

Knut Anders Hatlen commented on DERBY-3215:
-------------------------------------------

Here's the relevant part of CachedPage:

			throw dataFactory.markCorrupt(
                StandardException.newException(
                    SQLState.FILE_WRITE_PAGE_EXCEPTION, nested, 
                    identity, new Integer(myContainer.getPageSize())));

What's interesting is that it passes in two arguments to the message builder (identity and new Integer(...)). However, message.xml defines the message like this:

            <msg>
                <name>XSDG1.D</name>
                <text>Page {0} could not be written to disk, please check if disk is full.</text>
                <arg>page</arg>
            </msg>

That is, there's only one argument, which is the page identity. So the parameter which causes the NPE is not even used when the message is generated, and it can probably be removed.

> Potential NullPointerException in CachedPage class
> --------------------------------------------------
>
>                 Key: DERBY-3215
>                 URL: https://issues.apache.org/jira/browse/DERBY-3215
>             Project: Derby
>          Issue Type: Bug
>          Components: Store
>    Affects Versions: 10.3.1.4
>         Environment: Windows XP
>            Reporter: Jason Valentine
>
> There's a potential for a NullPointerException to be thrown in the in the org.apache.derby.impl.store.raw.data.CachedPage class.  In the writePage() method, there's a test of the myContainer reference to ensure it's not null (line 771), however in the else block, myContainer is dereferenced (line 836), where a NullPointerException is guaranteed to be thrown.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (DERBY-3215) Potential NullPointerException in CachedPage class

Posted by "Dag H. Wanvik (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-3215?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Dag H. Wanvik updated DERBY-3215:
---------------------------------

    Attachment: DERBY-3215b.diff

DERBY-3215b changes to code to test for empty myContainer up front
as suggested, plus removes some unused imports. Regression tests
passed. Will commit shortly.

> Potential NullPointerException in CachedPage class
> --------------------------------------------------
>
>                 Key: DERBY-3215
>                 URL: https://issues.apache.org/jira/browse/DERBY-3215
>             Project: Derby
>          Issue Type: Bug
>          Components: Store
>    Affects Versions: 10.3.1.4
>         Environment: Windows XP
>            Reporter: Jason Valentine
>            Assignee: Dag H. Wanvik
>            Priority: Minor
>             Fix For: 10.4.0.0
>
>         Attachments: DERBY-3215.diff, DERBY-3215b.diff
>
>
> There's a potential for a NullPointerException to be thrown in the in the org.apache.derby.impl.store.raw.data.CachedPage class.  In the writePage() method, there's a test of the myContainer reference to ensure it's not null (line 771), however in the else block, myContainer is dereferenced (line 836), where a NullPointerException is guaranteed to be thrown.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (DERBY-3215) Potential NullPointerException in CachedPage class

Posted by "Dag H. Wanvik (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-3215?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12544504 ] 

Dag H. Wanvik commented on DERBY-3215:
--------------------------------------

DERBY-3215b committed as svn 597123.


> Potential NullPointerException in CachedPage class
> --------------------------------------------------
>
>                 Key: DERBY-3215
>                 URL: https://issues.apache.org/jira/browse/DERBY-3215
>             Project: Derby
>          Issue Type: Bug
>          Components: Store
>    Affects Versions: 10.3.1.4
>         Environment: Windows XP
>            Reporter: Jason Valentine
>            Assignee: Dag H. Wanvik
>            Priority: Minor
>             Fix For: 10.4.0.0
>
>         Attachments: DERBY-3215.diff, DERBY-3215b.diff
>
>
> There's a potential for a NullPointerException to be thrown in the in the org.apache.derby.impl.store.raw.data.CachedPage class.  In the writePage() method, there's a test of the myContainer reference to ensure it's not null (line 771), however in the else block, myContainer is dereferenced (line 836), where a NullPointerException is guaranteed to be thrown.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (DERBY-3215) Potential NullPointerException in CachedPage class

Posted by "Dag H. Wanvik (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-3215?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12543704 ] 

Dag H. Wanvik commented on DERBY-3215:
--------------------------------------

I should mention that the wrong usage of FILE_WRITE_PAGE_EXCEPTION occurs in one more
instance in the same method (except for the one susceptible to the empty pointer). The patch 
corrects both instances. There are no occurences in other classes.

> Potential NullPointerException in CachedPage class
> --------------------------------------------------
>
>                 Key: DERBY-3215
>                 URL: https://issues.apache.org/jira/browse/DERBY-3215
>             Project: Derby
>          Issue Type: Bug
>          Components: Store
>    Affects Versions: 10.3.1.4
>         Environment: Windows XP
>            Reporter: Jason Valentine
>            Assignee: Dag H. Wanvik
>            Priority: Minor
>             Fix For: 10.4.0.0
>
>         Attachments: DERBY-3215.diff
>
>
> There's a potential for a NullPointerException to be thrown in the in the org.apache.derby.impl.store.raw.data.CachedPage class.  In the writePage() method, there's a test of the myContainer reference to ensure it's not null (line 771), however in the else block, myContainer is dereferenced (line 836), where a NullPointerException is guaranteed to be thrown.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (DERBY-3215) Potential NullPointerException in CachedPage class

Posted by "Dag H. Wanvik (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-3215?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Dag H. Wanvik resolved DERBY-3215.
----------------------------------

    Resolution: Fixed
    Derby Info:   (was: [Patch Available])

> Potential NullPointerException in CachedPage class
> --------------------------------------------------
>
>                 Key: DERBY-3215
>                 URL: https://issues.apache.org/jira/browse/DERBY-3215
>             Project: Derby
>          Issue Type: Bug
>          Components: Store
>    Affects Versions: 10.3.1.4
>         Environment: Windows XP
>            Reporter: Jason Valentine
>            Assignee: Dag H. Wanvik
>            Priority: Minor
>             Fix For: 10.4.0.0
>
>         Attachments: DERBY-3215.diff, DERBY-3215b.diff
>
>
> There's a potential for a NullPointerException to be thrown in the in the org.apache.derby.impl.store.raw.data.CachedPage class.  In the writePage() method, there's a test of the myContainer reference to ensure it's not null (line 771), however in the else block, myContainer is dereferenced (line 836), where a NullPointerException is guaranteed to be thrown.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (DERBY-3215) Potential NullPointerException in CachedPage class

Posted by "Mike Matrigali (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-3215?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Mike Matrigali updated DERBY-3215:
----------------------------------

    Fix Version/s: 10.3.2.1

just updating that the fix has already been merged to the 10.3 branch in january.

> Potential NullPointerException in CachedPage class
> --------------------------------------------------
>
>                 Key: DERBY-3215
>                 URL: https://issues.apache.org/jira/browse/DERBY-3215
>             Project: Derby
>          Issue Type: Bug
>          Components: Store
>    Affects Versions: 10.3.1.4
>         Environment: Windows XP
>            Reporter: Jason Valentine
>            Assignee: Dag H. Wanvik
>            Priority: Minor
>             Fix For: 10.3.2.1, 10.4.1.3
>
>         Attachments: DERBY-3215.diff, DERBY-3215b.diff
>
>
> There's a potential for a NullPointerException to be thrown in the in the org.apache.derby.impl.store.raw.data.CachedPage class.  In the writePage() method, there's a test of the myContainer reference to ensure it's not null (line 771), however in the else block, myContainer is dereferenced (line 836), where a NullPointerException is guaranteed to be thrown.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.